Skip to content

Do Not Allow Bribe with Insufficient Gold - #11

Closed
jennifer-mortensen wants to merge 0 commit into
benprew:mainfrom
jennifer-mortensen:main
Closed

Do Not Allow Bribe with Insufficient Gold#11
jennifer-mortensen wants to merge 0 commit into
benprew:mainfrom
jennifer-mortensen:main

Conversation

@jennifer-mortensen

Copy link
Copy Markdown

Fixes an issue where the player could bribe enemies with insufficient gold, causing their gold to go negative. The game will now simply do nothing (except play the usual sound effect) when the button is clicked. This mirrors behavior elsewhere in the game.

Comment thread game/screens/duel/duel_ante.go Outdated
}

func (s *DuelAnteScreen) bribe() (screenui.ScreenName, screenui.Screen, error) {
if s.player.Gold < s.enemy.BribeAmount() {

@scalderwood scalderwood Aug 11, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be <=? If I have 100 gold and the bribe is 100, then should I be allowed to exhaust my gold to 0?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No < is correct since it's returning you to the duel ante screen.

@benprew

benprew commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Thanks for your PR @jennifer-mortensen.

I think a better way to handle not enough money is to not display the bribe button at all, so a player is forced to duel the creature. We could have it so it doesn't even draw the Bribe button if the players doesn't have enough money.

See duel_ante.go#198

@benprew

benprew commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Actually my suggestion leads to a bug where the button is invisible but could still be clicked!

I think a better solution would be a slightly more involved change:

  • add a new canBribe() function in duel_ante.go that returns true/false if an enemy can be bribed
  • make the duelBtn a regular struct instead of pointer to a struct
  • only populate the duelBtn if the canBribe() is true
  • wrap the Key2 check in a canBribe() check
  • make sure button.go#Draw() doesn't draw a null image (can return early if imgToDraw is null)

This works because all values in Go have a "default value". This means you can call functions on an empty struct. If it was a pointer and you tried to call IsClicked() it would fail on a memory violation.

@benprew

benprew commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Also some enemies can't be bribed, and have a BribeAmount of 0, we should remove the bribe button in that case too.

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.

3 participants