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..77d76eb3 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -327,21 +327,28 @@ 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: self.checkPlayerExists(player) - for c in cards: - self.holecards[player].append(self.card(c)) + self.holecards[player] = set([self.card(c) for c in cards]) 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):