1
0
mirror of https://github.com/thib8956/tic-tac-toe-ws.git synced 2025-02-22 16:58:14 +00:00
tic-tac-toe-ws/common.ts
2025-01-29 23:43:33 +01:00

35 lines
599 B
TypeScript

export type MessageKind = "click" | "hello" | "update" | "endgame" | "reset" | "spectate";
export interface Message {
kind: MessageKind,
data: Click | Update | Hello | EndGame | Reset | Spectate,
}
export interface Click {
x: number,
y: number
}
export type Symbol = "x" | "o";
export interface Update {
last: { x: number, y: number, symbol: Symbol }
}
export interface Hello {
id: number,
symbol: "x" | "o"
}
export interface EndGame {
issue: "win" | "lose" | "draw"
}
type Reset = undefined;
export interface Spectate {
grid: (Symbol | undefined)[]
}