Support unit-based bets (1k/1m/1b) in modules/coins.py

This commit is contained in:
jesopo 2018-10-12 11:19:41 +01:00
parent a810d273d1
commit f096bddff4

View file

@ -147,6 +147,7 @@ class Module(object):
event["stderr"].write("You have no coins to bet") event["stderr"].write("You have no coins to bet")
return return
coin_bet = utils.parse_number(coin_bet)
match = REGEX_FLOAT.match(coin_bet) match = REGEX_FLOAT.match(coin_bet)
if not match or round(decimal.Decimal(coin_bet), 2) <= DECIMAL_ZERO: if not match or round(decimal.Decimal(coin_bet), 2) <= DECIMAL_ZERO:
event["stderr"].write("Please provide a number of coins to bet") event["stderr"].write("Please provide a number of coins to bet")
@ -275,6 +276,7 @@ class Module(object):
return return
for i, bet_amount in enumerate(bet_amounts): for i, bet_amount in enumerate(bet_amounts):
bet_amount = utils.parse_number(bet_amount)
match = REGEX_FLOAT.match(bet_amount) match = REGEX_FLOAT.match(bet_amount)
if not match or round(decimal.Decimal(bet_amount), 2 if not match or round(decimal.Decimal(bet_amount), 2
) <= DECIMAL_ZERO: ) <= DECIMAL_ZERO: