MCPcopy Create free account
hub / github.com/code100x/chess / resetMoveTimer

Method resetMoveTimer

apps/ws/src/Game.ts:309–319  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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');

Callers 2

seedMovesMethod · 0.95
makeMoveMethod · 0.95

Calls 1

endGameMethod · 0.95

Tested by

no test coverage detected