aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jesopo2019-01-25 16:04:10 +0000
committerGravatar jesopo2019-01-25 16:04:10 +0000
commit45f47bc3fcb01cb049cfe83879ce1b57cdf1ecdd (patch)
tree50c26611265dcac5235ba7ba30f967bc1cb9d292
parentDelete nickname_aliases.py as it's been disabled for a very long time due to (diff)
signature
Prevent users partaking in the lottery if doing so would put their coin total
below the coin redemption amount (coins.py)
-rw-r--r--modules/coins.py8
1 files changed, 8 insertions, 0 deletions
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)