Buying chips puts you back in the game #67

Closed
jheaps wants to merge 1 commits from fix/casino-holdem-buyin-deals-in into fix/casino-holdem-bet-vs-raise
Owner

Handing over cash and being dealt in are one event at a real table. Here they were two, and the second one was easy to miss. Stacked on #66.

#65 deals a busted player around until they rebuy. So the dealer takes their money, taps Add chips, and:

Ben:  inHand false -> false     stack 0 -> 100     buyIns 100 -> 200
toast: "Ben added $100."

He has chips, he is not in the game, and nothing on screen says so. He gets skipped hand after hand until somebody notices and finds "Deal in" in the seat menu.

Now the buy-in does both, and says which:

Toast Result
Mid-hand "Ben added $100 — in from the next hand." inHand true, folded true
Between hands "Ben added $100 — dealt in." inHand true, folded false

Folding him for the hand in progress is the rule "Deal in" already follows — you can't buy into a pot you haven't been paying for — so the two doors into the game behave the same way. It's one undoable step: undo takes back the chips, the cash record and the seat.

Not for a seat that was sat out while holding chips. That's a dealer who sat someone out on purpose and is topping them up, and dealing them back in would be the tool guessing at something it wasn't told. The test reads the seat's own recorded stack rather than stackOf(), which substitutes the table's starting stack and would make a seat with nothing recorded look like it was holding chips.

busted, sat out          -> back in
new chair, no stack yet  -> in
sat out holding $100     -> stays out
already in the hand      -> nothing to do, including an all-in at zero chips

Validation

8 tests (214 total). Driven through Playwright: the rebuy, the toast, the next hand actually dealing him in (4 players, live 4), and undo putting all three fields back. Layout and contrast clean at six viewports with the sheet closed.

(Running the layout audit with the add-chips sheet open reports 13 covered elements at every size — identical counts across every viewport, because it's the modal overlay doing exactly what a modal is for. The audit isn't modal-aware; that's my instrument, not the page.)

Found on the way, deliberately not fixed

Buying in on a seat with no stack of its own credits the table's starting stack plus the buy-in. A new player handed $100 on a table with a $100 default ends up with $200 of chips against $100 of recorded cash.

I'm leaving it because the right answer is genuinely unclear and it isn't mine to pick. A blank stack means "no chips recorded" to the bank check, which counts it as zero, and "the table's starting stack" to the betting code and the felt, which show it as $100. Both are defensible for their own job, and which one a buy-in should follow decides whether a casual dealer who never types stacks gets $200 or $100 after a rebuy. Say the word and I'll make it either.

Handing over cash and being dealt in are one event at a real table. Here they were two, and the second one was easy to miss. Stacked on #66. #65 deals a busted player around until they rebuy. So the dealer takes their money, taps **Add chips**, and: ``` Ben: inHand false -> false stack 0 -> 100 buyIns 100 -> 200 toast: "Ben added $100." ``` He has chips, he is not in the game, and nothing on screen says so. He gets skipped hand after hand until somebody notices and finds "Deal in" in the seat menu. Now the buy-in does both, and says which: | | Toast | Result | | --- | --- | --- | | Mid-hand | "Ben added $100 — **in from the next hand**." | inHand true, folded true | | Between hands | "Ben added $100 — **dealt in**." | inHand true, folded false | Folding him for the hand in progress is the rule "Deal in" already follows — you can't buy into a pot you haven't been paying for — so the two doors into the game behave the same way. It's **one undoable step**: undo takes back the chips, the cash record and the seat. **Not** for a seat that was sat out while *holding* chips. That's a dealer who sat someone out on purpose and is topping them up, and dealing them back in would be the tool guessing at something it wasn't told. The test reads the seat's own recorded stack rather than `stackOf()`, which substitutes the table's starting stack and would make a seat with nothing recorded look like it was holding chips. ``` busted, sat out -> back in new chair, no stack yet -> in sat out holding $100 -> stays out already in the hand -> nothing to do, including an all-in at zero chips ``` ## Validation **8 tests (214 total)**. Driven through Playwright: the rebuy, the toast, the next hand actually dealing him in (4 players, live 4), and undo putting all three fields back. Layout and contrast clean at six viewports with the sheet closed. (Running the layout audit with the add-chips sheet *open* reports 13 covered elements at every size — identical counts across every viewport, because it's the modal overlay doing exactly what a modal is for. The audit isn't modal-aware; that's my instrument, not the page.) ## Found on the way, deliberately not fixed Buying in on a seat with **no stack of its own** credits the table's starting stack *plus* the buy-in. A new player handed $100 on a table with a $100 default ends up with **$200 of chips against $100 of recorded cash**. I'm leaving it because the right answer is genuinely unclear and it isn't mine to pick. A blank stack means "no chips recorded" to the bank check, which counts it as zero, and "the table's starting stack" to the betting code and the felt, which show it as $100. Both are defensible for their own job, and which one a buy-in should follow decides whether a casual dealer who never types stacks gets $200 or $100 after a rebuy. Say the word and I'll make it either.
jheaps added 1 commit 2026-09-01 13:40:22 -06:00
Handing over cash and being dealt in are one event at a real table. Here they were
two, and the second one was easy to miss.

Last change deals a busted player around until they rebuy. So the dealer takes their
money, taps Add chips, and:

  Ben:  inHand false -> false     stack 0 -> 100     buyIns 100 -> 200
  toast: "Ben added $100."

He has chips, he is not in the game, and nothing on screen says so. He gets skipped
hand after hand until somebody notices and finds "Deal in" in the seat menu.

Now the buy-in does both, and says which:

  mid-hand:      "Ben added $100 - in from the next hand."   inHand true, folded true
  between hands: "Ben added $100 - dealt in."                inHand true, folded false

Folding him for the hand in progress is the rule "Deal in" already follows -- you
can't buy into a pot you have not been paying for -- so the two doors into the game
behave the same way. It is one undoable step: undo takes back the chips, the cash
record and the seat.

Not for a seat that was sat out while holding chips. That is a dealer who sat someone
out on purpose and is topping them up, and dealing them back in would be the tool
guessing at something it was not told. The test reads the seat's own recorded stack
rather than stackOf(), which substitutes the table's starting stack and would make a
seat with nothing recorded look like it was holding chips.

  busted, sat out          -> back in
  new chair, no stack yet  -> in
  sat out holding $100     -> stays out
  already in the hand      -> nothing to do, including an all-in at zero chips

8 tests (214 total).

Driven through the UI: the rebuy, the toast, the next hand actually dealing him in
(4 players, live 4), and undo putting all three fields back.

Found on the way, not fixed here

Buying in on a seat with no stack of its own credits the table's starting stack *plus*
the buy-in. A new player handed $100 on a table with a $100 default ends up with $200
of chips against $100 of recorded cash.

I am leaving it because the right answer is genuinely unclear and it is not mine to
pick. A blank stack means "no chips recorded" to the bank check, which counts it as
zero, and "the table's starting stack" to the betting code and the felt, which show
it as $100. Both are defensible for their own job, and which one a buy-in should
follow decides whether a casual dealer who never types stacks gets $200 or $100 after
a rebuy. Worth saying out loud rather than quietly picking one.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_015bnp7xKUPFFSpwkYNFaPgb
jheaps closed this pull request 2026-09-02 09:57:49 -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#67