Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f72dda6fa |
@@ -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 => {
|
||||||
|
|||||||
@@ -159,20 +159,7 @@ const HoldemState = {
|
|||||||
return ((fromIndex + delta) % count + count) % count;
|
return ((fromIndex + delta) % count + count) % count;
|
||||||
},
|
},
|
||||||
|
|
||||||
// The button passes to the next player, not the next chair. Moving it one seat at
|
|
||||||
// a time parks it on empty chairs — with four players spread around ten seats it
|
|
||||||
// sits on nobody most hands — and that isn't only untidy: position and blinds are
|
|
||||||
// supposed to come round to each player at the same rate, and they don't if the
|
|
||||||
// button is rotating past chairs nobody is sitting in.
|
|
||||||
advanceButton(state) {
|
advanceButton(state) {
|
||||||
for (let step = 1; step <= state.seatCount; step++) {
|
|
||||||
const index = this.nextSeatIndex(state, state.dealerSeatIndex, step);
|
|
||||||
if (state.seats[index].inHand) {
|
|
||||||
state.dealerSeatIndex = index;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Nobody is dealt in; move it along anyway so it doesn't look stuck.
|
|
||||||
state.dealerSeatIndex = this.nextSeatIndex(state, state.dealerSeatIndex, 1);
|
state.dealerSeatIndex = this.nextSeatIndex(state, state.dealerSeatIndex, 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user