| 307 | } |
| 308 | |
| 309 | async resetMoveTimer() { |
| 310 | if (this.moveTimer) { |
| 311 | clearTimeout(this.moveTimer) |
| 312 | } |
| 313 | const turn = this.board.turn(); |
| 314 | const timeLeft = GAME_TIME_MS - (turn === 'w' ? this.player1TimeConsumed : this.player2TimeConsumed); |
| 315 | |
| 316 | this.moveTimer = setTimeout(() => { |
| 317 | this.endGame("TIME_UP", turn === 'b' ? 'WHITE_WINS' : 'BLACK_WINS'); |
| 318 | }, timeLeft); |
| 319 | } |
| 320 | |
| 321 | async exitGame(user : User) { |
| 322 | this.endGame('PLAYER_EXIT', user.userId === this.player2UserId ? 'WHITE_WINS' : 'BLACK_WINS'); |