From f714b25487d32d063b40778f0f301a2a2b825368 Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Tue, 10 Mar 2009 17:25:49 +0000 Subject: [PATCH] everleaf stud markstreets, antes, bringin todo: completes todo: strange pot bug :( maybe go away if we add bringin completes or something fulltilt: warning if bringin not found --- pyfpdb/EverleafToFpdb.py | 35 ++++++++++++++++++++++++++++++++--- pyfpdb/FulltiltToFpdb.py | 8 +++++--- pyfpdb/Hand.py | 7 +++++-- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index 307160c4..1efc0573 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -59,6 +59,8 @@ follow : whether to tail -f the input""" self.re_PostSB = re.compile(ur"^%s: posts small blind \[(?:\$| €|) (?P[.0-9]+)" % player_re, re.MULTILINE) self.re_PostBB = re.compile(ur"^%s: posts big blind \[(?:\$| €|) (?P[.0-9]+)" % player_re, re.MULTILINE) self.re_PostBoth = re.compile(ur"^%s: posts both blinds \[(?:\$| €|) (?P[.0-9]+)" % player_re, re.MULTILINE) + self.re_Antes = re.compile(ur"^%s: posts ante \[(?:\$| €|) (?P[.0-9]+)" % player_re, re.MULTILINE) + self.re_BringIn = re.compile(ur"^%s posts bring-in (?:\$| €|)(?P[.0-9]+)\." % player_re, re.MULTILINE) self.re_HeroCards = re.compile(ur"^Dealt to %s \[ (?P.*) \]" % player_re, re.MULTILINE) self.re_Action = re.compile(ur"^%s(?P: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P[.\d]+) (USD|EUR|)\])?" % player_re, re.MULTILINE) self.re_ShowdownAction = re.compile(ur"^%s shows \[ (?P.*) \]" % player_re, re.MULTILINE) @@ -164,12 +166,18 @@ or None if we fail to get the info """ # PREFLOP = ** Dealing down cards ** # This re fails if, say, river is missing; then we don't get the ** that starts the river. #m = re.search('(\*\* Dealing down cards \*\*\n)(?P.*?\n\*\*)?( Dealing Flop \*\* \[ (?P\S\S), (?P\S\S), (?P\S\S) \])?(?P.*?\*\*)?( Dealing Turn \*\* \[ (?P\S\S) \])?(?P.*?\*\*)?( Dealing River \*\* \[ (?P\S\S) \])?(?P.*)', hand.handText,re.DOTALL) - - m = re.search(r"\*\* Dealing down cards \*\*(?P.+(?=\*\* Dealing Flop \*\*)|.+)" + if hand.gametype['base'] == 'hold': + m = re.search(r"\*\* Dealing down cards \*\*(?P.+(?=\*\* Dealing Flop \*\*)|.+)" r"(\*\* Dealing Flop \*\*(?P \[ \S\S, \S\S, \S\S \].+(?=\*\* Dealing Turn \*\*)|.+))?" r"(\*\* Dealing Turn \*\*(?P \[ \S\S \].+(?=\*\* Dealing River \*\*)|.+))?" r"(\*\* Dealing River \*\*(?P \[ \S\S \].+))?", hand.handText,re.DOTALL) - + elif hand.gametype['base'] == 'stud': + m = re.search(r"(?P.+(?=\*\* Dealing down cards \*\*)|.+)" + r"(\*\* Dealing down cards \*\*(?P.+(?=\*\*\*\* dealing 4th street \*\*\*\*)|.+))?" + r"(\*\*\*\* dealing 4th street \*\*\*\*(?P.+(?=\*\*\*\* dealing 5th street \*\*\*\*)|.+))?" + r"(\*\*\*\* dealing 5th street \*\*\*\*(?P.+(?=\*\*\*\* dealing 6th street \*\*\*\*)|.+))?" + r"(\*\*\*\* dealing 6th street \*\*\*\*(?P.+(?=\*\*\*\* dealing river \*\*\*\*)|.+))?" + r"(\*\*\*\* dealing river \*\*\*\*(?P.+))?", hand.handText,re.DOTALL) hand.addStreets(m) def readCommunityCards(self, hand, street): # street has been matched by markStreets, so exists in this hand @@ -182,6 +190,21 @@ or None if we fail to get the info """ cards = [card.strip() for card in cards.split(',')] hand.setCommunityCards(street=street, cards=cards) + def readAntes(self, hand): + logging.debug("reading antes") + m = self.re_Antes.finditer(hand.handText) + for player in m: + logging.debug("hand.addAnte(%s,%s)" %(player.group('PNAME'), player.group('ANTE'))) + hand.addAnte(player.group('PNAME'), player.group('ANTE')) + + def readBringIn(self, hand): + m = self.re_BringIn.search(hand.handText,re.DOTALL) + if m: + logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN'))) + hand.addBringIn(m.group('PNAME'), m.group('BRINGIN')) + else: + logging.warning("No bringin found.") + def readBlinds(self, hand): m = self.re_PostSB.search(hand.handText) if m is not None: @@ -210,6 +233,12 @@ or None if we fail to get the info """ #Not involved in hand hand.involved = False + def readStudPlayerCards(self, hand, street): + # lol. see Plymouth.txt + logging.warning("Everleaf readStudPlayerCards is only a stub.") + #~ if street in ('THIRD', 'FOURTH', 'FIFTH', 'SIXTH'): + #~ hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = [], open = []) + def readAction(self, hand, street): logging.debug("readAction (%s)" % street) diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index cd3ccd3e..6ba128fc 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -182,9 +182,11 @@ follow : whether to tail -f the input""" def readBringIn(self, hand): m = self.re_BringIn.search(hand.handText,re.DOTALL) - logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN'))) - - hand.addBringIn(m.group('PNAME'), m.group('BRINGIN')) + if m: + logging.debug("Player bringing in: %s for %s" %(m.group('PNAME'), m.group('BRINGIN'))) + hand.addBringIn(m.group('PNAME'), m.group('BRINGIN')) + else: + logging.warning("No bringin found") def readButton(self, hand): hand.buttonpos = int(self.re_Button.search(hand.handText).group('BUTTON')) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index ef45d94a..727656b6 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -618,8 +618,9 @@ closed likewise, but known only to player print >>fh, _("*** 3RD STREET ***") for player in [x[1] for x in self.players if x[1] in players_who_post_antes]: print player, self.holecards[player] - (closed, open) = self.holecards[player]['THIRD'] - print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(closed) + "]" if closed else " ", " [" + " ".join(open) + "]" if open else " ") + if 'THIRD' in self.holecards[player]: + (closed, open) = self.holecards[player]['THIRD'] + print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(closed) + "]" if closed else " ", " [" + " ".join(open) + "]" if open else " ") for act in self.actions['THIRD']: #FIXME: Need some logic here for bringin vs completes self.printActionLine(act, fh) @@ -732,6 +733,8 @@ class Pot(object): self.pots = [] while len(commitsall) > 0: commitslive = [(v,k) for (v,k) in commitsall if k in self.contenders] + print "all", commitsall + print "live", commitslive v1 = commitslive[0][0] self.pots += [sum([min(v,v1) for (v,k) in commitsall])] commitsall = [((v-v1),k) for (v,k) in commitsall if v-v1 >0]