Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f72dda6fa |
@@ -184,19 +184,9 @@ 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
|
||||||
if (this.liveSeats(state).length <= 1) {
|
? this.nextLiveIndex(state, state.dealerSeatIndex)
|
||||||
state.actingSeatIndex = null;
|
: 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) {
|
||||||
@@ -217,23 +207,15 @@ 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, bbIndex, headsUp } = HoldemState.getBlindSeats(state);
|
const sbIndex = this.seatAt(state, state.dealerSeatIndex, 1);
|
||||||
|
const bbIndex = this.seatAt(state, state.dealerSeatIndex, 2);
|
||||||
|
|
||||||
if (sbIndex === null || bbIndex === null) {
|
if (sb > 0 && state.seats[sbIndex].inHand) this.putIn(state, sbIndex, sb);
|
||||||
state.currentBet = 0;
|
if (bb > 0 && state.seats[bbIndex].inHand) this.putIn(state, bbIndex, bb);
|
||||||
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,10 +183,38 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById("seatCountInput").addEventListener("change", e => {
|
// A seat that has anything of a player in it — a name, chips, cash in, or a hand
|
||||||
HoldemState.resizeSeats(state, Number(e.target.value));
|
// in progress. Shrinking the table throws these away permanently, and it also
|
||||||
hooks.save(state);
|
// orphans them in the session standings, where they keep their winnings but lose
|
||||||
Render.renderAll();
|
// the stack and buy-in the settle-up is worked out from.
|
||||||
|
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,36 +163,10 @@ 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 live = this.liveOrderFromButton(state);
|
const sbIndex = this.nextSeatIndex(state, state.dealerSeatIndex, 1);
|
||||||
const dealerIndex = state.dealerSeatIndex;
|
const bbIndex = this.nextSeatIndex(state, state.dealerSeatIndex, 2);
|
||||||
|
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