Skip to content

Reject sub-$1 tavern bets and fix stale gambling payout dialogue - #128

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/tavern-bet-validation-and-tests
Jul 27, 2026
Merged

Reject sub-$1 tavern bets and fix stale gambling payout dialogue#128
dmccoystephenson merged 1 commit into
mainfrom
feature/tavern-bet-validation-and-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • Tavern.changeBet only checked affordability, so a negative bet amount passed Player.canAfford (money >= negative is always true) and set currentBet to a negative number. gamble()'s currentBet > 0 guard then silently treated this as "no bet", directly contradicting the "Current Bet: $-100" prompt the game had just shown. Now rejects any amount below $1 with an explicit message.
  • Old Tom's tavern dialogue still said gambling would "double your money", but the dice pay out DICE_WIN_MULTIPLIER (5x). Interpolated the constant so the dialogue can't drift from the payout again.
  • Adds real-loop regression tests driving Tavern.gamble() itself (loss path, no-bet-placed path) and Tavern.getDrunk()'s money-loss branch, plus regression tests for both fixes above.

Test plan

  • python3 -m compileall -q src
  • Full suite green: 380 passed (SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy python3 -m pytest)
  • Confirmed each new/changed test fails without its corresponding fix (stashed src/location/tavern.py, reran tests/location/test_tavern.py, saw the new bet-rejection and dialogue tests fail, then restored and confirmed pass)

Closes #127
Closes #126

Tavern.changeBet only checked affordability, so a negative bet passed
Player.canAfford (money >= negative amount is always true) and set
currentBet to a negative number. gamble()'s `currentBet > 0` guard then
silently treated it as no bet, contradicting the confirmed-bet prompt.
Also interpolates DICE_WIN_MULTIPLIER into Old Tom's dialogue, which
still described the old even-money payout instead of the actual 5x.

Adds real-loop regression tests for gamble()'s loss and no-bet-placed
paths and for getDrunk()'s money-loss branch.

Closes #127
Closes #126

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric:

Note: at the start of this cycle the working tree had uncommitted, never-committed changes to tests/location/test_tavern.py (3 new tests) left over from an interrupted prior session. Two of them (test_gamble_loss_via_real_loop, test_gamble_no_bet_placed) had a latent bug — a mock side_effect that checked an accumulator list's truthiness as a "first call" flag without ever setting it on that branch, so the mocked showOptions returned the same input forever. Running them caused Tavern.gamble()'s while True loop to spin permanently, and the pytest process was observed consuming >19GB of RAM before being killed. Fixed by replacing the flawed sentinel with an explicit call counter in both tests before including them in this PR. Investigating and fixing this seemed safer than either silently discarding untested WIP or shipping it as-is.

@dmccoystephenson
dmccoystephenson merged commit 57636b9 into main Jul 27, 2026
1 check passed
@dmccoystephenson
dmccoystephenson deleted the feature/tavern-bet-validation-and-tests branch July 27, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant