Say when somebody is being dealt in for free, and give the dealer the post
Sitting down between the button and the big blind means the blinds have gone past you. The tool dealt those players straight in, silently. Measured: Eve takes a seat, and the next hand she is dealt cards in late position having put nothing in — a free hand, out of everyone else's night a couple of dollars at a time, with nothing anywhere on screen to tell the dealer it had happened. At a table there are two answers and the player picks one: post the big blind and come in now, or wait for the blind to reach them. The tool did neither and named neither. The deal prompt now names anyone about to be dealt in who has not paid for it, and carries the post as one tap. Nothing is forced — a home game that doesn't care can deal as before, and the sentence is still worth having on its own, because the dealer at least knows. The post goes in as a big blind out of that player's own stack, is live like any blind, and is spent at the end of the hand rather than becoming a standing charge. Somebody back from sitting out is owed one the same as a newcomer. The big blind of the hand isn't — they're already paying — and neither is anyone at a table that has not dealt a hand yet, where the whole table is new and nobody has been skipped. Deliberately one line for however many have walked up, not one each: the bar is docked over the felt and the felt has already shrunk as far as it goes on a phone, so every line costs seat area. A line apiece put the bar over two fifths of the bottom seat at 390x844. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_015bnp7xKUPFFSpwkYNFaPgb
This commit is contained in:
@@ -3406,6 +3406,38 @@ textarea:focus-visible {
|
||||
color: #9a9a9a;
|
||||
}
|
||||
|
||||
/* An aside that has something to press. It wraps rather than squeezing the button:
|
||||
on a phone the sentence takes the width it needs and the button drops under it,
|
||||
still at full tap size, instead of being crushed to a sliver at the end of a line. */
|
||||
.dealPromptLine.dealPromptDebt {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.4rem 0.55rem;
|
||||
}
|
||||
|
||||
.dealPromptDebtBtn {
|
||||
/* Sized down from a full action button — it's an option beside a sentence, not
|
||||
the thing the dealer came here to press. "Post blinds & deal" stays the button
|
||||
that looks like the button. */
|
||||
flex: 0 0 auto;
|
||||
min-height: 32px;
|
||||
padding: 0.24rem 0.7rem;
|
||||
font-size: 0.72rem;
|
||||
background: rgba(245, 213, 71, 0.1);
|
||||
border: 1px solid rgba(245, 213, 71, 0.45);
|
||||
color: #f0d98c;
|
||||
}
|
||||
|
||||
@media (max-width: 700px), (pointer: coarse) {
|
||||
/* A fingertip needs 44px, and this one moves money. */
|
||||
.dealPromptDebtBtn {
|
||||
min-height: 44px;
|
||||
padding: 0.4rem 0.9rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Touch targets on a wide touch screen ----------
|
||||
|
||||
Every touch-target rule in this file sits behind `max-width: 700px`, and width was
|
||||
|
||||
@@ -643,6 +643,44 @@ const ActionBar = {
|
||||
wrap.appendChild(out);
|
||||
}
|
||||
|
||||
// Somebody who has just sat down between the button and the big blind has had
|
||||
// the blinds go past them, and dealing them in there is a free hand in late
|
||||
// position. At a table the answer is that they post the big blind to come in
|
||||
// now, or wait for it to reach them. The tool used to do neither and say
|
||||
// nothing: it dealt them in for free, and the dealer had no way to know it had
|
||||
// happened. Both answers are offered here; neither is forced, because a home
|
||||
// game that doesn't care shouldn't have to argue with its own scoreboard.
|
||||
// One line for however many have walked up, not one each. The bar is docked
|
||||
// over the felt and the felt has already shrunk as far as it will go on a
|
||||
// phone, so every line here is taken out of the ring of seats: measured at
|
||||
// 390x844 with two newcomers, a line apiece put the bar over two fifths of the
|
||||
// bottom seat. They post together or they wait together, which is what happens
|
||||
// at a table anyway when two people sit down at once.
|
||||
if (preview.debtors.length > 0) {
|
||||
const ids = preview.debtors.map(i => this.state.seats[i].id);
|
||||
const posting = ids.every(id => preview.posting.includes(id));
|
||||
const who = listNames(preview.debtors);
|
||||
const each = preview.debtors.length > 1 ? " each" : "";
|
||||
|
||||
const line = document.createElement("p");
|
||||
line.className = "dealPromptLine dealPromptAside dealPromptDebt";
|
||||
|
||||
const text = document.createElement("span");
|
||||
text.textContent = posting
|
||||
? `${who} posting ${Money.format(preview.bigBlind)}${each} to come in.`
|
||||
: `${who} sat down after the blinds — ${preview.debtors.length > 1 ? "free hands" : "a free hand"} unless they post.`;
|
||||
line.appendChild(text);
|
||||
|
||||
line.appendChild(this.button(
|
||||
posting ? "Don't post" : `Post ${Money.format(preview.bigBlind)}${each}`,
|
||||
"dealPromptDebtBtn",
|
||||
() => this.commit(
|
||||
posting ? `${who} waiting for the blind` : `${who} posting to come in`,
|
||||
() => { this.state.postingIn = posting ? [] : ids; })
|
||||
));
|
||||
wrap.appendChild(line);
|
||||
}
|
||||
|
||||
const row = document.createElement("div");
|
||||
row.className = "actionButtons";
|
||||
row.appendChild(this.button("Post blinds & deal", "actionDeal", () => {
|
||||
|
||||
@@ -83,6 +83,11 @@ const Betting = {
|
||||
return {
|
||||
sbIndex, bbIndex, headsUp, manual: !!manual, deadSmallBlind: !!deadSmallBlind,
|
||||
deadButton: !!asDealt.deadButton && !asDealt.seats[buttonIndex].inHand,
|
||||
// Asked of the table as it will be dealt, for the same reason the blinds
|
||||
// are: someone sitting out for having no chips isn't owed a blind, and the
|
||||
// big blind of the hand about to go out isn't either.
|
||||
debtors: HoldemState.blindDebtors(asDealt, bbIndex),
|
||||
posting: (state.postingIn || []).slice(),
|
||||
buttonIndex,
|
||||
buttonMoves: buttonIndex !== state.dealerSeatIndex,
|
||||
satOut,
|
||||
@@ -462,11 +467,30 @@ const Betting = {
|
||||
if (sb > 0 && sbIndex !== null) this.putIn(state, sbIndex, sb);
|
||||
if (bb > 0) this.putIn(state, bbIndex, bb);
|
||||
|
||||
// Anyone the dealer said would post to come in past the blinds. It's a big
|
||||
// blind like any other — it buys them a hand they'd otherwise have to wait for
|
||||
// — so it goes in the middle the same way, before the count below reads it.
|
||||
const posting = Array.isArray(state.postingIn) ? state.postingIn : [];
|
||||
if (bb > 0) {
|
||||
state.seats.forEach((player, index) => {
|
||||
if (index === sbIndex || index === bbIndex) return;
|
||||
if (player.inHand && posting.includes(player.id)) this.putIn(state, index, bb);
|
||||
});
|
||||
}
|
||||
// Deliberately not cleared here. repostBlinds takes every posted chip back and
|
||||
// deals again through this same function, so a post that cleared itself on the
|
||||
// way in would be refunded and never retaken — the dealer moves the button and
|
||||
// somebody's post quietly vanishes. startNextHand is what ends it.
|
||||
|
||||
// What the next hand's rotation is worked out from. Recorded here, where the
|
||||
// blinds are actually posted, because by the time it's needed the seats have
|
||||
// moved on and the answer can no longer be read off the table.
|
||||
state.postedBlinds = { sbIndex, bbIndex };
|
||||
|
||||
// Who got cards. Read next hand to tell a player who has been here all along
|
||||
// from one who has just walked up and had the blinds go past them.
|
||||
state.dealtLastHand = state.seats.filter(p => p.inHand).map(p => p.id);
|
||||
|
||||
state.currentBet = this.round(Math.max(
|
||||
sbIndex === null ? 0 : this.committed(state.seats[sbIndex]),
|
||||
this.committed(state.seats[bbIndex])));
|
||||
|
||||
@@ -86,6 +86,14 @@ const HoldemState = {
|
||||
// seating as it stands, because by then the people it needs to know about
|
||||
// are exactly the ones who have got up and gone.
|
||||
postedBlinds: null,
|
||||
// Player ids that were dealt in the last hand actually dealt. What makes a
|
||||
// seat recognisable as having *just* joined — new to the table, or back
|
||||
// from sitting out — which is the whole question behind owing a blind.
|
||||
dealtLastHand: [],
|
||||
// Ids the dealer has said will buy in past the blinds this hand, by posting
|
||||
// the big blind rather than waiting for it. Cleared every hand: it's a
|
||||
// decision about one deal, not a standing arrangement.
|
||||
postingIn: [],
|
||||
// Set when somebody leaves out of the blinds and the rotation has to hold
|
||||
// to the seats to keep the big blind moving one player at a time. The
|
||||
// button then sits on the chair they vacated, and no small blind is posted.
|
||||
@@ -175,6 +183,12 @@ const HoldemState = {
|
||||
// way, which is what that table was already doing.
|
||||
parsed.deadButton = parsed.deadButton === true;
|
||||
parsed.deadSmallBlind = parsed.deadSmallBlind === true;
|
||||
// An old save has no record of who was dealt last hand. Empty is the
|
||||
// honest answer — it reads as "this table hasn't played yet", so the first
|
||||
// hand after reopening treats nobody as having just walked up, rather than
|
||||
// asking the whole table to post.
|
||||
if (!Array.isArray(parsed.dealtLastHand)) parsed.dealtLastHand = [];
|
||||
if (!Array.isArray(parsed.postingIn)) parsed.postingIn = [];
|
||||
|
||||
// A table saved before dealing and betting were separate has no flag, and
|
||||
// guessing false would show "deal the hand" over a hand already in
|
||||
@@ -460,6 +474,29 @@ const HoldemState = {
|
||||
return { dealerIndex, sbIndex: live[0], bbIndex: live[1], headsUp: false };
|
||||
},
|
||||
|
||||
// Seats about to be dealt a hand they haven't paid for.
|
||||
//
|
||||
// Somebody who walks up and sits down between the button and the big blind has had
|
||||
// the blinds go past them. Dealing them in there is a free hand in late position —
|
||||
// which is exactly what posting is for, and it comes out of everybody else's night
|
||||
// a couple of dollars at a time. At a real table they either post the big blind to
|
||||
// come straight in, or they wait for it to reach them.
|
||||
//
|
||||
// The seat that *is* the big blind this hand isn't owed anything: they're paying.
|
||||
// Neither is anyone at a table that hasn't dealt a hand yet, where everybody is new
|
||||
// and nobody has been skipped.
|
||||
blindDebtors(state, bbIndex) {
|
||||
const played = Array.isArray(state.dealtLastHand) && state.dealtLastHand.length > 0;
|
||||
if (!played) return [];
|
||||
return state.seats
|
||||
.map((player, index) => ({ player, index }))
|
||||
.filter(({ player, index }) =>
|
||||
player.inHand &&
|
||||
index !== bbIndex &&
|
||||
!state.dealtLastHand.includes(player.id))
|
||||
.map(({ index }) => index);
|
||||
},
|
||||
|
||||
// Where the button goes for the next hand, and whether anything is left dead.
|
||||
//
|
||||
// Ordinarily it follows the small blind round — the next player along, which is
|
||||
@@ -518,6 +555,9 @@ const HoldemState = {
|
||||
// the next one would freeze the blinds on two players for the rest of the
|
||||
// night, which is the opposite of what naming them once is for.
|
||||
state.blindOverride = null;
|
||||
// Posting to come in is a decision about one deal. Carrying it forward would
|
||||
// charge somebody an extra big blind every hand for the rest of the night.
|
||||
state.postingIn = [];
|
||||
state.seats.forEach(p => {
|
||||
p.folded = false;
|
||||
p.cards = ["", ""];
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
// Somebody who walks up and sits down after the blinds have gone past them.
|
||||
//
|
||||
// Dealing them straight in is a free hand in late position — which is what posting
|
||||
// exists to stop, and it comes out of everybody else's night a couple of dollars at a
|
||||
// time. The tool used to do it silently. It now says so, and takes the post if the
|
||||
// dealer says to.
|
||||
const test = require("node:test");
|
||||
const { describe } = require("node:test");
|
||||
const assert = require("node:assert");
|
||||
const { HoldemState, Betting, makeTable } = require("./load");
|
||||
|
||||
const NAMES = ["Ann", "Ben", "Cal", "Dee"];
|
||||
const table = (dealerSeatIndex = 0) => {
|
||||
const state = makeTable({ seatCount: 6, seated: [0, 1, 2, 3], stack: 200, dealerSeatIndex });
|
||||
NAMES.forEach((name, i) => { state.seats[i].name = name; });
|
||||
return state;
|
||||
};
|
||||
|
||||
// Eve walks up and takes seat 5 while the table is running.
|
||||
const seatEve = state => {
|
||||
state.seats[4].name = "Eve";
|
||||
state.seats[4].inHand = true;
|
||||
state.seats[4].stack = 200;
|
||||
state.seats[4].buyIns = 200;
|
||||
return 4;
|
||||
};
|
||||
|
||||
const debtors = state => {
|
||||
const { bbIndex } = HoldemState.getBlindSeats(state);
|
||||
return HoldemState.blindDebtors(state, bbIndex).map(i => state.seats[i].name);
|
||||
};
|
||||
|
||||
describe("who is owed a blind", () => {
|
||||
test("nobody, at a table that hasn't dealt a hand yet", () => {
|
||||
// Everyone is new on the first hand. Asking the whole table to post would be
|
||||
// the tool mistaking the start of the night for five people walking up late.
|
||||
const state = table();
|
||||
assert.deepEqual(debtors(state), []);
|
||||
});
|
||||
|
||||
test("nobody, on an ordinary hand where the same people are still sitting there", () => {
|
||||
const state = table();
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
assert.deepEqual(debtors(state), []);
|
||||
});
|
||||
|
||||
test("the player who has just sat down", () => {
|
||||
const state = table();
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
seatEve(state);
|
||||
|
||||
assert.deepEqual(debtors(state), ["Eve"]);
|
||||
});
|
||||
|
||||
test("not once they've been dealt a hand", () => {
|
||||
const state = table();
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
seatEve(state);
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
|
||||
assert.deepEqual(debtors(state), [], "she's one of the regulars now");
|
||||
});
|
||||
|
||||
test("not somebody who is the big blind this hand — they're paying already", () => {
|
||||
const state = table(0); // blinds Ben and Cal
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state); // blinds move to Cal and Dee
|
||||
|
||||
// Dee sits out for a hand and comes straight back into her own big blind.
|
||||
state.seats[3].inHand = false;
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
state.seats[3].inHand = true;
|
||||
|
||||
const { bbIndex } = HoldemState.getBlindSeats(state);
|
||||
assert.ok(!HoldemState.blindDebtors(state, bbIndex).includes(bbIndex),
|
||||
"the big blind is never asked to post on top of their blind");
|
||||
});
|
||||
|
||||
test("somebody back from sitting out is owed one just like a newcomer", () => {
|
||||
const state = table();
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
|
||||
state.seats[3].inHand = false; // Dee stands up for a hand
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
state.seats[3].inHand = true; // and sits back down
|
||||
|
||||
assert.ok(debtors(state).includes("Dee"), "the blinds went past her while she was up");
|
||||
});
|
||||
|
||||
test("a seat sat out for having no chips isn't owed anything", () => {
|
||||
// They aren't being dealt in, so there's no free hand to charge for.
|
||||
const state = table();
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
const eve = seatEve(state);
|
||||
state.seats[eve].stack = 0;
|
||||
|
||||
const preview = Betting.blindPreview(state);
|
||||
assert.ok(!preview.debtors.includes(eve), "she's sitting out until she buys chips");
|
||||
});
|
||||
});
|
||||
|
||||
describe("posting to come in", () => {
|
||||
test("the post goes in the middle and buys a hand", () => {
|
||||
const state = table();
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
const eve = seatEve(state);
|
||||
|
||||
state.postingIn = [state.seats[eve].id];
|
||||
const before = Betting.stackOf(state, state.seats[eve]);
|
||||
Betting.beginHand(state);
|
||||
|
||||
assert.equal(Betting.committed(state.seats[eve]), state.bigBlind, "she's posted a big blind");
|
||||
assert.equal(Betting.stackOf(state, state.seats[eve]), before - state.bigBlind,
|
||||
"out of her own stack, not conjured");
|
||||
assert.equal(state.currentBet, state.bigBlind, "and it doesn't raise the hand");
|
||||
});
|
||||
|
||||
test("not posting leaves her stack alone", () => {
|
||||
const state = table();
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
const eve = seatEve(state);
|
||||
|
||||
const before = Betting.stackOf(state, state.seats[eve]);
|
||||
Betting.beginHand(state);
|
||||
|
||||
assert.equal(Betting.committed(state.seats[eve]), 0);
|
||||
assert.equal(Betting.stackOf(state, state.seats[eve]), before);
|
||||
});
|
||||
|
||||
test("the pot is what the blinds and the post add up to", () => {
|
||||
const state = table();
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
const eve = seatEve(state);
|
||||
|
||||
state.postingIn = [state.seats[eve].id];
|
||||
Betting.beginHand(state);
|
||||
|
||||
const middle = state.seats.reduce((sum, p) => sum + Betting.committed(p), 0);
|
||||
assert.equal(middle, state.smallBlind + state.bigBlind + state.bigBlind);
|
||||
});
|
||||
|
||||
test("it's spent after the hand, not a standing charge", () => {
|
||||
const state = table();
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
const eve = seatEve(state);
|
||||
|
||||
state.postingIn = [state.seats[eve].id];
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
|
||||
assert.deepEqual(state.postingIn, [], "or she'd pay an extra blind every hand all night");
|
||||
Betting.beginHand(state);
|
||||
assert.ok(Betting.committed(state.seats[eve]) === 0 ||
|
||||
state.seats[eve].id === state.seats[HoldemState.getBlindSeats(state).bbIndex]?.id,
|
||||
"she pays nothing extra on the next hand");
|
||||
});
|
||||
|
||||
test("moving the button after a post doesn't lose it", () => {
|
||||
// repostBlinds takes every posted chip back and deals again. A post that
|
||||
// cleared itself on the way in would be refunded and never retaken.
|
||||
const state = table();
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
const eve = seatEve(state);
|
||||
|
||||
state.postingIn = [state.seats[eve].id];
|
||||
Betting.beginHand(state);
|
||||
const chips = () => state.seats.reduce(
|
||||
(sum, p) => sum + Betting.stackOf(state, p) + Betting.handTotal(p), 0);
|
||||
const before = chips();
|
||||
|
||||
state.dealerSeatIndex = 2;
|
||||
Betting.repostBlinds(state);
|
||||
|
||||
assert.equal(Betting.committed(state.seats[eve]), state.bigBlind, "still posted");
|
||||
assert.equal(chips(), before, "and no chips made or lost in the shuffle");
|
||||
});
|
||||
|
||||
test("a post from somebody who isn't owed one is not taken", () => {
|
||||
// Only seats actually being dealt in can post, and only for their own chips.
|
||||
const state = table();
|
||||
state.postingIn = [state.seats[3].id];
|
||||
state.seats[3].inHand = false;
|
||||
Betting.beginHand(state);
|
||||
|
||||
assert.equal(Betting.committed(state.seats[3]), 0, "she isn't even in the hand");
|
||||
});
|
||||
});
|
||||
|
||||
describe("what the dealer is shown", () => {
|
||||
test("the prompt has something to say about it, and something to press", () => {
|
||||
const state = table();
|
||||
Betting.beginHand(state);
|
||||
HoldemState.startNextHand(state);
|
||||
const eve = seatEve(state);
|
||||
|
||||
const preview = Betting.blindPreview(state);
|
||||
assert.deepEqual(preview.debtors, [eve]);
|
||||
assert.deepEqual(preview.posting, [], "not posting until the dealer says so");
|
||||
|
||||
state.postingIn = [state.seats[eve].id];
|
||||
assert.deepEqual(Betting.blindPreview(state).posting, [state.seats[eve].id]);
|
||||
});
|
||||
|
||||
test("an old save reads as a table nobody has just walked up to", () => {
|
||||
const state = table();
|
||||
Betting.beginHand(state);
|
||||
const parsed = JSON.parse(JSON.stringify(state));
|
||||
delete parsed.dealtLastHand;
|
||||
delete parsed.postingIn;
|
||||
|
||||
const store = new Map([[HoldemState.STORAGE_KEY, JSON.stringify(parsed)]]);
|
||||
globalThis.localStorage = {
|
||||
getItem: key => (store.has(key) ? store.get(key) : null),
|
||||
setItem: (key, value) => store.set(key, value),
|
||||
removeItem: key => store.delete(key),
|
||||
};
|
||||
|
||||
const loaded = HoldemState.load();
|
||||
assert.deepEqual(loaded.dealtLastHand, []);
|
||||
assert.deepEqual(loaded.postingIn, []);
|
||||
assert.deepEqual(debtors(loaded), [],
|
||||
"reopening the tab doesn't ask the whole table to post");
|
||||
delete globalThis.localStorage;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user