1
0
mirror of https://github.com/thib8956/tic-tac-toe-ws.git synced 2026-01-29 14:23:22 +00:00
Files
tic-tac-toe-ws/common.ts

39 lines
809 B
TypeScript

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