game workflow corrected
This commit is contained in:
@@ -1222,14 +1222,13 @@ export class GameWebSocketService {
|
||||
if (!game) return;
|
||||
|
||||
// Only clean up games that haven't finished yet
|
||||
if (!game.finished) {
|
||||
if (game.state !== GameState.FINISHED && game.state !== GameState.CANCELLED) {
|
||||
logOther(`Handling abandoned game ${gameCode}`, { gameId: game.id });
|
||||
|
||||
// Mark game as abandoned in database
|
||||
// Mark game as cancelled in database
|
||||
await this.gameRepository.update(game.id, {
|
||||
finished: true,
|
||||
state: GameState.CANCELLED,
|
||||
enddate: new Date(),
|
||||
// Could add an 'abandoned' flag if the database schema supports it
|
||||
});
|
||||
|
||||
// Clean up all Redis data for this abandoned game
|
||||
@@ -2236,7 +2235,7 @@ export class GameWebSocketService {
|
||||
const game = await this.gameRepository.findByGameCode(gameCode);
|
||||
if (game) {
|
||||
await this.gameRepository.update(game.id, {
|
||||
finished: true,
|
||||
state: GameState.FINISHED,
|
||||
winner: winnerId,
|
||||
enddate: new Date()
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user