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

feat: synchronize colors between clients

This commit is contained in:
2026-01-27 13:08:40 +01:00
parent d8733c48b3
commit eb6011fa9d
4 changed files with 28 additions and 18 deletions

View File

@@ -1,9 +1,12 @@
export type MessageKind = "click" | "hello" | "update" | "endgame" | "reset" | "spectate";
export interface Message {
kind: MessageKind,
data: Click | Update | Hello | 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,
@@ -12,8 +15,10 @@ export interface Click {
export type Symbol = "x" | "o";
export type SymbolWithHue = { symbol: Symbol, hue: number };
export interface Update {
last: { x: number, y: number, symbol: Symbol }
last: { x: number, y: number, symbol: Symbol, hue: number}
}
export interface Hello {
@@ -27,8 +32,7 @@ export interface EndGame {
type Reset = undefined;
export interface Spectate {
grid: (Symbol | undefined)[]
grid: (SymbolWithHue | undefined)[]
}