Skip to content

Fix player being informed they won $0 when winning dice rolls at the Tavern#37

Merged
dmccoystephenson merged 2 commits intomainfrom
copilot/fix-7a41e107-d705-44d8-9b09-eff13cb14b98
Oct 13, 2025
Merged

Fix player being informed they won $0 when winning dice rolls at the Tavern#37
dmccoystephenson merged 2 commits intomainfrom
copilot/fix-7a41e107-d705-44d8-9b09-eff13cb14b98

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 2, 2025

Problem

When players won a dice roll at the Tavern's gambling game, they were incorrectly told they won $0 instead of their actual bet amount. This happened because the code reset self.currentBet to 0 before using it in the win message.

Before the fix:

The dice rolled a 3! You won $0! Care to try again? Current Bet: $0

After the fix:

The dice rolled a 3! You won $50! Care to try again? Current Bet: $0

Solution

The fix is minimal and surgical - store the bet amount in a winAmount variable before resetting self.currentBet to 0. This ensures the correct amount is displayed to the player.

Changes in src/location/tavern.py:

if input == self.diceThrow:
    winAmount = self.currentBet  # Store bet amount before resetting
    self.player.money += self.currentBet
    self.stats.totalMoneyMade += self.currentBet
    self.currentBet = 0
    self.currentPrompt.text = (
        "The dice rolled a %d! You won $%d! Care to try again? Current Bet: $%d"
        % (self.diceThrow, winAmount, self.currentBet)  # Use stored amount
    )

Testing

Added test_gamble_win_shows_correct_amount() to validate the fix. All 63 tests pass successfully.

Additional Changes

Minor code formatting changes from running black and autoflake to maintain code style consistency.

Original prompt

This section details on the original issue you should resolve

<issue_title>Fix player being informed they won $0 when winning dice rolls at the Tavern.</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #13

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: dmccoystephenson <21204351+dmccoystephenson@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix player being informed they won $0 when winning dice rolls at the Tavern. Fix player being informed they won $0 when winning dice rolls at the Tavern Oct 2, 2025
Copilot AI requested a review from dmccoystephenson October 2, 2025 06:21
@dmccoystephenson dmccoystephenson marked this pull request as ready for review October 2, 2025 06:25
@dmccoystephenson dmccoystephenson merged commit 5f76162 into main Oct 13, 2025
@dmccoystephenson dmccoystephenson deleted the copilot/fix-7a41e107-d705-44d8-9b09-eff13cb14b98 branch October 13, 2025 05:21
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.

Fix player being informed they won $0 when winning dice rolls at the Tavern.

2 participants