From 7500bcdf929d73090df274be1a02e728eff61aa6 Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Thu, 11 Dec 2008 17:31:58 +0000 Subject: [PATCH] Everleaf sometimes shows the entire winning hand without reporting holecards seperately. --- pyfpdb/EverleafToFpdb.py | 8 ++++++-- pyfpdb/HandHistoryConverter.py | 14 +++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index 7eee20a7..68e4ce5b 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -79,7 +79,7 @@ class Everleaf(HandHistoryConverter): self.rexx.setHeroCardsRegex('.*\nDealt\sto\s(?P.*)\s\[ (?P\S\S), (?P\S\S) \]') self.rexx.setActionStepRegex('.*\n(?P.*)(?P: bets| checks| raises| calls| folds)(\s\[\$ (?P[.\d]+) USD\])?') self.rexx.setShowdownActionRegex('.*\n(?P.*) shows \[ (?P.*) \]') - self.rexx.setCollectPotRegex('.*\n(?P.*) wins \$ (?P[.\d]+) USD.*') + self.rexx.setCollectPotRegex('.*\n(?P.*) wins \$ (?P[.\d]+) USD(.*\[ (?P.*) \])?') self.rexx.compileRegexes() def readSupportedGames(self): @@ -195,6 +195,10 @@ class Everleaf(HandHistoryConverter): def readCollectPot(self,hand): m = self.rexx.collect_pot_re.search(hand.string) if m is not None: + if m.group('HAND') is not None: + re_card = re.compile('(?P[0-9tjqka][schd])') # copied from earlier + cards = set([hand.card(card.group('CARD')) for card in re_card.finditer(m.group('HAND'))]) + hand.addShownCards(cards=None, player=m.group('PNAME'), holeandboard=cards) hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT')) else: print "WARNING: Unusual, no one collected; can happen if it's folded to big blind with a dead small blind." @@ -204,7 +208,7 @@ class Everleaf(HandHistoryConverter): if __name__ == "__main__": c = Configuration.Config() - e = Everleaf(c, "Speed_Kuala_full.txt") + e = Everleaf(c, "regression-test-files/everleaf/Speed_Kuala_full.txt") e.processFile() print str(e) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 6cb4e2b5..65cf68d3 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -327,6 +327,7 @@ If a player has None chips he won't be added.""" Assigns observed holecards to a player. cards list of card bigrams e.g. ['2h','jc'] player (string) name of player +hand Note, will automatically uppercase the rank letter. """ try: @@ -336,12 +337,19 @@ Note, will automatically uppercase the rank letter. except FpdbParseError, e: print "Tried to add holecards for unknown player: %s" % (player,) - def addShownCards(self, cards, player): + def addShownCards(self, cards, player, holeandboard=None): """\ For when a player shows cards for any reason (for showdown or out of choice). """ - self.shown.add(player) - self.addHoleCards(cards,player) + if cards is not None: + self.shown.add(player) + self.addHoleCards(cards,player) + elif holeandboard is not None: + board = set([c for s in self.board.values() for c in s]) + #print board + #print holeandboard + #print holeandboard.difference(board) + self.addHoleCards(holeandboard.difference(board),player) def checkPlayerExists(self,player):