Start of fixes to draw parsing

This commit is contained in:
Worros 2009-11-29 14:40:32 +08:00
parent e93412f12d
commit f5d8f153b5
2 changed files with 16 additions and 8 deletions

View File

@ -535,7 +535,7 @@ Map the tuple self.gametype onto the pokerstars string describing it
elif act[1] == 'bringin':
return ("%s: brings in for %s%s%s" %(act[0], self.sym, act[2], ' and is all-in' if act[3] else ''))
elif act[1] == 'discards':
return ("%s: discards %s %s%s" %(act[0], act[2], 'card' if act[2] == 1 else 'cards' , " [" + " ".join(self.discards[act[0]]['DRAWONE']) + "]" if self.hero == act[0] else ''))
return ("%s: discards %s %s%s" %(act[0], act[2], 'card' if act[2] == 1 else 'cards' , " [" + " ".join(self.discards['DRAWONE'][act[0]]) + "]" if self.hero == act[0] else ''))
elif act[1] == 'stands pat':
return ("%s: stands pat" %(act[0]))
@ -953,6 +953,13 @@ class DrawHand(Hand):
act = (player, 'discards', num)
self.actions[street].append(act)
def holecardsAsSet(self, street, player):
"""Return holdcards: (oc, nc) as set()"""
(nc,oc) = self.holecards[street][player]
nc = set(nc)
oc = set(oc)
return (nc, oc)
def getStreetTotals(self):
# street1Pot INT, /* pot size at flop/street4 */
# street2Pot INT, /* pot size at turn/street5 */
@ -979,9 +986,10 @@ class DrawHand(Hand):
if 'DEAL' in self.actions:
print >>fh, _("*** DEALING HANDS ***")
for player in [x[1] for x in self.players if x[1] in players_who_act_ondeal]:
if 'DEAL' in self.holecards[player]:
(nc,oc) = self.holecards[player]['DEAL']
print >>fh, _("Dealt to %s: [%s]") % (player, " ".join(nc))
if 'DEAL' in self.holecards:
if self.holecards['DEAL'].has_key(player):
(nc,oc) = self.holecards['DEAL'][player]
print >>fh, _("Dealt to %s: [%s]") % (player, " ".join(nc))
for act in self.actions['DEAL']:
print >>fh, self.actionString(act)
@ -990,7 +998,7 @@ class DrawHand(Hand):
for act in self.actions['DRAWONE']:
print >>fh, self.actionString(act)
if act[0] == self.hero and act[1] == 'discards':
(nc,oc) = self.holecards['DRAWONE'][act[0]]
(nc,oc) = self.holecardsAsSet('DRAWONE', act[0])
dc = self.discards['DRAWONE'][act[0]]
kc = oc - dc
print >>fh, _("Dealt to %s [%s] [%s]" % (act[0], " ".join(kc), " ".join(nc)))
@ -1000,7 +1008,7 @@ class DrawHand(Hand):
for act in self.actions['DRAWTWO']:
print >>fh, self.actionString(act)
if act[0] == self.hero and act[1] == 'discards':
(nc,oc) = self.holecards['DRAWTWO'][act[0]]
(nc,oc) = self.holecardsAsSet('DRAWONE', act[0])
dc = self.discards['DRAWTWO'][act[0]]
kc = oc - dc
print >>fh, _("Dealt to %s [%s] [%s]" % (act[0], " ".join(kc), " ".join(nc)))
@ -1010,7 +1018,7 @@ class DrawHand(Hand):
for act in self.actions['DRAWTHREE']:
print >>fh, self.actionString(act)
if act[0] == self.hero and act[1] == 'discards':
(nc,oc) = self.holecards['DRAWTHREE'][act[0]]
(nc,oc) = self.holecardsAsSet('DRAWONE', act[0])
dc = self.discards['DRAWTHREE'][act[0]]
kc = oc - dc
print >>fh, _("Dealt to %s [%s] [%s]" % (act[0], " ".join(kc), " ".join(nc)))

View File

@ -101,7 +101,7 @@ class PokerStars(HandHistoryConverter):
self.re_HeroCards = re.compile(r"^Dealt to %(PLYR)s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % subst, re.MULTILINE)
self.re_Action = re.compile(r"""
^%(PLYR)s:(?P<ATYPE>\sbets|\schecks|\sraises|\scalls|\sfolds|\sdiscards|\sstands\spat)
(\s%(CUR)s(?P<BET>[.\d]+))?(\sto\s%(CUR)s(?P<BETTO>[.\d]+))? # the number discarded goes in <BET>
(\s(%(CUR)s)?(?P<BET>[.\d]+))?(\sto\s%(CUR)s(?P<BETTO>[.\d]+))? # the number discarded goes in <BET>
(\scards?(\s\[(?P<DISCARDED>.+?)\])?)?"""
% subst, re.MULTILINE|re.VERBOSE)
self.re_ShowdownAction = re.compile(r"^%s: shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)