From 438bb4c8a3fa1b61b5e7829a9b68f381b1aa3151 Mon Sep 17 00:00:00 2001 From: b3ni15 Date: Sun, 21 Dec 2025 02:54:09 +0100 Subject: [PATCH] Add roundStartsAt property to Table class and update state management --- src/game/tables.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/game/tables.js b/src/game/tables.js index 114de22..6777626 100644 --- a/src/game/tables.js +++ b/src/game/tables.js @@ -30,6 +30,7 @@ class Table { this.turnTimeout = null; this.turnEndsAt = null; this.turnCounter = 0; + this.roundStartsAt = null; this.clients = new Set(); } @@ -60,6 +61,7 @@ class Table { maxBet: MAX_BET, roundId: this.roundId, turnEndsAt: this.turnEndsAt, + roundStartsAt: this.roundStartsAt, dealerHand, currentSeatIndex: this.currentSeatIndex, seats: this.seats.map((seat, index) => ({ @@ -271,10 +273,14 @@ class Table { return; } + this.roundStartsAt = Date.now() + ROUND_START_DELAY_MS; + this.broadcastState(); this.roundTimeout = setTimeout(() => { this.roundTimeout = null; const hasBets = this.seats.some((seat) => seat.bet > 0); if (!hasBets) { + this.roundStartsAt = null; + this.broadcastState(); return; } void this.startRound(); @@ -287,6 +293,7 @@ class Table { } this.clearTurnTimer(); + this.roundStartsAt = null; this.phase = 'playing'; this.roundId += 1; this.deck = shuffle(createDeck()); @@ -466,6 +473,7 @@ class Table { resetRound() { this.clearTurnTimer(); + this.roundStartsAt = null; for (const seat of this.seats) { if (!seat.userId) { continue; @@ -484,7 +492,7 @@ class Table { } } -const tables = Array.from({ length: 3 }, (_, index) => new Table(index + 1, 7)); +const tables = Array.from({ length: 3 }, (_, index) => new Table(index + 1, 4)); export function listTables() { return tables.map((table) => table.snapshot());