From ce93c2f7fe6fc146d03aaa3e3d1f52e24401d326 Mon Sep 17 00:00:00 2001 From: Worros Date: Mon, 23 Aug 2010 13:50:04 +0800 Subject: [PATCH] OnGame: Parse herocards --- pyfpdb/OnGameToFpdb.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/pyfpdb/OnGameToFpdb.py b/pyfpdb/OnGameToFpdb.py index a2320e74..a8b82c1b 100755 --- a/pyfpdb/OnGameToFpdb.py +++ b/pyfpdb/OnGameToFpdb.py @@ -122,7 +122,7 @@ class OnGame(HandHistoryConverter): self.re_Antes = re.compile(r"^%(PLYR)s: posts the ante %(CUR)s(?P[.0-9]+)" % subst, re.MULTILINE) self.re_BringIn = re.compile(r"^%(PLYR)s: brings[- ]in( low|) for %(CUR)s(?P[.0-9]+)" % subst, re.MULTILINE) self.re_PostBoth = re.compile('.*\n(?P.*): posts small \& big blinds \(\$? (?P[.0-9]+)\)') - self.re_HeroCards = re.compile('.*\nDealt\sto\s(?P.*)\s\[ (?P.*) \]') + self.re_HeroCards = re.compile('Dealing\sto\s%(PLYR)s:\s\[(?P.*)\]' % subst) #lopllopl checks, Eurolll checks, .Lucchess checks. self.re_Action = re.compile('(, )?(?P.*?)(?P bets| checks| raises| calls| folds)( (?P\d*\.?\d*))?( and is all-in)?') @@ -275,17 +275,15 @@ class OnGame(HandHistoryConverter): hand.addBringIn(m.group('PNAME'), m.group('BRINGIN')) def readHeroCards(self, hand): - m = self.re_HeroCards.search(hand.handText) - if(m == None): - #Not involved in hand - hand.involved = False - else: - hand.hero = m.group('PNAME') - # "2c, qh" -> set(["2c","qc"]) - # Also works with Omaha hands. - cards = m.group('CARDS') - cards = set(cards.split(',')) - hand.addHoleCards(cards, m.group('PNAME')) + # streets PREFLOP, PREDRAW, and THIRD are special cases beacause + # we need to grab hero's cards + for street in ('PREFLOP', 'DEAL'): + if street in hand.streets.keys(): + m = self.re_HeroCards.finditer(hand.streets[street]) + for found in m: + hand.hero = found.group('PNAME') + newcards = found.group('CARDS').split(', ') + hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True) def readAction_old(self, hand, street): m = self.re_Action.finditer(hand.streets.group(street))