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");
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": {

View File

@@ -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;
}