From 97b490c0580d4f8f3fe382a3ab581b07ee94c32c Mon Sep 17 00:00:00 2001 From: Jose Conde Date: Tue, 16 Jul 2024 15:06:35 +0200 Subject: [PATCH] sending tiles when finishing game --- src/game/DominoesGame.ts | 4 ++-- src/game/MatchSession.ts | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/game/DominoesGame.ts b/src/game/DominoesGame.ts index 8585620..20097ad 100644 --- a/src/game/DominoesGame.ts +++ b/src/game/DominoesGame.ts @@ -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); } diff --git a/src/game/MatchSession.ts b/src/game/MatchSession.ts index 788f589..95c2689 100644 --- a/src/game/MatchSession.ts +++ b/src/game/MatchSession.ts @@ -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, };