diff --git a/src/pong/src/state.ts b/src/pong/src/state.ts index f73353a..e3f0aff 100644 --- a/src/pong/src/state.ts +++ b/src/pong/src/state.ts @@ -279,6 +279,12 @@ class StateI { const gameId = newUUID() as unknown as GameId; this.games.set(gameId, g); + setTimeout(() => { + if (!g.ready_checks[0] && !g.ready_checks[1]) { + this.fastify.log.info(`paused game ${gameId} has been canceled`); + this.cleanupGame(gameId, g); + } + }, 1000 * 31); this.fastify.log.info('new paused game \'' + gameId + '\''); return gameId; } @@ -573,7 +579,7 @@ class StateI { game.local, ); this.fastify.log.info('SetGameOutcome !'); - if (!game.local) { + if (!game.local && game.ready_checks[0] && game.ready_checks[1]) { const payload = { nextGame: chat_text }; try { const resp = await fetch('http://app-chat/broadcastNextGame', { diff --git a/src/pong/src/tour.ts b/src/pong/src/tour.ts index b7df36f..cf82fab 100644 --- a/src/pong/src/tour.ts +++ b/src/pong/src/tour.ts @@ -70,6 +70,7 @@ export class Tournament { const [u1, u2] = matchup; const gameId = newUUID() as PongGameId; const game = State.initGame(null, gameId, u1, u2); + State.broadcastTourStatus(`A Tournament game between ${this.users.get(u1)?.name ?? 'the left player'} and ${this.users.get(u2)?.name ?? 'the right player'} will start ASAP`); if (game) { game.onEnd = () => this.gameEnd(); }