From c24a5b4d85eb8e8e9584916ed067a3b07e4dbac2 Mon Sep 17 00:00:00 2001 From: Thibaud Date: Thu, 30 Jan 2025 09:50:55 +0100 Subject: [PATCH] fix: spectator message on game reset --- client.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client.ts b/client.ts index ea3ac00..bbc69b0 100644 --- a/client.ts +++ b/client.ts @@ -28,7 +28,7 @@ interface Shape { let grid: Cell[] = new Array(9); let pendingEvts: Point[] = []; -let spectate = false; // is this client in spectator mode? +let isSpectator = false; // is this client in spectator mode? let myId: number | null = null; let mySymbol: "x" | "o" | null = null; let canvasMsg: string = "Offline..."; @@ -181,7 +181,7 @@ function init() { resizeCanvas(ctx); // Init canvas canvas.addEventListener("click", (evt) => { - if (spectate) { + if (isSpectator) { console.debug("ignoring click in spectator mode"); return; } @@ -206,7 +206,7 @@ function init() { break; } case "spectate": { - spectate = true; + isSpectator = true; canvasMsg = "connected as spectator"; // Initialize grid state for (const [index, sym] of (msg.data as Spectate).grid.entries()) { @@ -243,7 +243,9 @@ function init() { break; } case "reset": { - canvasMsg = `Game reset... Id #${myId}, playing as ${mySymbol}`; + if (!isSpectator) { + canvasMsg = `Game reset... Id #${myId}, playing as ${mySymbol}`; + } grid = new Array(9); pendingEvts = []; resizeCanvas(ctx);