From d7ed15bcfe9c982ff119e971b3a72211babc81a2 Mon Sep 17 00:00:00 2001 From: Chaz Littlejohn Date: Tue, 5 Apr 2011 02:41:53 +0000 Subject: [PATCH] Added the column 'showed' to handsplayers which flags whether or not a player showed his or her hand. If false and 'sawSD' is true then they mucked. If true and 'sawSD' is false, then they showed outside of a showdown (site dependent). Also fixed up readShownCards in FTP's hhc so it recorded mucked and showed correctly. --- pyfpdb/Database.py | 3 ++- pyfpdb/DerivedStats.py | 3 +++ pyfpdb/FulltiltToFpdb.py | 15 ++++++++++----- pyfpdb/SQL.py | 6 +++++- pyfpdb/TestHandsPlayers.py | 2 +- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 431e9c0b..5632cffe 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -73,7 +73,7 @@ except ImportError: use_numpy = False -DB_VERSION = 154 +DB_VERSION = 155 # Variance created as sqlite has a bunch of undefined aggregate functions. @@ -1963,6 +1963,7 @@ class Database: pdata[p]['street3Seen'], pdata[p]['street4Seen'], pdata[p]['sawShowdown'], + pdata[p]['showed'], pdata[p]['wonAtSD'], pdata[p]['street0Aggr'], pdata[p]['street1Aggr'], diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index 6cc97d09..805cc912 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -43,6 +43,7 @@ class DerivedStats(): init['street4Aggr'] = False init['wonWhenSeenStreet1'] = 0.0 init['sawShowdown'] = False + init['showed'] = False init['wonAtSD'] = 0.0 init['startCards'] = 0 init['position'] = 2 @@ -187,6 +188,8 @@ class DerivedStats(): self.handsplayers[player[1]]['tourneysPlayersIds'] = hand.tourneysPlayersIds[player[1]] else: self.handsplayers[player[1]]['tourneysPlayersIds'] = None + if player[1] in hand.shown: + self.handsplayers[player[1]]['showed'] = True #### seen now processed in playersAtStreetX() # XXX: enumerate(list, start=x) is python 2.6 syntax; 'start' diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index 07ba6785..c07e2a48 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -170,7 +170,7 @@ class Fulltilt(HandHistoryConverter): self.re_ShowdownAction = re.compile(r"^%s shows \[(?P.*)\]" % player_re, re.MULTILINE) self.re_CollectPot = re.compile(r"^Seat (?P[0-9]+): %(PLAYERS)s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \([%(LS)s]?(?P[%(NUM)s]+)\)(, mucked| with.*)?" % self.substitutions, re.MULTILINE) self.re_SitsOut = re.compile(r"^%s sits out" % player_re, re.MULTILINE) - self.re_ShownCards = re.compile(r"^Seat (?P[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(?Pshowed|mucked) \[(?P.*)\](( and won \(.*\) with | and lost with | \- )(?P.*))?" % player_re, re.MULTILINE) + self.re_ShownCards = re.compile(r"^Seat (?P[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(?Pshowed|mucked) \[(?P.*)\](( and won \(.*\) with | and lost with | \- )(?P.*))?" % player_re, re.MULTILINE) def readSupportedGames(self): return [["ring", "hold", "nl"], @@ -525,11 +525,16 @@ class Fulltilt(HandHistoryConverter): def readShownCards(self,hand): for m in self.re_ShownCards.finditer(hand.handText): if m.group('CARDS') is not None: + cards = m.group('CARDS') + cards = cards.split(' ') # needs to be a list, not a set--stud needs the order string = m.group('STRING') - if m.group('ACT'): - hand.addShownCards(cards=m.group('CARDS').split(' '), player=m.group('PNAME'), shown = False, mucked = True, string = string) - else: - hand.addShownCards(cards=m.group('CARDS').split(' '), player=m.group('PNAME'), shown = True, mucked = False, string = string) + + (shown, mucked) = (False, False) + if m.group('SHOWED') == "showed": shown = True + elif m.group('SHOWED') == "mucked": mucked = True + + #print "DEBUG: hand.addShownCards(%s, %s, %s, %s)" %(cards, m.group('PNAME'), shown, mucked) + hand.addShownCards(cards=cards, player=m.group('PNAME'), shown=shown, mucked=mucked, string=string) def guessMaxSeats(self, hand): """Return a guess at max_seats when not specified in HH.""" diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index a7cc824e..48a2ef6d 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -731,6 +731,7 @@ class Sql: street3Seen BOOLEAN, street4Seen BOOLEAN, sawShowdown BOOLEAN, + showed BOOLEAN, street1Aggr BOOLEAN, street2Aggr BOOLEAN, @@ -871,6 +872,7 @@ class Sql: street3Seen BOOLEAN, street4Seen BOOLEAN, sawShowdown BOOLEAN, + showed BOOLEAN, street1Aggr BOOLEAN, street2Aggr BOOLEAN, @@ -1010,6 +1012,7 @@ class Sql: street3Seen INT, street4Seen INT, sawShowdown INT, + showed INT, street1Aggr INT, street2Aggr INT, @@ -4963,6 +4966,7 @@ class Sql: street3Seen, street4Seen, sawShowdown, + showed, wonAtSD, street0Aggr, street1Aggr, @@ -5071,7 +5075,7 @@ class Sql: %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, - %s, %s + %s, %s, %s )""" self.query['store_hands_actions'] = """insert into HandsActions ( diff --git a/pyfpdb/TestHandsPlayers.py b/pyfpdb/TestHandsPlayers.py index b94344de..23859d9e 100755 --- a/pyfpdb/TestHandsPlayers.py +++ b/pyfpdb/TestHandsPlayers.py @@ -127,7 +127,7 @@ def compare_handsplayers_file(filename, importer, errors): # The stats match - continue pass else: - if stat == 'tourneyTypeId' or stat == 'tourneysPlayersIds': + if stat == 'tourneyTypeId' or stat == 'tourneysPlayersIds' or stat == 'showed': # Not and error pass else: