Do Not Allow Bribe with Insufficient Gold - #11
Conversation
| } | ||
|
|
||
| func (s *DuelAnteScreen) bribe() (screenui.ScreenName, screenui.Screen, error) { | ||
| if s.player.Gold < s.enemy.BribeAmount() { |
There was a problem hiding this comment.
Should this be <=? If I have 100 gold and the bribe is 100, then should I be allowed to exhaust my gold to 0?
There was a problem hiding this comment.
No < is correct since it's returning you to the duel ante screen.
|
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 |
|
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:
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. |
|
Also some enemies can't be bribed, and have a BribeAmount of 0, we should remove the bribe button in that case too. |
63776c8 to
b679998
Compare
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.