feat(ttt): added draw status in ttt match history
This commit is contained in:
parent
830f251537
commit
f87a991441
7 changed files with 36 additions and 17 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -2013,7 +2013,8 @@
|
|||
"enum": [
|
||||
"winX",
|
||||
"winO",
|
||||
"other"
|
||||
"other",
|
||||
"draw"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,7 +104,8 @@
|
|||
"enum": [
|
||||
"winX",
|
||||
"winO",
|
||||
"other"
|
||||
"other",
|
||||
"draw"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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']),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue