bookie: ensure a winner player never gets less than his/her bet

This could conceivably happen in a game where one side bets a lot
more than the other side.
This commit is contained in:
moneromooo 2015-01-27 22:13:11 +00:00
parent e2787cc2b3
commit 00b742445e

View file

@ -390,6 +390,8 @@ def Result(link,cmd):
ounits = long(redis_hget(tname,bettor+":units")) ounits = long(redis_hget(tname,bettor+":units"))
if o == outcome: if o == outcome:
owinunits = long(total_units_bet * (1-config.bookie_fee) * ounits / total_units_bet_by_winners) owinunits = long(total_units_bet * (1-config.bookie_fee) * ounits / total_units_bet_by_winners)
if owinunits<ounits:
owinunits=units
resultmsg.append("%s wins %s" % (NickFromIdentity(bettor), AmountToString(owinunits))) resultmsg.append("%s wins %s" % (NickFromIdentity(bettor), AmountToString(owinunits)))
p.hincrby("balances",bettor,owinunits) p.hincrby("balances",bettor,owinunits)
else: else: