sending tiles when finishing game

This commit is contained in:
Jose Conde 2024-07-16 15:06:35 +02:00
parent af78c26a93
commit 97b490c058
2 changed files with 7 additions and 7 deletions

View File

@ -217,9 +217,9 @@ export class DominoesGame extends EventEmitter {
gameId: this.id,
isBlocked: this.gameBlocked,
isTied: this.gameTied,
winner: this.winner?.getState(),
winner: this.winner?.getState(true),
score: this.players.map(player => ({id: player.id, name: player.name, score: player.score})),
players: this.players.map(player => player.getState())
players: this.players.map(player => player.getState(true))
}
this.emit('game-over', summary);
}

View File

@ -152,14 +152,14 @@ export class MatchSession {
this.status = 'end'
this.notificationService.sendEventToPlayers('server:match-finished', this.players, {
lastGame: gameSummary,
sessionState: this.getState(),
sessionState: this.getState(true),
});
} else {
this.status = 'waiting'
// await this.playerNotificationManager.notifyMatchState(this);
this.notificationService.sendEventToPlayers('server:game-finished', this.players, {
lastGame: gameSummary,
sessionState: this.getState()
sessionState: this.getState(true)
});
this.waitingForPlayers = true;
this.startGame();
@ -304,12 +304,12 @@ export class MatchSession {
return `GameSession:(${this.id} ${this.name})`;
}
getState(): MatchSessionState {
getState(showPips?: boolean): MatchSessionState {
return {
id: this.id,
name: this.name!,
creator: this.creator.id,
players: this.players.map(player => player.getState()),
players: this.players.map(player => player.getState(showPips)),
playersReady: this.numPlayersReady,
sessionInProgress: this.sessionInProgress,
maxPlayers: this.maxPlayers,
@ -321,7 +321,7 @@ export class MatchSession {
pointsToWin: this.pointsToWin,
status: this.sessionInProgress ? 'in progress' : 'waiting',
scoreboard: this.getScoreBoardState(),
matchWinner: this.matchWinner?.getState() || null,
matchWinner: this.matchWinner?.getState(true) || null,
matchInProgress: this.matchInProgress,
gameSummaries: this.gameSummaries,
};