From 45f47bc3fcb01cb049cfe83879ce1b57cdf1ecdd Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 25 Jan 2019 16:04:10 +0000 Subject: Prevent users partaking in the lottery if doing so would put their coin total below the coin redemption amount (coins.py) --- modules/coins.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'modules') diff --git a/modules/coins.py b/modules/coins.py index b02c32fc..b805831c 100644 --- a/modules/coins.py +++ b/modules/coins.py @@ -469,9 +469,17 @@ class Module(ModuleManager.BaseModule): user_coins = self._get_user_coins(event["user"]) coin_amount = decimal.Decimal(LOTTERY_BUYIN)*amount + new_user_coins = user_coins-coin_amount + redeem_amount = self._redeem_amount(event["server"]) + if coin_amount > user_coins: raise utils.EventError("%s: You don't have enough coins" % event["user"].nickname) + elif new_user_coins < redeem_amount: + raise utils.EventError( + "%s: you can't play the lottery if it puts your total coins " + "below %s" % (event["user"].nickname, + self._coin_str(redeem_amount))) self._take(event["server"], event["user"], coin_amount) -- cgit v1.3.1-10-gc9f91