From 4f72dda6fa1318f93adddec0a29d0c6ac256ae12 Mon Sep 17 00:00:00 2001 From: JoshHeaps Date: Tue, 1 Sep 2026 02:33:03 -0600 Subject: [PATCH] Ask before a smaller table deletes the players sitting in it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Typing a smaller number into "Seats at table" silently threw away every seat past the new count. Nine players down to six removed three of them — names, stacks and buy-ins gone, no confirmation, no way back. It also quietly falsified the settle-up. Those players keep their rows in the session standings, because the hand log remembers who won what, but the seat they were read from no longer exists — so a player who had just won a pot showed as having bought in for nothing and holding nothing. Shrinking now says who it is about to remove and asks, and either way the change is undoable like the rest of the table's actions. Growing the table, and shrinking onto chairs nobody is sitting in, still happen without a word. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_015bnp7xKUPFFSpwkYNFaPgb --- .../wwwroot/js/casino/holdem/main.js | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/JoshHeaps.Net/wwwroot/js/casino/holdem/main.js b/JoshHeaps.Net/wwwroot/js/casino/holdem/main.js index f6915ae..30137cc 100644 --- a/JoshHeaps.Net/wwwroot/js/casino/holdem/main.js +++ b/JoshHeaps.Net/wwwroot/js/casino/holdem/main.js @@ -183,10 +183,38 @@ document.addEventListener("DOMContentLoaded", () => { }); }; - document.getElementById("seatCountInput").addEventListener("change", e => { - HoldemState.resizeSeats(state, Number(e.target.value)); - hooks.save(state); - Render.renderAll(); + // A seat that has anything of a player in it — a name, chips, cash in, or a hand + // in progress. Shrinking the table throws these away permanently, and it also + // orphans them in the session standings, where they keep their winnings but lose + // the stack and buy-in the settle-up is worked out from. + const seatHasSomeoneIn = player => + !!(player.name && player.name.trim()) || + player.inHand || + (Number(player.stack) || 0) > 0 || + (Number(player.buyIns) || 0) > 0 || + (Number(player.amountOverride) || 0) > 0; + + document.getElementById("seatCountInput").addEventListener("change", async e => { + const requested = Math.max(2, Math.min(24, Math.floor(Number(e.target.value)) || state.seatCount)); + const losing = state.seats.slice(requested).filter(seatHasSomeoneIn); + + if (losing.length > 0) { + const who = losing + .map((p, i) => HoldemState.displayName(p, requested + state.seats.slice(requested).indexOf(p))) + .join(", "); + const ok = await Dialog.confirm({ + title: `Remove ${losing.length} ${losing.length === 1 ? "player" : "players"}?`, + message: `Going down to ${requested} seats takes ${who} off the table along with their chips and buy-ins, and their session totals stop adding up.`, + confirmLabel: "Remove them", + danger: true, + }); + if (!ok) { + e.target.value = state.seatCount; + return; + } + } + + runUndoable(`Table set to ${requested} seats.`, () => HoldemState.resizeSeats(state, requested)); }); document.getElementById("directionSelect").addEventListener("change", e => {