From cd77bae2c8efc63c27ecb5baa122eafcb656d8a1 Mon Sep 17 00:00:00 2001 From: Maciej Caderek Date: Mon, 25 Apr 2022 17:05:30 +0200 Subject: [PATCH] Fixed speach sythesis conditions --- src/board/loaders/PiecesCache.ts | 3 --- src/player/Player.ts | 18 +++++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/board/loaders/PiecesCache.ts b/src/board/loaders/PiecesCache.ts index 0b5922b..48baf47 100644 --- a/src/board/loaders/PiecesCache.ts +++ b/src/board/loaders/PiecesCache.ts @@ -54,7 +54,4 @@ const PiecesCache = { }, }; -// @ts-ignore -window.PiecesCache = PiecesCache; - export default PiecesCache; diff --git a/src/player/Player.ts b/src/player/Player.ts index 1ba9eeb..608b646 100644 --- a/src/player/Player.ts +++ b/src/player/Player.ts @@ -190,18 +190,12 @@ class Player { await this.board.frame(position, this.game.header); this.board.render(); - if (window.speechSynthesis) { - if (this.ply > 0 && state.siteConfig.speech) { + if (window.speechSynthesis && state.siteConfig.speech) { + if (this.ply > 0) { this.speech.say(sanToText(position.move?.san as string)); } - if (this.ply > 0 && state.siteConfig.sounds) { - state.boardConfig.piecesStyle.includes("anarchy") - ? this.playAnarchySFX(position) - : this.playSFX(position); - } - - if (position.end === 0 && state.siteConfig.speech) { + if (position.end === 0) { const result = this.game.header.Result; if (result) { 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() {