Don't calculate user_coins(+/-)coin_bet twice

This commit is contained in:
jesopo 2018-10-11 14:13:37 +01:00
parent a9202a6abf
commit 3d2acc2f61

View file

@ -167,21 +167,21 @@ class Module(object):
win = side_name == chosen_side win = side_name == chosen_side
if win: if win:
event["user"].set_setting("coins", str(user_coins+coin_bet)) new_coins = str(user_coins+coin_bet)
event["user"].set_setting("coins", new_coins)
event["stdout"].write( event["stdout"].write(
"%s flips %s and wins %s coin%s! (new total: %s)" % ( "%s flips %s and wins %s coin%s! (new total: %s)" % (
event["user"].nickname, side_name, coin_bet_str, event["user"].nickname, side_name, coin_bet_str,
"" if coin_bet == 1 else "s", "" if coin_bet == 1 else "s", new_coins
user_coins+coin_bet
) )
) )
else: else:
event["user"].set_setting("coins", str(user_coins-coin_bet)) new_coins = str(user_coins-coin_bet)
event["user"].set_setting("coins", new_coins)
event["stdout"].write( event["stdout"].write(
"%s flips %s and loses %s coin%s! (new total: %s)" % ( "%s flips %s and loses %s coin%s! (new total: %s)" % (
event["user"].nickname, side_name, coin_bet_str, event["user"].nickname, side_name, coin_bet_str,
"" if coin_bet == 1 else "s", "" if coin_bet == 1 else "s", new_coins
user_coins-coin_bet
) )
) )