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

35 lines
599 B
TypeScript
Raw Normal View History

2025-01-29 23:43:33 +01:00
export type MessageKind = "click" | "hello" | "update" | "endgame" | "reset" | "spectate";
export interface Message {
2024-09-25 13:40:22 +02:00
kind: MessageKind,
2025-01-29 23:43:33 +01:00
data: Click | Update | Hello | EndGame | Reset | Spectate,
}
export interface Click {
2024-09-25 13:40:22 +02:00
x: number,
y: number
}
2025-01-29 23:43:33 +01:00
export type Symbol = "x" | "o";
export interface Update {
2025-01-29 23:43:33 +01:00
last: { x: number, y: number, symbol: Symbol }
}
2024-09-08 12:05:02 +02:00
export interface Hello {
2024-09-25 11:58:56 +02:00
id: number,
2024-09-25 13:40:22 +02:00
symbol: "x" | "o"
2024-09-08 12:05:02 +02:00
}
2024-09-09 14:09:00 +02:00
export interface EndGame {
issue: "win" | "lose" | "draw"
}
type Reset = undefined;
2025-01-29 23:43:33 +01:00
export interface Spectate {
grid: (Symbol | undefined)[]
}