Skip to content

Fix tavern money prompts truncating cents - #124

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/tavern-money-cents-display
Jul 27, 2026
Merged

Fix tavern money prompts truncating cents#124
dmccoystephenson merged 1 commit into
mainfrom
feature/tavern-money-cents-display

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • player.money can hold a fractional value after a bank withdrawal (bank.py already parses withdraw/deposit amounts with float(input())), but three "Change Bet" prompts in tavern.py formatted self.player.money with %d, silently dropping the cents.
  • Switched those three prompts (in gamble()'s "Change Bet" branch and changeBet()'s two outcome branches) to %.2f, matching the convention bank.py already uses for the same field.
  • currentBet/winAmount/diceThrow displays were left as %d — those are always whole dollars by design (changeBet does self.amount = int(amount)), so no change needed there.

Test plan

  • Added test_changeBet_invalid_input_shows_cents, test_changeBet_insufficient_money_shows_cents, and test_gamble_change_bet_prompt_shows_cents to tests/location/test_tavern.py, each asserting the generated prompt text retains cents (e.g. $42.70).
  • Verified regression coverage: stashed the tavern.py fix, confirmed all three new tests fail against the old %d code, then restored the fix and confirmed they pass.
  • python3 -m compileall -q src tests
  • Full suite: 374 passed (SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy python3 -m pytest)

Triage notes

player.money can carry cents after a fractional bank withdrawal
(bank.py already parses withdraw/deposit amounts as float), but the
tavern's "Change Bet" prompts formatted it with %d, silently dropping
the fractional part. Switch those three prompts to %.2f, matching the
convention already used for player.money in bank.py.

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

Copy link
Copy Markdown
Member Author

Self-review rubric:

  • Scope: PASS — only src/location/tavern.py (the three %d -> %.2f fixes) and its test file are touched; no unrelated formatting/renames.
  • Tests-new: PASS — each new test exercises a real generation path (gamble()'s change-bet branch, changeBet()'s two outcome branches), not a hand-crafted literal string.
  • Tests-fix: PASS — stashed src/location/tavern.py, ran the 3 new tests, confirmed all 3 FAIL ($42 instead of $42.70, etc.), popped the stash, confirmed all 3 PASS.
  • Sibling structure: N/A — no new files.
  • Sibling renames: N/A — no renamed identifiers.
  • Docs: PASS — this is a display-format fix only, no persisted field/README/schema/PLANNING content changed.
  • Issue resolution: N/A — no tracked issue closed by this PR (see triage note below).
  • CI: PASS — test check green on the PR head (https://github.com/Stephenson-Software/FishE/actions/runs/30227748780).
  • Schema-sync: N/A — no persisted field touched.
  • Money-format: PASS — this PR's whole purpose is fixing a money value (player.money) displayed with %d; now %.2f, matching bank.py's existing convention for the same field. Verified the two %d fields left alone (currentBet, winAmount, diceThrow) are always ints by construction (changeBet does self.amount = int(amount)).
  • Deterministic-tests: PASS — no new test touches random.
  • Headless-pygame: N/A — no pygame code path touched.
  • camelCase: PASS — no new identifiers introduced.

Triage note: the repo's only open issue (#122) is a stale-looking PLANNING.md GOALS entry that both the issue body and a follow-up comment concluded is not currently reproducible in code — but deliberately left open because only the repo owner can say whether the original symptom is something the code checks wouldn't catch. Not picked for this cycle; this PR fixes an independent bug found during the triage sweep instead (no tracking issue existed for it).

@dmccoystephenson
dmccoystephenson merged commit 2cec09b into main Jul 27, 2026
1 check passed
@dmccoystephenson
dmccoystephenson deleted the feature/tavern-money-cents-display branch July 27, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant