Fixed speach sythesis conditions

This commit is contained in:
Maciej Caderek
2022-04-25 17:05:30 +02:00
parent eefacbf92b
commit cd77bae2c8
2 changed files with 9 additions and 12 deletions

View File

@@ -54,7 +54,4 @@ const PiecesCache = {
}, },
}; };
// @ts-ignore
window.PiecesCache = PiecesCache;
export default PiecesCache; export default PiecesCache;

View File

@@ -190,18 +190,12 @@ class Player {
await this.board.frame(position, this.game.header); await this.board.frame(position, this.game.header);
this.board.render(); this.board.render();
if (window.speechSynthesis) { if (window.speechSynthesis && state.siteConfig.speech) {
if (this.ply > 0 && state.siteConfig.speech) { if (this.ply > 0) {
this.speech.say(sanToText(position.move?.san as string)); this.speech.say(sanToText(position.move?.san as string));
} }
if (this.ply > 0 && state.siteConfig.sounds) { if (position.end === 0) {
state.boardConfig.piecesStyle.includes("anarchy")
? this.playAnarchySFX(position)
: this.playSFX(position);
}
if (position.end === 0 && state.siteConfig.speech) {
const result = this.game.header.Result; const result = this.game.header.Result;
if (result) { if (result) {
this.speech.say( this.speech.say(
@@ -214,6 +208,12 @@ class Player {
} }
} }
} }
if (this.ply > 0 && state.siteConfig.sounds) {
state.boardConfig.piecesStyle.includes("anarchy")
? this.playAnarchySFX(position)
: this.playSFX(position);
}
} }
async first() { async first() {