This commit is contained in:
Jose Conde
2024-07-08 10:21:56 +02:00
parent f67c262b0e
commit ca0f1466c2
4 changed files with 18 additions and 5 deletions

View File

@ -69,15 +69,18 @@ export class MatchSession {
let gameNumber: number = 0;
this.matchInProgress = true
this.playerNotificationManager.notifyMatchState(this);
let winnerIndex: number | null = null;
while (this.matchInProgress) {
this.currentGame = new DominoesGame(this.players, this.rng);
if (winnerIndex !== null) {
this.currentGame.setForcedInitialPlayerIndex(winnerIndex);
}
gameNumber += 1;
this.state = 'started'
this.logger.info(`Game #${gameNumber} started`);
// this.game.reset()
const gameSummary = await this.currentGame.start();
this.logger.debug('gameSummary :>> ', gameSummary);
winnerIndex = this.players.findIndex(player => player.id === gameSummary.winner?.id);
this.setScores();
this.checkMatchWinner();
this.resetPlayers();