Fix tavern money prompts truncating cents - #124
Merged
Conversation
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>
Member
Author
|
Self-review rubric:
Triage note: the repo's only open issue (#122) is a stale-looking |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
player.moneycan hold a fractional value after a bank withdrawal (bank.pyalready parses withdraw/deposit amounts withfloat(input())), but three "Change Bet" prompts intavern.pyformattedself.player.moneywith%d, silently dropping the cents.gamble()'s "Change Bet" branch andchangeBet()'s two outcome branches) to%.2f, matching the conventionbank.pyalready uses for the same field.currentBet/winAmount/diceThrowdisplays were left as%d— those are always whole dollars by design (changeBetdoesself.amount = int(amount)), so no change needed there.Test plan
test_changeBet_invalid_input_shows_cents,test_changeBet_insufficient_money_shows_cents, andtest_gamble_change_bet_prompt_shows_centstotests/location/test_tavern.py, each asserting the generated prompt text retains cents (e.g.$42.70).tavern.pyfix, confirmed all three new tests fail against the old%dcode, then restored the fix and confirmed they pass.python3 -m compileall -q src testsSDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy python3 -m pytest)Triage notes