Post the blinds to the players rather than to the chairs #37

Closed
jheaps wants to merge 0 commits from feature/casino-holdem-heads-up into master
Owner

This is a rules bug, not polish. Blinds were assigned by seat offset — always button+1 and button+2 — which is only correct when everyone is dealt in and there are three or more of them.

Touches only betting.js and state.js, so it does not overlap #33–#36.

What was wrong

situation before correct
Heads-up button posted the big blind, acted second pre-flop button posts the small blind, acts first
Heads-up at a 9-handed table (two players dealt in) no blinds posted at all, badges on empty seats blinds to the two players
Seats left of the button sitting out no blinds posted at all blinds to the next players who are in

The heads-up case is the end of every home tournament, dealt wrong. The other two are worse: the offsets dont care whether anyone is sitting in those chairs, so the blinds landed on empty seats and no money went in the middle.

The fix

Blinds now walk the players actually dealt in, starting from the button, with heads-up as its own case: the button is the small blind and acts first pre-flop, and the big blind acts first afterwards. The badges come from the same function as the money, so what the table shows and what gets posted cannot disagree.

Validation (Playwright, headed)

Six table shapes, before and after, checking blinds, badges, and both pre-flop and post-flop first-to-act:

  • heads-up two seats · heads-up at a nine-handed table · button parked on an empty seat · three-handed · six seats with gaps · one player only (posts nothing, asks nobody to act)
  • All six now correct. The button-on-an-empty-seat case surfaced a follow-on — post-flop order was still taken from the button rather than the big blind — which is fixed in the same change.
  • The engines core guarantee still holds: 400 randomised hands, 2–8 seats, random sit-outs and stacks — chips in stacks plus chips in the middle always equal what everyone started with, no negative stacks, every hand terminates.
  • A real heads-up hand through the UI: the button seat carries both the dealer button and the SB badge, posts $1 against the big blinds $2, and the action starts on it. No console errors.
**This is a rules bug, not polish.** Blinds were assigned by seat offset — always button+1 and button+2 — which is only correct when everyone is dealt in and there are three or more of them. Touches only `betting.js` and `state.js`, so it does not overlap #33–#36. ## What was wrong | situation | before | correct | |---|---|---| | **Heads-up** | button posted the **big** blind, acted **second** pre-flop | button posts the **small** blind, acts **first** | | **Heads-up at a 9-handed table** (two players dealt in) | **no blinds posted at all**, badges on empty seats | blinds to the two players | | **Seats left of the button sitting out** | **no blinds posted at all** | blinds to the next players who are in | The heads-up case is the end of every home tournament, dealt wrong. The other two are worse: the offsets dont care whether anyone is sitting in those chairs, so the blinds landed on empty seats and no money went in the middle. ## The fix Blinds now walk the players actually dealt in, starting from the button, with heads-up as its own case: the button is the small blind and acts first pre-flop, and the big blind acts first afterwards. **The badges come from the same function as the money**, so what the table shows and what gets posted cannot disagree. ## Validation (Playwright, headed) Six table shapes, before and after, checking blinds, badges, and both pre-flop and post-flop first-to-act: - heads-up two seats · heads-up at a nine-handed table · **button parked on an empty seat** · three-handed · six seats with gaps · one player only (posts nothing, asks nobody to act) - All six now correct. The button-on-an-empty-seat case surfaced a follow-on — post-flop order was still taken from the button rather than the big blind — which is fixed in the same change. - **The engines core guarantee still holds**: 400 randomised hands, 2–8 seats, random sit-outs and stacks — chips in stacks plus chips in the middle always equal what everyone started with, no negative stacks, every hand terminates. - A real heads-up hand through the UI: the button seat carries **both the dealer button and the SB badge**, posts $1 against the big blinds $2, and the action starts on it. No console errors.
jheaps added 1 commit 2026-09-01 01:22:36 -06:00
Blinds were assigned by seat offset — always button+1 and button+2 — which is
only right when everyone is dealt in and there are three or more of them.

Heads-up it had the blinds backwards. The button posted the big blind and acted
second before the flop; the rule is the opposite on both counts. That's the end
of every home tournament, dealt wrong.

Worse, the offsets don't care whether anyone is sitting in those chairs. With
two players at a nine-handed table, or with the seats left of the button sitting
out, the blinds landed on empty seats and simply weren't posted — no money in
the middle, and SB/BB badges pointing at nobody.

Blinds now walk the players who are actually dealt in, starting from the button,
with heads-up as its own case: the button is the small blind, acts first
pre-flop, and the big blind acts first afterwards. The badges come from the same
function as the money, so what the table shows and what gets posted can't
disagree.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015bnp7xKUPFFSpwkYNFaPgb
jheaps closed this pull request 2026-09-01 02:42:17 -06:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jheaps/JoshHeaps.Net#37