mirror of
https://github.com/cassoule/flopobot_v2.git
synced 2026-03-18 21:40:27 +01:00
blackjack split fix
This commit is contained in:
@@ -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": {
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user