From 251fe05d287c345065797c45bf642e6927993b79 Mon Sep 17 00:00:00 2001 From: Maciej Caderek Date: Fri, 1 Apr 2022 21:05:34 +0200 Subject: [PATCH] WIP --- src/player/Player.ts | 15 ++++++++++++++- src/types.ts | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/player/Player.ts b/src/player/Player.ts index 0d4c9c6..a88b11b 100644 --- a/src/player/Player.ts +++ b/src/player/Player.ts @@ -113,7 +113,7 @@ class Player { await this.board.frame(position, this.game.header); this.board.render(); - if (state.boardConfig.speech) { + if (this.ply > 0 && state.boardConfig.speech) { this.speech.say(sanToText(position.move?.san as string)); } @@ -128,6 +128,19 @@ class Player { sfx.move.play(); } } + + if (position.end === 0) { + const result = this.game.header.Result; + if (result) { + this.speech.say( + result === "1-0" + ? "White wins!" + : result === "0-1" + ? "Black wins!" + : "Draw" + ); + } + } } async first() { diff --git a/src/types.ts b/src/types.ts index cbdbea1..ddf82a3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -89,8 +89,8 @@ export type BoardConfig = { showChecks: boolean; showCoords: boolean; showShadows: boolean; - sounds: boolean; - speech: boolean; + sounds?: boolean; + speech?: boolean; flipped: boolean; };