Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89d79a0f7d |
@@ -184,9 +184,19 @@ const Betting = {
|
|||||||
|
|
||||||
const nextStreetIndex = this.STREETS.indexOf(state.street || "preflop") + 1;
|
const nextStreetIndex = this.STREETS.indexOf(state.street || "preflop") + 1;
|
||||||
state.street = this.STREETS[nextStreetIndex] || "river";
|
state.street = this.STREETS[nextStreetIndex] || "river";
|
||||||
state.actingSeatIndex = this.liveSeats(state).length > 1
|
|
||||||
? this.nextLiveIndex(state, state.dealerSeatIndex)
|
if (this.liveSeats(state).length <= 1) {
|
||||||
: null;
|
state.actingSeatIndex = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// After the flop the first live player left of the button acts — which heads-up
|
||||||
|
// is the big blind, since the button is the small blind. Naming the big blind
|
||||||
|
// directly also covers a button parked on a seat nobody is sitting in.
|
||||||
|
const { bbIndex, headsUp } = HoldemState.getBlindSeats(state);
|
||||||
|
state.actingSeatIndex = headsUp && bbIndex !== null && !state.seats[bbIndex].folded
|
||||||
|
? bbIndex
|
||||||
|
: this.nextLiveIndex(state, state.dealerSeatIndex);
|
||||||
},
|
},
|
||||||
|
|
||||||
isHandOver(state) {
|
isHandOver(state) {
|
||||||
@@ -207,15 +217,23 @@ const Betting = {
|
|||||||
|
|
||||||
const sb = Number(state.smallBlind) || 0;
|
const sb = Number(state.smallBlind) || 0;
|
||||||
const bb = Number(state.bigBlind) || 0;
|
const bb = Number(state.bigBlind) || 0;
|
||||||
const sbIndex = this.seatAt(state, state.dealerSeatIndex, 1);
|
const { sbIndex, bbIndex, headsUp } = HoldemState.getBlindSeats(state);
|
||||||
const bbIndex = this.seatAt(state, state.dealerSeatIndex, 2);
|
|
||||||
|
|
||||||
if (sb > 0 && state.seats[sbIndex].inHand) this.putIn(state, sbIndex, sb);
|
if (sbIndex === null || bbIndex === null) {
|
||||||
if (bb > 0 && state.seats[bbIndex].inHand) this.putIn(state, bbIndex, bb);
|
state.currentBet = 0;
|
||||||
|
state.actingSeatIndex = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sb > 0) this.putIn(state, sbIndex, sb);
|
||||||
|
if (bb > 0) this.putIn(state, bbIndex, bb);
|
||||||
|
|
||||||
state.currentBet = this.round(Math.max(this.committed(state.seats[sbIndex]), this.committed(state.seats[bbIndex])));
|
state.currentBet = this.round(Math.max(this.committed(state.seats[sbIndex]), this.committed(state.seats[bbIndex])));
|
||||||
state.lastRaiseSize = bb || 0;
|
state.lastRaiseSize = bb || 0;
|
||||||
state.actingSeatIndex = this.nextLiveIndex(state, bbIndex);
|
|
||||||
|
// Heads-up the button is the small blind and acts first before the flop; with
|
||||||
|
// three or more it's the seat after the big blind.
|
||||||
|
state.actingSeatIndex = headsUp ? sbIndex : this.nextLiveIndex(state, bbIndex);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Winners get their share put back in front of them.
|
// Winners get their share put back in front of them.
|
||||||
|
|||||||
@@ -183,38 +183,10 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// A seat that has anything of a player in it — a name, chips, cash in, or a hand
|
document.getElementById("seatCountInput").addEventListener("change", e => {
|
||||||
// in progress. Shrinking the table throws these away permanently, and it also
|
HoldemState.resizeSeats(state, Number(e.target.value));
|
||||||
// orphans them in the session standings, where they keep their winnings but lose
|
hooks.save(state);
|
||||||
// the stack and buy-in the settle-up is worked out from.
|
Render.renderAll();
|
||||||
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 => {
|
document.getElementById("directionSelect").addEventListener("change", e => {
|
||||||
|
|||||||
@@ -163,10 +163,36 @@ const HoldemState = {
|
|||||||
state.dealerSeatIndex = this.nextSeatIndex(state, state.dealerSeatIndex, 1);
|
state.dealerSeatIndex = this.nextSeatIndex(state, state.dealerSeatIndex, 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Seats dealt into this hand, in blind order starting from the seat after the
|
||||||
|
// button. Blinds follow the players, not the chairs — the seats immediately left
|
||||||
|
// of the button are empty often enough that counting chairs posts them to nobody.
|
||||||
|
liveOrderFromButton(state) {
|
||||||
|
const order = [];
|
||||||
|
for (let step = 1; step <= state.seatCount; step++) {
|
||||||
|
const index = this.nextSeatIndex(state, state.dealerSeatIndex, step);
|
||||||
|
if (state.seats[index].inHand) order.push(index);
|
||||||
|
}
|
||||||
|
return order;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Who posts what. Heads-up is its own rule: with two players the button posts the
|
||||||
|
// small blind, which is the opposite of the usual order.
|
||||||
getBlindSeats(state) {
|
getBlindSeats(state) {
|
||||||
const sbIndex = this.nextSeatIndex(state, state.dealerSeatIndex, 1);
|
const live = this.liveOrderFromButton(state);
|
||||||
const bbIndex = this.nextSeatIndex(state, state.dealerSeatIndex, 2);
|
const dealerIndex = state.dealerSeatIndex;
|
||||||
return { dealerIndex: state.dealerSeatIndex, sbIndex, bbIndex };
|
|
||||||
|
if (live.length < 2) {
|
||||||
|
return { dealerIndex, sbIndex: null, bbIndex: null, headsUp: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (live.length === 2) {
|
||||||
|
const buttonIsPlaying = state.seats[dealerIndex].inHand;
|
||||||
|
const sbIndex = buttonIsPlaying ? dealerIndex : live[0];
|
||||||
|
const bbIndex = live.find(i => i !== sbIndex);
|
||||||
|
return { dealerIndex, sbIndex, bbIndex, headsUp: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { dealerIndex, sbIndex: live[0], bbIndex: live[1], headsUp: false };
|
||||||
},
|
},
|
||||||
|
|
||||||
startNextHand(state) {
|
startNextHand(state) {
|
||||||
|
|||||||
Reference in New Issue
Block a user