From 3115df3cdd5952a874257ac18f4c3e00e87d4a6d Mon Sep 17 00:00:00 2001 From: milo Date: Sun, 15 Feb 2026 11:52:39 +0100 Subject: [PATCH] blackjack split fix --- src/game/blackjack.js | 5 ++++- src/server/routes/blackjack.js | 18 ++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/game/blackjack.js b/src/game/blackjack.js index 81c8083..18177b1 100644 --- a/src/game/blackjack.js +++ b/src/game/blackjack.js @@ -361,7 +361,10 @@ export function applyAction(room, playerId, action) { if (hand.stood || hand.busted) throw new Error("Already ended"); hand.hasActed = true; hand.cards.push(draw(room.shoe)); - if (isBust(hand.cards)) hand.busted = true; + if (isBust(hand.cards)) { + hand.busted = true; + p.activeHand++; + } return "hit"; } case "stand": { diff --git a/src/server/routes/blackjack.js b/src/server/routes/blackjack.js index 3d2716a..5d01d99 100644 --- a/src/server/routes/blackjack.js +++ b/src/server/routes/blackjack.js @@ -81,25 +81,23 @@ export function blackjackRoutes(io) { for (const p of Object.values(room.players)) { try { if (!p.inRound) continue; - const h = p.hands[p.activeHand]; - if (h && !h.hasActed && !h.busted && !h.stood && !h.surrendered) { - h.surrendered = true; + // Handle all remaining hands (important after splits) + for (let i = p.activeHand; i < p.hands.length; i++) { + const h = p.hands[i]; + if (!h || h.busted || h.stood || h.surrendered) continue; h.stood = true; h.hasActed = true; - //room.leavingAfterRound[p.id] = true; // kick at end of round - emitToast({ type: "player-timeout", userId: p.id }); changed = true; - } else if (h && h.hasActed && !h.stood) { - h.stood = true; - //room.leavingAfterRound[p.id] = true; // kick at end of round + } + if (changed) { + p.activeHand = p.hands.length; emitToast({ type: "player-auto-stand", userId: p.id }); - changed = true; } } catch (e) { console.log(e); } } - if (changed) emitUpdate("auto-surrender", snapshot(room)); + //if (changed) emitUpdate("auto-surrender", snapshot(room)); return changed; }