[NEWIMPORT] Insert winnings column into HandsPlayers

This commit is contained in:
Worros 2009-11-06 18:39:59 +08:00
parent bea6bf2d6b
commit 5aef7b6054
2 changed files with 22 additions and 5 deletions

View File

@ -1393,6 +1393,7 @@ class Database:
pids[p], pids[p],
pdata[p]['startCash'], pdata[p]['startCash'],
pdata[p]['seatNo'], pdata[p]['seatNo'],
pdata[p]['winnings'],
pdata[p]['street0Aggr'], pdata[p]['street0Aggr'],
pdata[p]['street1Aggr'], pdata[p]['street1Aggr'],
pdata[p]['street2Aggr'], pdata[p]['street2Aggr'],
@ -1405,6 +1406,7 @@ class Database:
playerId, playerId,
startCash, startCash,
seatNo, seatNo,
winnings,
street0Aggr, street0Aggr,
street1Aggr, street1Aggr,
street2Aggr, street2Aggr,
@ -1413,7 +1415,7 @@ class Database:
) )
VALUES ( VALUES (
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s %s, %s, %s, %s, %s
)""" )"""
# position, # position,
@ -1423,7 +1425,6 @@ class Database:
# card3, # card3,
# card4, # card4,
# startCards, # startCards,
# winnings,
# rake, # rake,
# totalProfit, # totalProfit,
# street0VPI, # street0VPI,

View File

@ -18,6 +18,13 @@
#fpdb modules #fpdb modules
import Card import Card
DEBUG = True
if DEBUG:
import pprint
pp = pprint.PrettyPrinter(indent=4)
class DerivedStats(): class DerivedStats():
def __init__(self, hand): def __init__(self, hand):
self.hand = hand self.hand = hand
@ -30,13 +37,17 @@ class DerivedStats():
for player in hand.players: for player in hand.players:
self.handsplayers[player[1]] = {} self.handsplayers[player[1]] = {}
#Init vars that may not be used, but still need to be inserted. #Init vars that may not be used, but still need to be inserted.
self.handsplayers[player[1]]['winnings'] = 0
self.handsplayers[player[1]]['street4Aggr'] = False self.handsplayers[player[1]]['street4Aggr'] = False
self.assembleHands(self.hand) self.assembleHands(self.hand)
self.assembleHandsPlayers(self.hand) self.assembleHandsPlayers(self.hand)
print "hands =", self.hands if DEBUG:
print "handsplayers =", self.handsplayers print "Hands:"
pp.pprint(self.hands)
print "HandsPlayers:"
pp.pprint(self.handsplayers)
def getHands(self): def getHands(self):
return self.hands return self.hands
@ -90,6 +101,11 @@ class DerivedStats():
self.handsplayers[player[1]]['seatNo'] = player[0] self.handsplayers[player[1]]['seatNo'] = player[0]
self.handsplayers[player[1]]['startCash'] = player[2] self.handsplayers[player[1]]['startCash'] = player[2]
# Winnings is a non-negative value of money collected from the pot, which already includes the
# rake taken out. hand.collectees is Decimal, database requires cents
for player in hand.collectees:
self.handsplayers[player]['winnings'] = int(100 * hand.collectees[player])
for i, street in enumerate(hand.actionStreets[1:]): for i, street in enumerate(hand.actionStreets[1:]):
self.aggr(self.hand, i) self.aggr(self.hand, i)