feat(ttt): added draw status in ttt match history

This commit is contained in:
Maix0 2026-01-07 00:16:39 +01:00 committed by Maix0
parent 830f251537
commit f87a991441
7 changed files with 36 additions and 17 deletions

View file

@ -3,7 +3,7 @@ import type { Database } from './_base';
import { UserId } from './user';
import { isNullish } from '@shared/utils';
export type TicTacToeOutcome = 'winX' | 'winO' | 'other';
export type TicTacToeOutcome = 'winX' | 'winO' | 'draw' | 'other';
// describe every function in the object
export interface ITicTacToeDb extends Database {
setTTTGameOutcome(this: ITicTacToeDb, id: TTTGameId, player1: UserId, player2: UserId, outcome: TicTacToeOutcome): void,
@ -82,7 +82,7 @@ function TicTacToeGameFromRow(r: Partial<TicTacToeGameTable> | undefined): TicTa
if (isNullish(r.outcome)) return undefined;
if (isNullish(r.time)) return undefined;
if (r.outcome !== 'winX' && r.outcome !== 'winO' && r.outcome !== 'other') return undefined;
if (r.outcome !== 'winX' && r.outcome !== 'winO' && r.outcome !== 'other' && r.outcome !== 'draw') return undefined;
const date = Date.parse(r.time);
if (Number.isNaN(date)) return undefined;

View file

@ -2013,7 +2013,8 @@
"enum": [
"winX",
"winO",
"other"
"other",
"draw"
]
}
}

View file

@ -104,7 +104,8 @@
"enum": [
"winX",
"winO",
"other"
"other",
"draw"
]
}
}

View file

@ -17,7 +17,7 @@ const TTTHistoryResponse = {
playerX: Type.Object({ id: Type.String(), name: Type.String() }),
playerO: Type.Object({ id: Type.String(), name: Type.String() }),
date: Type.String(),
outcome: Type.Enum(['winX', 'winO', 'other']),
outcome: Type.Enum(['winX', 'winO', 'other', 'draw']),
}),
),
}),

View file

@ -14,7 +14,7 @@ export type GameUpdate = {
boardState: CellState[];
currentPlayer: 'X' | 'O';
gameState: 'winX' | 'winO' | 'concededX' | 'concededO' | 'draw' | 'ongoing';
gameState: 'winX' | 'winO' | 'draw' | 'ongoing';
}
export type GameMove = {