Add the ability for games to earmark part of the house balance

This allows games to take bets from players (so the players aren't
in control of them anymore) while still not counting these as part
of the house balance (and thus the house can't spend them on some
other payment).
This commit is contained in:
moneromooo 2015-01-21 14:27:25 +00:00
parent 69d0f89549
commit 19e8aa1b1c

View file

@ -231,6 +231,13 @@ def RetrieveHouseBalance():
house_balance = house_balance - ib
user_balances+=ib
earmarked_balances=0
earmarked = redis_hgetall("earmarked")
for e in earmarked:
eb = long(redis_hget("earmarked", e))
house_balance = house_balance - eb
earmarked_balances+=eb
rbal=long(redis_get('reserve_balance') or 0)
if rbal:
house_balance = house_balance - rbal
@ -238,7 +245,7 @@ def RetrieveHouseBalance():
if house_balance < 0:
raise RuntimeError('Negative house balance')
return
log_info('RetrieveHouseBalance: unlocked %s, users %s, reserve %s, house %s' % (AmountToString(unlocked_balance), AmountToString(user_balances), AmountToString(rbal), AmountToString(house_balance)))
log_info('RetrieveHouseBalance: unlocked %s, users %s, earmarked %s, reserve %s, house %s' % (AmountToString(unlocked_balance), AmountToString(user_balances), AmountToString(earmarked_balances), AmountToString(rbal), AmountToString(house_balance)))
return house_balance
def GetHouseBalance(link,cmd):