blackjack split fix

This commit is contained in:
milo
2026-02-15 11:52:39 +01:00
parent db7d9aec8f
commit 3115df3cdd
2 changed files with 12 additions and 11 deletions

View File

@@ -361,7 +361,10 @@ export function applyAction(room, playerId, action) {
if (hand.stood || hand.busted) throw new Error("Already ended"); if (hand.stood || hand.busted) throw new Error("Already ended");
hand.hasActed = true; hand.hasActed = true;
hand.cards.push(draw(room.shoe)); hand.cards.push(draw(room.shoe));
if (isBust(hand.cards)) hand.busted = true; if (isBust(hand.cards)) {
hand.busted = true;
p.activeHand++;
}
return "hit"; return "hit";
} }
case "stand": { case "stand": {

View File

@@ -81,25 +81,23 @@ export function blackjackRoutes(io) {
for (const p of Object.values(room.players)) { for (const p of Object.values(room.players)) {
try { try {
if (!p.inRound) continue; if (!p.inRound) continue;
const h = p.hands[p.activeHand]; // Handle all remaining hands (important after splits)
if (h && !h.hasActed && !h.busted && !h.stood && !h.surrendered) { for (let i = p.activeHand; i < p.hands.length; i++) {
h.surrendered = true; const h = p.hands[i];
if (!h || h.busted || h.stood || h.surrendered) continue;
h.stood = true; h.stood = true;
h.hasActed = true; h.hasActed = true;
//room.leavingAfterRound[p.id] = true; // kick at end of round
emitToast({ type: "player-timeout", userId: p.id });
changed = true; changed = true;
} else if (h && h.hasActed && !h.stood) { }
h.stood = true; if (changed) {
//room.leavingAfterRound[p.id] = true; // kick at end of round p.activeHand = p.hands.length;
emitToast({ type: "player-auto-stand", userId: p.id }); emitToast({ type: "player-auto-stand", userId: p.id });
changed = true;
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} }
} }
if (changed) emitUpdate("auto-surrender", snapshot(room)); //if (changed) emitUpdate("auto-surrender", snapshot(room));
return changed; return changed;
} }