From 2cfe7f2ccc5ab27b567962de5c52926e8a463db8 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 1 Jul 2009 08:29:37 -0400 Subject: [PATCH 1/7] Fix bug--get correct player id in Flop_Mucked tool tip. --- pyfpdb/Mucked.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index c0715632..b3b134c5 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -448,7 +448,8 @@ class Flop_Mucked(Aux_Seats): container.move(self.positions[i][0], self.positions[i][1]) # here is where I move back self.displayed = True if i != "common": - self.m_windows[i].eb.set_tooltip_text(self.hud.stat_dict[i]['screen_name']) + id = self.get_id_from_seat(i) + self.m_windows[i].eb.set_tooltip_text(self.hud.stat_dict[id]['screen_name']) def update_gui(self, new_hand_id): """Prepare and show the mucked cards.""" @@ -458,7 +459,7 @@ class Flop_Mucked(Aux_Seats): n_sd = 0 for (i, cards) in self.hud.cards.iteritems(): n_cards = self.has_cards(cards) - if n_cards > 0: + if n_cards > 0 and i != 'common': n_sd = n_sd + 1 if n_sd < 2: print "skipping, n_sd =", n_sd From 4394c7beb38af9fbad8b82da97562eabab939b82 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 1 Jul 2009 13:53:30 -0400 Subject: [PATCH 2/7] Fix to convert stud hands. --- pyfpdb/Hand.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index b9272031..a0c1537c 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -916,6 +916,11 @@ class StudHand(Hand): def __init__(self, hhc, sitename, gametype, handText, builtFrom = "HHC"): if gametype['base'] != 'stud': pass # or indeed don't pass and complain instead + + self.allStreets = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH'] + self.communityStreets = [] + self.actionStreets = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH'] + self.streetList = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH'] # a list of the observed street names in order self.holeStreets = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH'] Hand.__init__(self, sitename, gametype, handText) @@ -957,7 +962,7 @@ closed likewise, but known only to player logging.debug("addPlayerCards %s, o%s x%s" % (player, open, closed)) try: self.checkPlayerExists(player) - self.holecards[player][street] = (open, closed) + self.holecards[street][player] = (open, closed) # cards = set([self.card(c) for c in cards]) # self.holecards[player].update(cards) except FpdbParseError, e: @@ -1015,8 +1020,8 @@ Add a complete on [street] by [player] to [amountTo] dealt = 0 #~ print >>fh, _("*** 3RD STREET ***") for player in [x[1] for x in self.players if x[1] in players_who_post_antes]: - if 'THIRD' in self.holecards[player]: - (open, closed) = self.holecards[player]['THIRD'] + if self.holecards['THIRD'].has_key(player): + (open, closed) = self.holecards['THIRD'][player] dealt+=1 if dealt==1: print >>fh, _("*** 3RD STREET ***") @@ -1029,12 +1034,12 @@ Add a complete on [street] by [player] to [amountTo] dealt = 0 #~ print >>fh, _("*** 4TH STREET ***") for player in [x[1] for x in self.players if x[1] in players_who_post_antes]: - if 'FOURTH' in self.holecards[player]: + if player in self.holecards['FOURTH']: old = [] - (o,c) = self.holecards[player]['THIRD'] + (o,c) = self.holecards['THIRD'][player] if o:old.extend(o) if c:old.extend(c) - new = self.holecards[player]['FOURTH'][0] + new = self.holecards['FOURTH'][player][0] dealt+=1 if dealt==1: print >>fh, _("*** 4TH STREET ***") @@ -1046,13 +1051,13 @@ Add a complete on [street] by [player] to [amountTo] dealt = 0 #~ print >>fh, _("*** 5TH STREET ***") for player in [x[1] for x in self.players if x[1] in players_who_post_antes]: - if 'FIFTH' in self.holecards[player]: + if self.holecards['FIFTH'].has_key(player): old = [] for street in ('THIRD','FOURTH'): - (o,c) = self.holecards[player][street] + (o,c) = self.holecards[street][player] if o:old.extend(o) if c:old.extend(c) - new = self.holecards[player]['FIFTH'][0] + new = self.holecards['FIFTH'][player][0] dealt+=1 if dealt==1: print >>fh, _("*** 5TH STREET ***") @@ -1064,13 +1069,13 @@ Add a complete on [street] by [player] to [amountTo] dealt = 0 #~ print >>fh, _("*** 6TH STREET ***") for player in [x[1] for x in self.players if x[1] in players_who_post_antes]: - if 'SIXTH' in self.holecards[player]: + if self.holecards['SIXTH'].has_key(player): old = [] for street in ('THIRD','FOURTH','FIFTH'): - (o,c) = self.holecards[player][street] + (o,c) = self.holecards[street][player] if o:old.extend(o) if c:old.extend(c) - new = self.holecards[player]['SIXTH'][0] + new = self.holecards['SIXTH'][player][0] dealt += 1 if dealt == 1: print >>fh, _("*** 6TH STREET ***") @@ -1085,13 +1090,13 @@ Add a complete on [street] by [player] to [amountTo] # i.e. are all but one players folded; is there an allin showdown; and all that. print >>fh, _("*** 7TH STREET ***") for player in [x[1] for x in self.players if x[1] in players_who_post_antes]: - if 'SEVENTH' in self.holecards[player]: + if self.holecards['SEVENTH'].has_key(player): old = [] for street in ('THIRD','FOURTH','FIFTH','SIXTH'): - (o,c) = self.holecards[player][street] + (o,c) = self.holecards[street][player] if o:old.extend(o) if c:old.extend(c) - new = self.holecards[player]['SEVENTH'][0] + new = self.holecards['SEVENTH'][player][0] if new: print >>fh, _("Dealt to %s:%s%s") % (player, " [" + " ".join(old) + "] " if old else " ", "[" + " ".join(new) + "]" if new else "") for act in self.actions['SEVENTH']: From 97520bfee9705d936c48c9e183999db60dbb0900 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 1 Jul 2009 13:55:12 -0400 Subject: [PATCH 3/7] Fix call to StoreHands for stud games. --- pyfpdb/Database.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 2cade5de..e9401d35 100755 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -287,7 +287,8 @@ class Database: fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) hands_id = fpdb_simple.storeHands(self.backend, db, cursor, site_hand_no, gametype_id - ,hand_start_time, names, tableName, maxSeats, hudImportData) + ,hand_start_time, names, tableName, maxSeats, hudImportData + ,(None, None, None, None, None), (None, None, None, None, None)) #print "before calling store_hands_players_stud, antes:", antes hands_players_ids = fpdb_simple.store_hands_players_stud(self.backend, db, cursor, hands_id, player_ids From 3c2c328f5ae6aea2dc3b90b13f027c8f96ee648b Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 3 Jul 2009 13:23:30 -0400 Subject: [PATCH 4/7] Fix for PokerStars NewVPP tables. --- pyfpdb/Tables.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/Tables.py b/pyfpdb/Tables.py index dcd145f4..d4b879b2 100755 --- a/pyfpdb/Tables.py +++ b/pyfpdb/Tables.py @@ -369,7 +369,7 @@ def clean_title(name): for pattern in [' \(6 max\)', ' \(heads up\)', ' \(deep\)', ' \(deep hu\)', ' \(deep 6\)', ' \(2\)', ' \(edu\)', ' \(edu, 6 max\)', ' \(6\)', - ' \(speed\)', + ' \(speed\)', 'special', 'newVPP', ' no all-in', ' fast', ',', ' 50BB min', '50bb min', '\s+$']: name = re.sub(pattern, '', name) name = name.rstrip() From 9d7c370449f62dfef40b6c9f7978bec827fb1c3e Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 3 Jul 2009 18:59:50 -0400 Subject: [PATCH 5/7] Get mucked cards from Stars flop games. __str__ method for Hand. --- pyfpdb/Hand.py | 56 ++++++++++++++++++++++++++++++++++---- pyfpdb/PokerStarsToFpdb.py | 12 ++++++-- 2 files changed, 60 insertions(+), 8 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index a0c1537c..fa472b03 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -26,6 +26,7 @@ import operator import time,datetime from copy import deepcopy from Exceptions import * +import pprint import DerivedStats import Card @@ -74,6 +75,7 @@ class Hand: self.folded = set() self.dealt = set() # 'dealt to' line to be printed self.shown = set() # cards were shown + self.mucked = set() # cards were mucked at showdown # self.action = [] # Things to do with money @@ -83,8 +85,49 @@ class Hand: self.rake = None def __str__(self): + vars = ( ("BB", self.bb), + ("SB", self.sb), + ("BUTTONPOS", self.buttonpos), + ("HAND NO.", self.handid), + ("SITE", self.sitename), + ("TABLE NAME", self.tablename), + ("HERO", self.hero), + ("MAXSEATS", self.maxseats), + ("LASTBET", self.lastBet), + ("ACTION STREETS", self.actionStreets), + ("STREETS", self.streets), + ("ALL STREETS", self.allStreets), + ("COMMUNITY STREETS", self.communityStreets), + ("HOLE STREETS", self.holeStreets), + ("COUNTED SEATS", self.counted_seats), + ("DEALT", self.dealt), + ("SHOWN", self.shown), + ("MUCKED", self.mucked), + ("TOTAL POT", self.totalpot), + ("TOTAL COLLECTED", self.totalcollected), + ("RAKE", self.rake), + ("START TIME", self.starttime), + ) + + structs = ( ("PLAYERS", self.players), + ("STACKS", self.stacks), + ("POSTED", self.posted), + ("POT", self.pot), + ("SEATING", self.seating), + ("GAMETYPE", self.gametype), + ("ACTION", self.actions), + ("COLLECTEES", self.collectees), + ("BETS", self.bets), + ("BOARD", self.board), + ("DISCARDS", self.discards), + ("HOLECARDS", self.holecards), + ) str = '' - str = str + "Hand Object for %s at %s" % (self.handid, self.sitename) + for (name, var) in vars: + str = str + "\n%s = " % name + pprint.pformat(var) + + for (name, struct) in structs: + str = str + "\n%s =\n" % name + pprint.pformat(struct, 4) return str def insert(self, db): @@ -494,12 +537,13 @@ class HoldemOmahaHand(Hand): pass - def addHoleCards(self, cards, player, shown=False, dealt=False): + def addHoleCards(self, cards, player, shown, mucked, dealt=False): """\ Assigns observed holecards to a player. cards list of card bigrams e.g. ['2h','Jc'] player (string) name of player shown whether they were revealed at showdown +mucked whether they were mucked at showdown dealt whether they were seen in a 'dealt to' line """ logging.debug("addHoleCards %s %s" % (cards, player)) @@ -516,23 +560,25 @@ dealt whether they were seen in a 'dealt to' line self.dealt.add(player) if shown: self.shown.add(player) + if mucked: + self.mucked.add(player) if player in self.holecards['PREFLOP']: self.holecards['PREFLOP'][player].update(cardset) else: self.holecards['PREFLOP'][player] = cardset - def addShownCards(self, cards, player, holeandboard=None): + def addShownCards(self, cards, player, holeandboard=None, shown=True, mucked=False): """\ For when a player shows cards for any reason (for showdown or out of choice). Card ranks will be uppercased """ logging.debug("addShownCards %s hole=%s all=%s" % (player, cards, holeandboard)) if cards is not None: - self.addHoleCards(cards,player,shown=True) + self.addHoleCards(cards,player,shown, mucked) elif holeandboard is not None: holeandboard = set([self.card(c) for c in holeandboard]) board = set([c for s in self.board.values() for c in s]) - self.addHoleCards(holeandboard.difference(board),player,shown=True) + self.addHoleCards(holeandboard.difference(board),player,shown, mucked) def writeHTMLHand(self, fh=sys.__stdout__): diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 5350713c..154d2b9d 100755 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -66,7 +66,7 @@ follow : whether to tail -f the input""" self.re_ShowdownAction = re.compile(r"^%s: shows \[(?P.*)\]" % player_re, re.MULTILINE) self.re_CollectPot = re.compile(r"Seat (?P[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$(?P[.\d]+)\)(, mucked| with.*|)" % player_re, re.MULTILINE) self.re_sitsOut = re.compile("^%s sits out" % player_re, re.MULTILINE) - self.re_ShownCards = re.compile("^Seat (?P[0-9]+): %s \(.*\) showed \[(?P.*)\].*" % player_re, re.MULTILINE) + self.re_ShownCards = re.compile("^Seat (?P[0-9]+): %s \(.*\) (?Pshowed|mucked) \[(?P.*)\].*" % player_re, re.MULTILINE) def readSupportedGames(self): @@ -222,7 +222,7 @@ follow : whether to tail -f the input""" # Also works with Omaha hands. cards = m.group('NEWCARDS') cards = set(cards.split(' ')) - hand.addHoleCards(cards, m.group('PNAME')) + hand.addHoleCards(cards, m.group('PNAME'), shown=False, mucked=False) def readDrawCards(self, hand, street): logging.debug("readDrawCards") @@ -314,9 +314,15 @@ follow : whether to tail -f the input""" def readShownCards(self,hand): for m in self.re_ShownCards.finditer(hand.handText): if m.group('CARDS') is not None: + print "SHOWED", m.group('SHOWED') cards = m.group('CARDS') cards = set(cards.split(' ')) - hand.addShownCards(cards=cards, player=m.group('PNAME')) + + (shown, mucked) = (False, False) + if m.group('SHOWED') == "showed": shown = True + elif m.group('SHOWED') == "mucked": mucked = True + + hand.addShownCards(cards=cards, player=m.group('PNAME'), shown=shown, mucked=mucked) if __name__ == "__main__": parser = OptionParser() From 0636a290f7a24eeebee311f3687488cc65540de8 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 3 Jul 2009 19:28:32 -0400 Subject: [PATCH 6/7] Get mixed game info and put it in gameType structure. --- pyfpdb/PokerStarsToFpdb.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 154d2b9d..8719a8c0 100755 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -26,7 +26,7 @@ from HandHistoryConverter import * class PokerStars(HandHistoryConverter): # Static regexes - re_GameInfo = re.compile("PokerStars Game #(?P[0-9]+):\s+(HORSE)? \(?(?PHold\'em|Razz|7 Card Stud|7 Card Stud Hi/Lo|Omaha|Omaha Hi/Lo|Badugi) (?PNo Limit|Limit|Pot Limit),? \(?(?P\$|)?(?P[.0-9]+)/\$?(?P[.0-9]+)\) - (?P.*$)", re.MULTILINE) + re_GameInfo = re.compile("PokerStars Game #(?P[0-9]+):\s+(?PHORSE|8\-Game|HOSE)? \(?(?PHold\'em|Razz|7 Card Stud|7 Card Stud Hi/Lo|Omaha|Omaha Hi/Lo|Badugi) (?PNo Limit|Limit|Pot Limit),? \(?(?P\$|)?(?P[.0-9]+)/\$?(?P[.0-9]+)\) - (?P.*$)", re.MULTILINE) re_SplitHands = re.compile('\n\n+') re_TailSplitHands = re.compile('(\n\n\n+)') re_HandInfo = re.compile("^Table \'(?P[- a-zA-Z]+)\'(?P.+?$)?", re.MULTILINE) @@ -89,6 +89,7 @@ follow : whether to tail -f the input""" # translations from captured groups to our info strings limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl' } + mixes = { 'HORSE': 'horse', '8-Game': '8game', 'HOSE': 'hose'} games = { # base, category "Hold'em" : ('hold','holdem'), 'Omaha' : ('hold','omahahi'), @@ -109,6 +110,8 @@ follow : whether to tail -f the input""" info['bb'] = mg['BB'] if 'CURRENCY' in mg: info['currency'] = currencies[mg['CURRENCY']] + if 'MIXED' in mg: + info['mixedType'] = mixes[mg['MIXED']] # NB: SB, BB must be interpreted as blinds or bets depending on limit type. return info From 23a4ca34c8a6ecd54b9fba5617856fc0e0c90a1c Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 3 Jul 2009 20:41:08 -0400 Subject: [PATCH 7/7] Fix bug preventing some shown cards from being read. --- pyfpdb/PokerStarsToFpdb.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 8719a8c0..75609001 100755 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -66,8 +66,7 @@ follow : whether to tail -f the input""" self.re_ShowdownAction = re.compile(r"^%s: shows \[(?P.*)\]" % player_re, re.MULTILINE) self.re_CollectPot = re.compile(r"Seat (?P[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$(?P[.\d]+)\)(, mucked| with.*|)" % player_re, re.MULTILINE) self.re_sitsOut = re.compile("^%s sits out" % player_re, re.MULTILINE) - self.re_ShownCards = re.compile("^Seat (?P[0-9]+): %s \(.*\) (?Pshowed|mucked) \[(?P.*)\].*" % player_re, re.MULTILINE) - + self.re_ShownCards = re.compile("^Seat (?P[0-9]+): %s (\(.*\) )?(?Pshowed|mucked) \[(?P.*)\].*" % player_re, re.MULTILINE) def readSupportedGames(self): return [["ring", "hold", "nl"], @@ -317,7 +316,6 @@ follow : whether to tail -f the input""" def readShownCards(self,hand): for m in self.re_ShownCards.finditer(hand.handText): if m.group('CARDS') is not None: - print "SHOWED", m.group('SHOWED') cards = m.group('CARDS') cards = set(cards.split(' '))