From 91105824bdb00fb024885a53cd5102eb47cceaaa Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Wed, 10 Dec 2008 00:48:45 +0000 Subject: [PATCH 1/2] wasn't printing bets and fixed last fix --- pyfpdb/EverleafToFpdb.py | 14 +++++++++----- pyfpdb/HandHistoryConverter.py | 29 ++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index de7823bf..ff345194 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -188,15 +188,19 @@ class Everleaf(HandHistoryConverter): m = self.rexx.action_re.finditer(hand.streets.group(street)) hand.actions[street] = [] for action in m: - if action.group('ATYPE') == 'raises': + if action.group('ATYPE') == ' raises': hand.addRaiseTo( street, action.group('PNAME'), action.group('BET') ) - elif action.group('ATYPE') == 'calls': + elif action.group('ATYPE') == ' calls': hand.addCall( street, action.group('PNAME'), action.group('BET') ) - elif action.group('ATYPE') == 'bets': + elif action.group('ATYPE') == ': bets': hand.addBet( street, action.group('PNAME'), action.group('BET') ) + elif action.group('ATYPE') == ' folds': + hand.addFold( street, action.group('PNAME')) + elif action.group('ATYPE') == ' checks': + hand.addCheck( street, action.group('PNAME')) else: - #print "DEBUG: unimplemented readAction: %s %s" %(action.group('PNAME'),action.group('ATYPE'),) - hand.actions[street] += [[action.group('PNAME'), action.group('ATYPE')]] + print "DEBUG: unimplemented readAction: %s %s" %(action.group('PNAME'),action.group('ATYPE'),) + #hand.actions[street] += [[action.group('PNAME'), action.group('ATYPE')]] def readShowdownActions(self, hand): diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index a6a294c4..5fa83a0e 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -353,9 +353,15 @@ class Hand: def addBet(self, street, player=None, amount=0): self.bets[street][player].append(Decimal(amount)) - self.orderedBets[street].append(Decimal(amount)) + #self.orderedBets[street].append(Decimal(amount)) self.actions[street] += [[player, 'bets', amount]] + def addFold(self, street, player): + self.actions[street] += [[player, 'folds']] + + def addCheck(self, street, player): + self.actions[street] += [[player, 'checks']] + def addCollectPot(self,player, pot): if player not in self.collected: self.collected[player] = pot @@ -401,7 +407,7 @@ Known bug: doesn't take into account side pots""" print "*** HOLE CARDS ***" if self.involved: - print "Dealt to %s [%s %s]" %(self.hero , self.holecards[self.hero][0], self.holecards[self.hero][1]) + print "Dealt to %s [%s]" %(self.hero , " ".join(self.holecards[self.hero])) if 'PREFLOP' in self.actions: for act in self.actions['PREFLOP']: @@ -435,18 +441,21 @@ Known bug: doesn't take into account side pots""" for s in self.board.values(): board += s if board: # sometimes hand ends preflop without a board - print "Board [%s]" % (board) + print "Board [%s]" % (" ".join(board)) #print self.board for player in self.players: - if player[1] in self.collected and self.holecards[player[1]]: - print "Seat %d: %s showed [%s %s] and won ($%s)" % (player[0], player[1], self.holecards[player[1]][0], self.holecards[player[1]][1], self.collected[player[1]]) - elif player[1] in self.collected: - print "Seat %d: %s collected ($%s)" % (player[0], player[1], self.collected[player[1]]) + seatnum = player[0] + name = player[1] + if name in self.collected and self.holecards[name]: + # TODO: (bug) hero cards will always be 'shown' because they are known to us. Better to explicitly flag those who 'show' their cards. + print "Seat %d: %s showed [%s] and won ($%s)" % (seatnum, name, " ".join(self.holecards[name]), self.collected[name]) + elif name in self.collected: + print "Seat %d: %s collected ($%s)" % (seatnum, name, self.collected[name]) elif self.holecards[player[1]]: - print "Seat %d: %s showed [%s %s]" % (player[0], player[1], self.holecards[player[1]][0], self.holecards[player[1]][1]) + print "Seat %d: %s showed [%s]" % (seatnum, name, " ".join(self.holecards[name])) else: - print "Seat %d: %s folded (or mucked..)" % (player[0], player[1]) + print "Seat %d: %s folded or mucked" % (seatnum, name) print # TODO: @@ -470,6 +479,8 @@ Known bug: doesn't take into account side pots""" print "%s: %s " %(act[0], act[1]) if act[1] == 'calls': print "%s: %s $%s" %(act[0], act[1], act[2]) + if act[1] == 'bets': + print "%s: %s $%s" %(act[0], act[1], act[2]) if act[1] == 'raises': print "%s: %s $%s to $%s" %(act[0], act[1], act[2], act[3]) From 3ff2ec21063716e2d51452f86999af644c531e96 Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Wed, 10 Dec 2008 00:58:10 +0000 Subject: [PATCH 2/2] removed read board cards from markStreets --- pyfpdb/EverleafToFpdb.py | 10 +++++----- pyfpdb/HandHistoryConverter.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index ff345194..19253ddc 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -118,9 +118,9 @@ class Everleaf(HandHistoryConverter): def readPlayerStacks(self, hand): m = self.rexx.player_info_re.finditer(hand.string) players = [] - print "\nReading stacks - players seen:" + #print "\nReading stacks - players seen:" for a in m: - print a.group('PNAME') + #print a.group('PNAME') hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH')) def markStreets(self, hand): @@ -129,9 +129,9 @@ class Everleaf(HandHistoryConverter): #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.string,re.DOTALL) m = re.search(r"\*\* Dealing down cards \*\*(?P.+(?=\*\* Dealing Flop \*\*)|.+)" - r"(\*\* Dealing Flop \*\* \[ (?P\S\S), (?P\S\S), (?P\S\S) \](?P.+(?=\*\* Dealing Turn \*\*)|.+))?" - r"(\*\* Dealing Turn \*\* \[ (?P\S\S) \](?P.+(?=\*\* Dealing River \*\*)|.+))?" - r"(\*\* Dealing River \*\* \[ (?P\S\S) \](?P.+))?", hand.string,re.DOTALL) + r"(\*\* Dealing Flop \*\* \[ \S\S, \S\S, \S\S \](?P.+(?=\*\* Dealing Turn \*\*)|.+))?" + r"(\*\* Dealing Turn \*\* \[ \S\S \](?P.+(?=\*\* Dealing River \*\*)|.+))?" + r"(\*\* Dealing River \*\* \[ \S\S \](?P.+))?", hand.string,re.DOTALL) # that wasn't easy. diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 5fa83a0e..23f39db3 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -306,7 +306,7 @@ class Hand: def setCommunityCards(self, street, cards): self.board[street] = [self.card(c) for c in cards] - print self.board[street] + #print self.board[street] def card(self,c): """upper case the ranks but not suits, 'atjqk' => 'ATJQK'""" @@ -388,7 +388,7 @@ Known bug: doesn't take into account side pots""" def printHand(self): # PokerStars format. - print "### Pseudo stars format ###" + print "\n### Pseudo stars format ###" print "%s Game #%s: %s ($%s/$%s) - %s" %(self.sitename, self.handid, "XXXXhand.gametype", self.sb, self.bb, self.starttime) print "Table '%s' %d-max Seat #%s is the button" %(self.tablename, self.maxseats, self.buttonpos) for player in self.players: @@ -414,17 +414,17 @@ Known bug: doesn't take into account side pots""" self.printActionLine(act) if 'FLOP' in self.actions: - print "*** FLOP *** [%s %s %s]" %(self.streets.group("FLOP1"), self.streets.group("FLOP2"), self.streets.group("FLOP3")) + print "*** FLOP *** [%s]" %( " ".join(self.board['Flop'])) for act in self.actions['FLOP']: self.printActionLine(act) if 'TURN' in self.actions: - print "*** TURN *** [%s %s %s] [%s]" %(self.streets.group("FLOP1"), self.streets.group("FLOP2"), self.streets.group("FLOP3"), self.streets.group("TURN1")) + print "*** TURN *** [%s] [%s]" %( " ".join(self.board['Flop']), " ".join(self.board['Turn'])) for act in self.actions['TURN']: self.printActionLine(act) if 'RIVER' in self.actions: - print "*** RIVER *** [%s %s %s %s] [%s]" %(self.streets.group("FLOP1"), self.streets.group("FLOP2"), self.streets.group("FLOP3"), self.streets.group("TURN1"), self.streets.group("RIVER1")) + print "*** RIVER *** [%s] [%s]" %(" ".join(self.board['Flop']+self.board['Turn']), " ".join(self.board['River']) ) for act in self.actions['RIVER']: self.printActionLine(act)