Merge branch 'master' of git://git.assembla.com/fpdboz
Conflicts: pyfpdb/Hud.py
This commit is contained in:
commit
0dd46d38ac
|
@ -296,11 +296,8 @@ Add a raise on [street] by [player] to [amountTo]
|
|||
if self.totalpot is None:
|
||||
self.totalpot = 0
|
||||
|
||||
# player names:
|
||||
# print [x[1] for x in self.players]
|
||||
for player in [x[1] for x in self.players]:
|
||||
for street in self.streetList:
|
||||
#print street, self.bets[street][player]
|
||||
self.totalpot += reduce(operator.add, self.bets[street][player], 0)
|
||||
|
||||
print "DEBUG conventional totalpot:", self.totalpot
|
||||
|
@ -308,7 +305,13 @@ Add a raise on [street] by [player] to [amountTo]
|
|||
|
||||
self.totalpot = 0
|
||||
|
||||
for street in self.actions:
|
||||
players_who_act_preflop = set([x[0] for x in self.actions['PREFLOP']])
|
||||
self.pot = Pot(players_who_act_preflop)
|
||||
|
||||
|
||||
# this can now be pruned substantially if Pot is working.
|
||||
#for street in self.actions:
|
||||
for street in [x for x in self.streetList if x in self.actions]:
|
||||
uncalled = 0
|
||||
calls = [0]
|
||||
for act in self.actions[street]:
|
||||
|
@ -317,18 +320,30 @@ Add a raise on [street] by [player] to [amountTo]
|
|||
uncalled = Decimal(act[2]) # only the last bet or raise can be uncalled
|
||||
calls = [0]
|
||||
print "uncalled: ", uncalled
|
||||
|
||||
self.pot.addMoney(act[0], Decimal(act[2]))
|
||||
|
||||
elif act[1] == 'raises': # [name, 'raises', amountby, amountto, amountcalled]
|
||||
print "calls %s and raises %s to %s" % (act[4],act[2],act[3])
|
||||
self.totalpot += Decimal(act[2]) + Decimal(act[4])
|
||||
calls = [0]
|
||||
uncalled = Decimal(act[2])
|
||||
print "uncalled: ", uncalled
|
||||
|
||||
self.pot.addMoney(act[0], Decimal(act[2])+Decimal(act[4]))
|
||||
|
||||
elif act[1] == 'calls': # [name, 'calls', amount]
|
||||
self.totalpot += Decimal(act[2])
|
||||
calls = calls + [Decimal(act[2])]
|
||||
print "calls:", calls
|
||||
|
||||
self.pot.addMoney(act[0], Decimal(act[2]))
|
||||
|
||||
elif act[1] == 'posts':
|
||||
self.totalpot += Decimal(act[3])
|
||||
|
||||
self.pot.addMoney(act[0], Decimal(act[3]))
|
||||
|
||||
if act[2] == 'big blind':
|
||||
# the bb gets called by out-of-blinds posts; but sb+bb only calls bb
|
||||
if uncalled == Decimal(act[3]): # a bb is already posted
|
||||
|
@ -343,14 +358,15 @@ Add a raise on [street] by [player] to [amountTo]
|
|||
uncalled = Decimal(act[3])
|
||||
calls = [0]
|
||||
pass
|
||||
|
||||
elif act[1] == 'folds':
|
||||
self.pot.addFold(act[0])
|
||||
if uncalled > 0 and max(calls+[0]) < uncalled:
|
||||
|
||||
print "DEBUG returning some bet, calls:", calls
|
||||
print "DEBUG returned: %.2f from %.2f" % ((uncalled - max(calls)), self.totalpot,)
|
||||
self.totalpot -= (uncalled - max(calls))
|
||||
print "DEBUG new totalpot:", self.totalpot
|
||||
|
||||
print "DEBUG new Pot.total:", self.pot
|
||||
|
||||
if self.totalcollected is None:
|
||||
self.totalcollected = 0;
|
||||
|
@ -395,9 +411,7 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
|||
print >>fh, _("Table '%s' %d-max Seat #%s is the button" %(self.tablename, self.maxseats, self.buttonpos))
|
||||
|
||||
players_who_act_preflop = set([x[0] for x in self.actions['PREFLOP']])
|
||||
#print players_who_act_preflop
|
||||
#print [x[1] for x in self.players]
|
||||
#print [x for x in self.players if x[1] in players_who_act_preflop]
|
||||
|
||||
for player in [x for x in self.players if x[1] in players_who_act_preflop]:
|
||||
#Only print stacks of players who do something preflop
|
||||
print >>fh, _("Seat %s: %s ($%s)" %(player[0], player[1], player[2]))
|
||||
|
@ -446,7 +460,8 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
|||
print >>fh, "DEBUG: what do they show"
|
||||
|
||||
print >>fh, _("*** SUMMARY ***")
|
||||
print >>fh, _("Total pot $%s | Rake $%.2f" % (self.totalpot, self.rake)) # TODO: side pots
|
||||
print >>fh, "%s | Rake $%.2f" % (self.pot, self.rake)
|
||||
#print >>fh, _("Total pot $%s | Rake $%.2f" % (self.totalpot, self.rake)) # TODO: side pots
|
||||
|
||||
board = []
|
||||
for s in self.board.values():
|
||||
|
@ -505,10 +520,6 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
|||
def bestHand(self, side, cards):
|
||||
return HandHistoryConverter.eval.best('hi', cards, [])
|
||||
|
||||
# from pokergame.py
|
||||
def bestHandValue(self, side, serial):
|
||||
(value, cards) = self.bestHand(side, serial)
|
||||
return value
|
||||
|
||||
# from pokergame.py
|
||||
# got rid of the _ for internationalisation
|
||||
|
@ -544,3 +555,61 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
|||
|
||||
|
||||
class FpdbParseError(Exception): pass
|
||||
|
||||
class Pot(object):
|
||||
|
||||
def __init__(self, contenders):
|
||||
self.contenders = contenders
|
||||
self.committed = dict([(player,Decimal(0)) for player in contenders])
|
||||
self.total = Decimal(0)
|
||||
|
||||
def addFold(self, player):
|
||||
self.contenders.remove(player)
|
||||
|
||||
def addMoney(self, player, amount):
|
||||
self.committed[player] += amount
|
||||
|
||||
def __str__(self):
|
||||
self.total = sum(self.committed.values())
|
||||
committed = sorted([ (v,k) for (k,v) in self.committed.items()])
|
||||
lastbet = committed[-1][0] - committed[-2][0]
|
||||
if lastbet > 0: # uncalled
|
||||
returnto = committed[-1][1]
|
||||
#print "returning %f to %s" % (lastbet, returnto)
|
||||
self.total -= lastbet
|
||||
self.committed[returnto] -= lastbet
|
||||
|
||||
|
||||
|
||||
# now: for those contenders still contending..
|
||||
commitsall = sorted([(v,k) for (k,v) in self.committed.items() if v >0])
|
||||
|
||||
pots = []
|
||||
while len(commitsall) > 0:
|
||||
commitslive = [(v,k) for (v,k) in commitsall if k in self.contenders]
|
||||
v1 = commitslive[0][0]
|
||||
pots += [sum([min(v,v1) for (v,k) in commitsall])]
|
||||
#print "all: ", commitsall
|
||||
#print "live:", commitslive
|
||||
commitsall = [((v-v1),k) for (v,k) in commitsall if v-v1 >0]
|
||||
|
||||
|
||||
#print "[**]", pots
|
||||
|
||||
# TODO: I think rake gets taken out of the pots.
|
||||
# so it goes:
|
||||
# total pot x. main pot y, side pot z. | rake r
|
||||
# and y+z+r = x
|
||||
# for example:
|
||||
# Total pot $124.30 Main pot $98.90. Side pot $23.40. | Rake $2
|
||||
# so....... that's tricky.
|
||||
if len(pots) == 1: # (only use Total pot)
|
||||
#return "Main pot $%.2f." % pots[0]
|
||||
return "Total pot $%.2f" % (self.total,)
|
||||
elif len(pots) == 2:
|
||||
return "Total pot $%.2f Main pot $%.2f. Side pot $%2.f." % (self.total, pots[0],pots[1])
|
||||
elif len(pots) == 3:
|
||||
return "Total pot $%.2f Main pot $%.2f. Side pot-1 $%2.f. Side pot-2 $.2f." % (self.total, pots[0],pots[1],pots[2])
|
||||
else:
|
||||
return "too many pots.. fix me.", pots
|
||||
|
||||
|
|
|
@ -1170,14 +1170,16 @@ def parseHandStartTime(topline, site):
|
|||
tmp=topline[pos1:pos2]
|
||||
isUTC=True
|
||||
else:
|
||||
tmp=topline[-30:]
|
||||
tmp=topline
|
||||
#print "parsehandStartTime, tmp:", tmp
|
||||
pos = tmp.find("-")+2
|
||||
tmp = tmp[pos:]
|
||||
#Need to match either
|
||||
# 2008/09/07 06:23:14 ET or
|
||||
# 2008/08/17 - 01:14:43 (ET)
|
||||
m = re.match('(?P<YEAR>[0-9]{4})\/(?P<MON>[0-9]{2})\/(?P<DAY>[0-9]{2})[\- ]+(?P<HR>[0-9]{2}):(?P<MIN>[0-9]{2}):(?P<SEC>[0-9]{2})',tmp)
|
||||
# 2008/08/17 - 01:14:43 (ET) or
|
||||
# 2008/11/12 9:33:31 CET [2008/11/12 3:33:31 ET]
|
||||
rexx = '(?P<YEAR>[0-9]{4})\/(?P<MON>[0-9]{2})\/(?P<DAY>[0-9]{2})[\- ]+(?P<HR>[0-9]+):(?P<MIN>[0-9]+):(?P<SEC>[0-9]+)'
|
||||
m = re.search(rexx,tmp)
|
||||
#print "year:", int(m.group('YEAR')), "month", int(m.group('MON')), "day", int(m.group('DAY')), "hour", int(m.group('HR')), "minute", int(m.group('MIN')), "second", int(m.group('SEC'))
|
||||
result = datetime.datetime(int(m.group('YEAR')), int(m.group('MON')), int(m.group('DAY')), int(m.group('HR')), int(m.group('MIN')), int(m.group('SEC')))
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user