23 lines
453 B
TypeScript
23 lines
453 B
TypeScript
export type xo = 'x' | 'o'
|
|
type Tile = xo | ''
|
|
type Row = [Tile, Tile, Tile]
|
|
|
|
export type Game = {
|
|
phase: Phase
|
|
turn: xo
|
|
board: [Row, Row, Row]
|
|
players: Record<string, xo>
|
|
names: Record<xo, string>
|
|
winLine?: WinLine
|
|
}
|
|
|
|
type Phase =
|
|
| 'play'
|
|
| 'gameOver'
|
|
|
|
export type WinLine = {
|
|
direction: 'horizontal' | 'vertical' | 'diagonal' | 'diagonal-reverse'
|
|
position: 'top' | 'middle' | 'bottom' | 'left' | 'center' | 'right'
|
|
player: xo
|
|
}
|