def readAction(self, hand, street): #print "DEBUG: readAction (%s)" % street m = self.re_Action.finditer(hand.streets[street]) curr_pot = Decimal('0') for action in m: #print " DEBUG: %s %s" % (action.group('ATYPE'), action.groupdict()) player = self.playerNameFromSeatNo(action.group('PSEAT'), hand) if action.group('ATYPE') == 'BET': amount = Decimal(action.group('BET')) amountstr = "%.2f" % float(amount / 100) #Gah! BET can mean check, bet, call or raise... if action.group('BET') == '0': hand.addCheck(street, player) elif amount > 0 and curr_pot == 0: # Open curr_pot = amount hand.addBet(street, player, amountstr) elif Decimal(action.group('BET')) > 0 and curr_pot > 0: # Raise or call if amount > curr_pot: # Raise curr_pot = amount hand.addCallandRaise(street, player, amountstr) elif amount <= curr_pot: # Call hand.addCall(street, player, amountstr) elif action.group('ATYPE') in ('FOLD', 'SIT_OUT'): hand.addFold(street, player) else: log.debug( _("Unimplemented %s: '%s' '%s'") % ("readAction", action.group('PSEAT'), action.group('ATYPE')))
def startPhase(self, phase): if phase == "BLINDSANTES": return True if phase == "PREFLOP": return False if phase == "FLOP" and len(self.flop) == 0: return False if phase == "TURN" and len(self.turn) == 0: return False if phase == "RIVER" and len(self.river) == 0: return False for player in self.players.values(): player.justacted = False if player.chips > self.called: player.stack += player.chips - self.called player.chips = self.called self.pot += player.chips player.chips = Decimal(0) self.bet = Decimal(0) self.called = Decimal(0) if phase == "FLOP": self.showFlop = True elif phase == "TURN": self.showTurn = True elif phase == "RIVER": self.showRiver = True return True
def readBlinds(self, hand): liveBlind = True for a in self.re_PostSB.finditer(hand.handText): pname = self.unknownPlayer(hand, a.group('PNAME')) sb = self.clearMoneyString(a.group('SB')) if liveBlind: hand.addBlind(pname, 'small blind', sb) liveBlind = False else: # Post dead blinds as ante hand.addBlind(pname, 'secondsb', sb) if not hand.gametype['sb'] and self.skin in ('ActionPoker', 'GearPoker'): hand.gametype['sb'] = sb for a in self.re_PostBB.finditer(hand.handText): pname = self.unknownPlayer(hand, a.group('PNAME')) if a.group('BB') is not None: bb = self.clearMoneyString(a.group('BB')) elif hand.gametype['bb']: bb = hand.gametype['bb'] else: raise FpdbHandPartial("BetOnlineToFpdb.readBlinds: " + _("Partial hand history: 'No blind info'")) hand.addBlind(pname, 'big blind', bb) if not hand.gametype['bb'] and self.skin in ('ActionPoker', 'GearPoker'): hand.gametype['bb'] = bb for a in self.re_PostBoth.finditer(hand.handText): if a.group('SBBB')!='0.00': pname = self.unknownPlayer(hand, a.group('PNAME')) sbbb = self.clearMoneyString(a.group('SBBB')) amount = str(Decimal(sbbb) + Decimal(sbbb)/2) hand.addBlind(pname, 'both', amount) else: pname = self.unknownPlayer(hand, a.group('PNAME')) hand.addBlind(pname, 'secondsb', hand.gametype['sb']) self.fixBlinds(hand)
def readBlinds(self, hand): for a in self.re_PostSB.finditer(hand.handText): #print "DEBUG: found sb: '%s' '%s'" %(self.playerNameFromSeatNo(a.group('PSEAT'), hand), a.group('SB')) hand.addBlind(self.playerNameFromSeatNo(a.group('PSEAT'), hand), 'small blind', a.group('SB')) for a in self.re_PostBB.finditer(hand.handText): #print "DEBUG: found bb: '%s' '%s'" %(self.playerNameFromSeatNo(a.group('PSEAT'), hand), a.group('BB')) hand.addBlind(self.playerNameFromSeatNo(a.group('PSEAT'), hand), 'big blind', a.group('BB')) for a in self.re_PostBoth.finditer(hand.handText): bb = Decimal(self.info['bb']) amount = Decimal(a.group('SBBB')) if amount < bb: hand.addBlind( self.playerNameFromSeatNo(a.group('PSEAT'), hand), 'small blind', a.group('SBBB')) elif amount == bb: hand.addBlind( self.playerNameFromSeatNo(a.group('PSEAT'), hand), 'big blind', a.group('SBBB')) else: hand.addBlind( self.playerNameFromSeatNo(a.group('PSEAT'), hand), 'both', a.group('SBBB'))
def determineGameType(self, handText): m = self.re_Site.search(handText) if not m: tmp = handText[0:200] log.error(_("PokerTrackerToFpdb.determineGameType: '%s'") % tmp) raise FpdbParseError self.sitename = self.sites[m.group('SITE')][0] self.siteId = self.sites[m.group('SITE')][1] # Needs to match id entry in Sites database info = {} if self.sitename in ('iPoker', 'Merge'): m = self.re_GameInfo1.search(handText) elif self.sitename=='Everest': m = self.re_GameInfo2.search(handText) elif self.sitename == 'Microgaming': m = self.re_GameInfo3.search(handText) if not m: tmp = handText[0:200] log.error(_("PokerTrackerToFpdb.determineGameType: '%s'") % tmp) raise FpdbParseError mg = m.groupdict() #print 'DEBUG determineGameType', mg if 'LIMIT' in mg: info['limitType'] = self.limits[mg['LIMIT']] if 'GAME' in mg: (info['base'], info['category']) = self.games[mg['GAME']] if 'SB' in mg: info['sb'] = self.clearMoneyString(mg['SB']) if 'BB' in mg: info['bb'] = self.clearMoneyString(mg['BB']) if 'CURRENCY' in mg and mg['CURRENCY'] is not None: info['currency'] = self.currencies[mg['CURRENCY']] if 'MIXED' in mg: if mg['MIXED'] is not None: info['mix'] = self.mixes[mg['MIXED']] if 'TOUR' in mg and mg['TOUR'] is not None: info['type'] = 'tour' info['currency'] = 'T$' else: info['type'] = 'ring' if info['limitType'] == 'fl' and info['bb'] is not None: if info['type'] == 'ring': try: bb = self.clearMoneyString(mg['BB']) info['sb'] = self.Lim_Blinds[bb][0] info['bb'] = self.Lim_Blinds[bb][1] except KeyError: tmp = handText[0:200] log.error(_("PokerTrackerToFpdb.determineGameType: Lim_Blinds has no lookup for '%s' - '%s'") % (mg['BB'], tmp)) raise FpdbParseError else: sb = self.clearMoneyString(mg['SB']) info['sb'] = str((Decimal(sb)/2).quantize(Decimal("0.01"))) info['bb'] = str(Decimal(sb).quantize(Decimal("0.01"))) return info
def readBlinds(self, hand): for a in self.re_PostSB.finditer(hand.streets['PREFLOP']): hand.addBlind(a.group('PNAME'), 'small blind', self.clearMoneyString(a.group('SB'))) if not hand.gametype['sb']: hand.gametype['sb'] = self.clearMoneyString(a.group('SB')) for a in self.re_PostBB.finditer(hand.streets['PREFLOP']): if not hand.gametype['bb']: hand.gametype['bb'] = self.clearMoneyString(a.group('BB')) hand.addBlind(a.group('PNAME'), 'big blind', self.clearMoneyString(a.group('BB'))) for a in self.re_PostBoth.finditer(hand.streets['PREFLOP']): bb = Decimal(self.info['bb']) amount = Decimal(self.clearMoneyString(a.group('SBBB'))) if amount < bb: hand.addBlind(a.group('PNAME'), 'small blind', self.clearMoneyString(a.group('SBBB'))) elif amount == bb: hand.addBlind(a.group('PNAME'), 'big blind', self.clearMoneyString(a.group('SBBB'))) else: hand.addBlind(a.group('PNAME'), 'both', self.clearMoneyString(a.group('SBBB'))) # FIXME # The following should only trigger when a small blind is missing in a tournament, or the sb/bb is ALL_IN # see http://sourceforge.net/apps/mantisbt/fpdb/view.php?id=115 if hand.gametype['type'] == 'tour': if hand.gametype['sb'] == None and hand.gametype['bb'] == None: hand.gametype['sb'] = "1" hand.gametype['bb'] = "2" elif hand.gametype['sb'] == None: hand.gametype['sb'] = str(int(Decimal(hand.gametype['bb']))/2) elif hand.gametype['bb'] == None: hand.gametype['bb'] = str(int(Decimal(hand.gametype['sb']))*2) if int(Decimal(hand.gametype['bb']))/2 != int(Decimal(hand.gametype['sb'])): if int(Decimal(hand.gametype['bb']))/2 < int(Decimal(hand.gametype['sb'])): hand.gametype['bb'] = str(int(Decimal(hand.gametype['sb']))*2) else: hand.gametype['sb'] = str(int(Decimal(hand.gametype['bb']))/2)
def readCollectPot(self, hand): #Bovada walks are calculated incorrectly in converted PokerStars hands acts, bovadaUncalled = hand.actions.get('PREFLOP'), False if acts != None and len([a for a in acts if a[1] != 'folds']) == 0: m0 = self.re_Uncalled.search(hand.handText) if m0 and Decimal(m0.group('BET')) == Decimal(hand.bb): bovadaUncalled = True i = 0 pre, post = hand.handText.split('*** SUMMARY ***') if hand.runItTimes == 0: for m in self.re_CollectPot.finditer(post): if bovadaUncalled: hand.addCollectPot(player=m.group('PNAME'), pot=str(Decimal(m.group('POT')) * 2)) else: hand.addCollectPot(player=m.group('PNAME'), pot=m.group('POT')) i += 1 if i == 0: for m in self.re_CollectPot2.finditer(pre): if bovadaUncalled: hand.addCollectPot(player=m.group('PNAME'), pot=str(Decimal(m.group('POT')) * 2)) else: hand.addCollectPot(player=m.group('PNAME'), pot=m.group('POT'))
def readAction(self, hand, street): m = self.re_Action.finditer(hand.streets[street]) for action in m: acts = action.groupdict() #print "DEBUG: acts: %s" %acts if action.group('ATYPE') == ' folds': hand.addFold(street, action.group('PNAME')) elif action.group('ATYPE') == ' checks': if street == 'PREFLOP' and action.group('PNAME') not in [ p for (p, b) in hand.posted ]: both = str(Decimal(str(hand.bb)) + Decimal(str(hand.sb))) hand.addBlind(action.group('PNAME'), 'both', both) hand.addCheck(street, action.group('PNAME')) elif action.group('ATYPE') == ' calls': hand.addCall(street, action.group('PNAME'), self.clearMoneyString(action.group('BET'))) elif action.group('ATYPE') == ' raises': hand.addCallandRaise( street, action.group('PNAME'), self.clearMoneyString(action.group('BET'))) elif action.group('ATYPE') == ' bets': hand.addBet(street, action.group('PNAME'), self.clearMoneyString(action.group('BET'))) elif action.group('ATYPE') == ' goes all-in': hand.addAllIn(street, action.group('PNAME'), self.clearMoneyString(action.group('BET'))) else: print( _("DEBUG:") + " " + _("Unimplemented %s: '%s' '%s'") % ("readAction", action.group('PNAME'), action.group('ATYPE')))
def readBlinds(self, hand): for a in self.re_Action.finditer(hand.streets['PREFLOP']): if a.group('ATYPE') == '1': hand.addBlind(a.group('PNAME'), 'small blind', self.clearMoneyString(a.group('BET'))) if not hand.gametype['sb']: hand.gametype['sb'] = self.clearMoneyString(a.group('BET')) m = self.re_Action.finditer(hand.streets['PREFLOP']) blinds = {} for a in m: if a.group('ATYPE') == '2': blinds[int(a.group('ACT'))] = a.groupdict() for b in sorted(blinds.iterkeys()): type = 'big blind' blind = blinds[b] if not hand.gametype['bb']: hand.gametype['bb'] = self.clearMoneyString(blind['BET']) elif hand.gametype['sb']: bb = Decimal(hand.gametype['bb']) amount = Decimal(self.clearMoneyString(blind['BET'])) if amount > bb: type = 'both' hand.addBlind(blind['PNAME'], type, self.clearMoneyString(blind['BET'])) self.fixTourBlinds(hand)
def readBlinds(self, hand): hand.setUncalledBets(True) liveBlind, hand.allInBlind = True, False for a in self.re_PostSB.finditer(hand.handText): if a.group('PNAME') in hand.stacks: if liveBlind: hand.addBlind(a.group('PNAME'), 'small blind', self.clearMoneyString(a.group('SB'))) liveBlind = False else: # Post dead blinds as ante hand.addBlind(a.group('PNAME'), 'secondsb', self.clearMoneyString(a.group('SB'))) self.allInBlind(hand, 'PREFLOP', a, 'secondsb') else: log.error("PacificPokerToFpdb.readBlinds (SB): '%s', '%s' not in hand.stacks" % (hand.handid, a.group('PNAME'))) raise FpdbParseError for a in self.re_PostBB.finditer(hand.handText): if a.group('PNAME') in hand.stacks: hand.addBlind(a.group('PNAME'), 'big blind', self.clearMoneyString(a.group('BB'))) self.allInBlind(hand, 'PREFLOP', a, 'big blind') else: log.error("PacificPokerToFpdb.readBlinds (BB): '%s', '%s' not in hand.stacks" % (hand.handid, a.group('PNAME'))) raise FpdbParseError for a in self.re_PostBoth.finditer(hand.handText): if a.group('PNAME') in hand.stacks: if Decimal(self.clearMoneyString(a.group('BB')))>0: bb = self.clearMoneyString(a.group('BB')) sb = self.clearMoneyString(a.group('SB')) both = str(Decimal(bb) + Decimal(sb)) hand.addBlind(a.group('PNAME'), 'both', both) else: hand.addBlind(a.group('PNAME'), 'secondsb', self.clearMoneyString(a.group('SB'))) self.allInBlind(hand, 'PREFLOP', a, 'both') else: log.error("PacificPokerToFpdb.readBlinds (Both): '%s', '%s' not in hand.stacks" % (hand.handid, a.group('PNAME'))) raise FpdbParseError
def determineGameType(self, handText): info = {} m = self.re_GameInfo.search(handText) if not m: tmp = handText[0:200] log.error(_("PokerStarsToFpdb.determineGameType: '%s'") % tmp) raise FpdbParseError mg = m.groupdict() if 'LIMIT' in mg: info['limitType'] = self.limits[mg['LIMIT']] if 'GAME' in mg: (info['base'], info['category']) = self.games[mg['GAME']] if 'SB' in mg: info['sb'] = mg['SB'] if 'BB' in mg: info['bb'] = mg['BB'] if 'CURRENCY' in mg: info['currency'] = self.currencies[mg['CURRENCY']] if 'MIXED' in mg: if mg['MIXED'] is not None: info['mix'] = self.mixes[mg['MIXED']] if 'Zoom' in mg['TITLE']: info['fast'] = True else: info['fast'] = False if 'Home' in mg['TITLE']: info['homeGame'] = True else: info['homeGame'] = False if 'CAP' in mg and mg['CAP'] is not None: info['buyinType'] = 'cap' else: info['buyinType'] = 'regular' if 'TOURNO' in mg and mg['TOURNO'] is None: info['type'] = 'ring' else: info['type'] = 'tour' if not mg['CURRENCY'] and info['type'] == 'ring': info['currency'] = 'play' if info['limitType'] == 'fl' and info['bb'] is not None: if info['type'] == 'ring': try: info['sb'] = self.Lim_Blinds[mg['BB']][0] info['bb'] = self.Lim_Blinds[mg['BB']][1] except KeyError: tmp = handText[0:200] log.error( _("PokerStarsToFpdb.determineGameType: Lim_Blinds has no lookup for '%s' - '%s'" ) % (mg['BB'], tmp)) raise FpdbParseError else: info['sb'] = str( (Decimal(mg['SB']) / 2).quantize(Decimal("0.01"))) info['bb'] = str(Decimal(mg['SB']).quantize(Decimal("0.01"))) return info
def readAction(self, hand, street): if self.sitename != 'Microgaming': m = self.re_Action1.finditer(hand.streets[street]) else: m = self.re_Action2.finditer(hand.streets[street]) curr_pot = Decimal('0') for action in m: acts = action.groupdict() #print "DEBUG: acts: %s" %acts if action.group('ATYPE') in (' folds', ' Fold', ' folded'): hand.addFold(street, action.group('PNAME')) elif action.group('ATYPE') in (' checks', ' Check', ' checked'): hand.addCheck(street, action.group('PNAME')) elif action.group('ATYPE') in (' calls', ' Call', ' called'): hand.addCall(street, action.group('PNAME'), action.group('BET')) elif action.group('ATYPE') in (' raises', ' Raise', ' raised', ' raised to', ' Raise to'): amount = Decimal(self.clearMoneyString(action.group('BET'))) if self.sitename == 'Merge': hand.addRaiseTo(street, action.group('PNAME'), action.group('BET')) elif self.sitename == 'Microgaming' or action.group( 'ATYPE') == ' Raise to': hand.addCallandRaise(street, action.group('PNAME'), action.group('BET')) else: if curr_pot > amount: hand.addCall(street, action.group('PNAME'), action.group('BET')) #elif not action.group('RAISETO') and action.group('ATYPE')==' Raise': # hand.addRaiseBy( street, action.group('PNAME'), action.group('BET') ) else: hand.addRaiseTo(street, action.group('PNAME'), action.group('BET')) curr_pot = amount elif action.group('ATYPE') in (' bets', ' Bet', ' bet'): if self.sitename == 'Microgaming' and street in ('PREFLOP', 'THIRD', 'DEAL'): hand.addCallandRaise(street, action.group('PNAME'), action.group('BET')) else: hand.addBet(street, action.group('PNAME'), action.group('BET')) curr_pot = Decimal(self.clearMoneyString(action.group('BET'))) elif action.group('ATYPE') in (' Allin', ' went all-in'): amount = Decimal(self.clearMoneyString(action.group('BET'))) hand.addAllIn(street, action.group('PNAME'), action.group('BET')) if curr_pot > amount and curr_pot > Decimal( '0') and self.sitename == 'Microgaming': hand.setUncalledBets(False) curr_pot = amount else: log.debug( _("DEBUG:") + " " + _("Unimplemented %s: '%s' '%s'") % ("readAction", action.group('PNAME'), action.group('ATYPE')))
def determineGameType(self, handText): info = {} m = self.re_GameInfo.search(handText) if not m: tmp = handText[0:200] log.error(_("BovadaToFpdb.determineGameType: '%s'") % tmp) raise FpdbParseError m1 = self.re_Dealt.search(handText) m2 = self.re_Summary.search(handText) if not m1 or not m2: raise FpdbHandPartial("BovadaToFpdb.determineGameType: " + _("Partial hand history")) mg = m.groupdict() m = self.re_Stakes.search(self.in_path) if m: mg.update(m.groupdict()) if 'LIMIT' in mg: if not mg['LIMIT']: info['limitType'] = 'nl' else: info['limitType'] = self.limits[mg['LIMIT']] if 'GAME' in mg: (info['base'], info['category']) = self.games[mg['GAME']] if 'SB' in mg: info['sb'] = mg['SB'] if 'BB' in mg: info['bb'] = mg['BB'] if 'TOURNO' in mg and mg['TOURNO'] is not None: info['type'] = 'tour' info['currency'] = 'T$' else: info['type'] = 'ring' info['currency'] = 'USD' if 'CURRENCY' in mg and mg['CURRENCY'] is not None: info['currency'] = self.currencies[mg['CURRENCY']] if 'Zone' in mg['GAME']: info['fast'] = True else: info['fast'] = False if info['limitType'] == 'fl' and info['bb'] is not None: if info['type'] == 'ring': try: info['sb'] = self.Lim_Blinds[mg['BB']][0] info['bb'] = self.Lim_Blinds[mg['BB']][1] except KeyError: tmp = handText[0:200] log.error(_("PokerStarsToFpdb.determineGameType: Lim_Blinds has no lookup for '%s' - '%s'") % (mg['BB'], tmp)) raise FpdbParseError else: info['sb'] = str((Decimal(mg['SB'])/2).quantize(Decimal("0.01"))) info['bb'] = str(Decimal(mg['SB']).quantize(Decimal("0.01"))) return info
def determineGameType(self, handText): # Inspect the handText and return the gametype dict # gametype dict is: {'limitType': xxx, 'base': xxx, 'category': xxx} info = {} m = self.re_HandInfo.search(handText) if not m: tmp = handText[0:200] log.error(_("OnGameToFpdb.determineGameType: '%s'") % tmp) raise FpdbParseError mg = m.groupdict() #print "DEBUG: mg: %s" % mg info['type'] = 'ring' if mg['TOUR'] != None: if mg['TID'] != None: info['type'] = 'tour' else: raise FpdbHandPartial if 'CURRENCY' in mg and mg['CURRENCY'] != None: if 'MONEY' in mg and mg['MONEY']=='Play money': info['currency'] = 'play' else: info['currency'] = self.currencies[mg['CURRENCY']] if 'LIMIT' in mg: if mg['LIMIT'] in self.limits: info['limitType'] = self.limits[mg['LIMIT']] else: tmp = handText[0:200] log.error(_("OnGameToFpdb.determineGameType: Limit not found in '%s'") % tmp) raise FpdbParseError if 'GAME' in mg: (info['base'], info['category']) = self.games[mg['GAME']] if 'SB' in mg: info['sb'] = self.clearMoneyString(mg['SB']) if 'BB' in mg: info['bb'] = self.clearMoneyString(mg['BB']) if 'Strobe' in mg['TABLE']: info['fast'] = True else: info['fast'] = False if info['limitType'] == 'fl' and info['bb'] is not None: if info['type'] == 'ring': try: bb = self.clearMoneyString(mg['BB']) info['sb'] = self.Lim_Blinds[bb][0] info['bb'] = self.Lim_Blinds[bb][1] except KeyError: tmp = handText[0:200] log.error(_("OnGameToFpdb.determineGameType: Lim_Blinds has no lookup for '%s' - '%s'") % (bb, tmp)) raise FpdbParseError else: sb = self.clearMoneyString(mg['SB']) info['sb'] = str((Decimal(sb)/2).quantize(Decimal("0.01"))) info['bb'] = str(Decimal(sb).quantize(Decimal("0.01"))) return info
def readBlinds(self, hand): for a in self.re_PostXB.finditer(hand.handText): amount = "%.2f" % float(float(a.group('XB'))/100) #print "DEBUG: handid %s readBlinds amount: %s sb: %s bb: %s" % (hand.handid, amount, str(Decimal(self.info['sb'])), str(Decimal(self.info['bb']))) if Decimal(a.group('XB'))/100 == Decimal(self.info['sb']): hand.addBlind(self.playerNameFromSeatNo(a.group('PSEAT'), hand),'small blind', amount) elif Decimal(a.group('XB'))/100 == Decimal(self.info['bb']): hand.addBlind(self.playerNameFromSeatNo(a.group('PSEAT'), hand),'big blind', amount)
def determineGameType(self, handText): info = {} m = self.re_GameInfo.search(handText) if not m: if self.re_Finished.search(handText): raise FpdbHandPartial if self.re_Dealer.match(handText): raise FpdbHandPartial tmp = handText[0:200] log.error(_("CakeToFpdb.determineGameType: '%s'") % tmp) raise FpdbParseError mg = m.groupdict() #print "DEBUG: mg: %s" % mg if 'LIMIT' in mg: info['limitType'] = self.limits[mg['LIMIT']] if 'GAME' in mg: (info['base'], info['category']) = self.games[mg['GAME']] if 'BB' in mg: if not mg['BB']: info['bb'] = self.clearMoneyString(mg['SBBB']) else: info['bb'] = self.clearMoneyString(mg['BB']) if 'SBBB' in mg: if not mg['BB']: info['sb'] = self.clearMoneyString(mg['ANTESB']) else: info['sb'] = self.clearMoneyString(mg['SBBB']) if 'CURRENCY' in mg: info['currency'] = self.currencies[mg['CURRENCY']] if 'MIXED' in mg: if mg['MIXED'] is not None: info['mix'] = self.mixes[mg['MIXED']] if 'TOURNO' in mg and mg['TOURNO'] is not None: info['type'] = 'tour' else: info['type'] = 'ring' if 'TABLE' in mg and 'Play Money' in mg['TABLE']: info['currency'] = 'play' if info['limitType'] == 'fl' and info['bb'] is not None: if info['type'] == 'ring': try: info['sb'] = self.Lim_Blinds[info['bb']][0] info['bb'] = self.Lim_Blinds[info['bb']][1] except KeyError: tmp = handText[0:200] log.error( _("CakeToFpdb.determineGameType: Lim_Blinds has no lookup for '%s' - '%s'" ) % (mg['BB'], tmp)) raise FpdbParseError else: info['sb'] = str( (Decimal(info['sb']) / 2).quantize(Decimal("0.01"))) info['bb'] = str(Decimal(info['sb']).quantize(Decimal("0.01"))) return info
def readCollectPot(self,hand): hand.adjustCollected = True for m in self.re_CollectPot.finditer(hand.handText): hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT')) for m in self.re_TotalPot.finditer(hand.handText): if hand.rakes.get('pot'): hand.rakes['pot'] += Decimal(self.clearMoneyString(m.group('POT'))) else: hand.rakes['pot'] = Decimal(self.clearMoneyString(m.group('POT')))
def determineGameType(self, handText): info = {} m = self.re_GameInfo.search(handText) if not m: # BetOnline starts writing the hh the moment you sit down. # Test if the hh contains the join line, and throw a partial if so. m2 = self.re_JoinsTable.search(handText) if not m2: tmp = handText[0:200] log.error(_("BetOnlineToFpdb.determineGameType: '%s'") % tmp) raise FpdbParseError else: raise FpdbHandPartial("BetOnlineToFpdb.determineGameType: " + _("Partial hand history: 'Player joining table'")) mg = m.groupdict() if mg['LIMIT']: info['limitType'] = self.limits[mg['LIMIT']] if info['limitType']=='pl': m = self.re_HeroCards.search(handText) if m and len(m.group('NEWCARDS').split(' '))==4: (info['base'], info['category']) = self.games['Omaha'] else: info['limitType'] = self.limits['No Limit'] if 'SKIN' in mg: self.skin = self.skins[mg['SKIN']] if 'GAME' in mg and not info.get('base'): (info['base'], info['category']) = self.games[mg['GAME']] if 'SB' in mg: info['sb'] = self.clearMoneyString(mg['SB']) if 'BB' in mg: info['bb'] = self.clearMoneyString(mg['BB']) if 'CURRENCY' in mg and mg['CURRENCY'] is not None: info['currency'] = self.currencies[mg['CURRENCY']] else: info['currency'] = 'USD' if 'MIXED' in mg: if mg['MIXED'] is not None: info['mix'] = self.mixes[mg['MIXED']] if 'TOURNO' in mg and mg['TOURNO'] is None: info['type'] = 'ring' else: info['type'] = 'tour' if info['limitType'] == 'fl' and info['bb'] is not None: if info['type'] == 'ring': try: info['sb'] = self.Lim_Blinds[info['BB']][0] info['bb'] = self.Lim_Blinds[info['BB']][1] except KeyError: tmp = handText[0:200] log.error(_("BetOnlineToFpdb.determineGameType: Lim_Blinds has no lookup for '%s' - '%s'") % (mg['BB'], tmp)) raise FpdbParseError else: info['sb'] = str((Decimal(info['SB'])/2).quantize(Decimal("0.01"))) info['bb'] = str(Decimal(info['SB']).quantize(Decimal("0.01"))) return info
def adjustMergeTourneyStack(self, hand, player, amount): amount = Decimal(amount) if hand.gametype['type'] == 'tour': for p in hand.players: if p[1] == player: stack = Decimal(p[2]) stack += amount p[2] = str(stack) hand.stacks[player] += amount
def endHand(self, collectees): self.pot = Decimal(0) for player in self.players.values(): player.justacted = False player.chips = Decimal(0) for name,amount in collectees.items(): player = self.players[name] player.chips += amount player.action = "collected" player.justacted = True
def adjustMergeTourneyStack(self, hand, player, amount): if self.sitename == 'Merge': amount = Decimal(self.clearMoneyString(amount)) if hand.gametype['type'] == 'tour': for p in hand.players: if p[1] == player: stack = Decimal(p[2]) stack += amount p[2] = str(stack) hand.stacks[player] += amount
def __init__(self, hand, name, stack, seat): self.stack = Decimal(stack) self.chips = Decimal(0) self.seat = seat self.name = name self.action = None self.justacted = False self.holecards = hand.join_holecards(name) self.x = 0.5 * math.cos(2 * self.seat * math.pi / hand.maxseats) self.y = 0.5 * math.sin(2 * self.seat * math.pi / hand.maxseats)
def determineGameType(self, handText): # Inspect the handText and return the gametype dict # gametype dict is: {'limitType': xxx, 'base': xxx, 'category': xxx} info = {} m = self.re_HandInfo.search(handText) if not m: tmp = handText[0:200] log.error(_("WinamaxToFpdb.determineGameType: '%s'") % tmp) raise FpdbParseError mg = m.groupdict() if mg.get('TOUR'): info['type'] = 'tour' info['currency'] = 'T$' elif mg.get('RING'): info['type'] = 'ring' if mg.get('MONEY'): info['currency'] = 'EUR' else: info['currency'] = 'play' if 'Go Fast' in mg.get('RING'): info['fast'] = True else: info['fast'] = False if 'LIMIT' in mg: if mg['LIMIT'] in self.limits: info['limitType'] = self.limits[mg['LIMIT']] else: tmp = handText[0:100] log.error( _("WinamaxToFpdb.determineGameType: Limit not found in %s." ) % tmp) raise FpdbParseError if 'GAME' in mg: (info['base'], info['category']) = self.games[mg['GAME']] m = self.re_Mixed.search(self.in_path) if m: info['mix'] = self.mixes[m.groupdict()['MIXED']] if 'SB' in mg: info['sb'] = mg['SB'] if 'BB' in mg: info['bb'] = mg['BB'] if info['limitType'] == 'fl' and info['bb'] is not None: info['sb'] = str((Decimal(mg['SB']) / 2).quantize(Decimal("0.01"))) info['bb'] = str(Decimal(mg['SB']).quantize(Decimal("0.01"))) return info
def readCollectPot(self, hand): pots = [Decimal(0) for n in range(hand.maxseats)] for m in self.re_CollectPot.finditer(hand.handText): pots[int(m.group('PSEAT'))] += Decimal(m.group('POT')) # Regarding the processing logic for "committed", see Pot.end() in # Hand.py committed = sorted([(v, k) for (k, v) in hand.pot.committed.items()]) for p in range(hand.maxseats): pname = self.playerNameFromSeatNo(p, hand) if committed[-1][1] == pname: pots[p] -= committed[-1][0] - committed[-2][0] if pots[p] > 0: hand.addCollectPot(player=pname, pot=pots[p])
def readTourneyResults(self, hand): """This function is not called. A recent patch broke the ability for the Stars parser to fetch tourney results from hh's. As the current Stars client supports writing tourney results files directly to the client machine i'm removing the ability to parse tourney results from hh files until we merge/resolve IdentifySite into the parsing despatch sequence""" for winningrankone in self.re_WinningRankOne.finditer(hand.handText): hand.addPlayerRank (winningrankone.group('PNAME'),int(100*Decimal(winningrankone.group('AMT'))),1) for winningrankothers in self.re_WinningRankOther.finditer(hand.handText): hand.addPlayerRank (winningrankothers.group('PNAME'),int(100*Decimal(winningrankothers.group('AMT'))),winningrankothers.group('RANK')) for rankothers in self.re_RankOther.finditer(hand.handText): hand.addPlayerRank (rankothers.group('PNAME'),0,rankothers.group('RANK'))
def determineGameType(self, handText): info = {} m = self.re_GameInfo.search(handText) if not m: tmp = handText[0:200] log.error(_("EnetToFpdb.determineGameType: '%s'") % tmp) raise FpdbParseError mg = m.groupdict() info['limitType'] = 'pl' #if 'LIMIT' in mg: # info['limitType'] = self.limits[mg['LIMIT']] if 'GAME' in mg: (info['base'], info['category']) = self.games[mg['GAME']] if 'SB' in mg: info['sb'] = self.clearMoneyString(mg['SB']) if 'BB' in mg: info['bb'] = self.clearMoneyString(mg['BB']) if 'CURRENCY' in mg: info['currency'] = self.currencies[mg['CURRENCY']] if 'TOURNO' in mg and mg['TOURNO'] is None: info['type'] = 'ring' else: info['type'] = 'tour' if not mg['CURRENCY'] and info['type'] == 'ring': info['currency'] = 'play' if info['limitType'] == 'fl' and info['bb'] is not None: if info['type'] == 'ring': try: info['sb'] = self.Lim_Blinds[self.clearMoneyString( mg['BB'])][0] info['bb'] = self.Lim_Blinds[self.clearMoneyString( mg['BB'])][1] except KeyError: tmp = handText[0:200] log.error( _("EnetToFpdb.determineGameType: Lim_Blinds has no lookup for '%s' - '%s'" ) % (mg['BB'], tmp)) raise FpdbParseError else: info['sb'] = str( (Decimal(self.clearMoneyString(mg['SB'])) / 2).quantize( Decimal("0.01"))) info['bb'] = str( Decimal(self.clearMoneyString(mg['SB'])).quantize( Decimal("0.01"))) return info
def readTourneyName(self, tourneyName, matchNo=None): entryId = 1 n = self.re_TourneyExtraInfo.search(tourneyName) if n.group('SNG') is not None: self.isSng = True if "Rush" in tourneyName: self.isFast = True if "On Demand" in tourneyName: self.isOnDemand = True if n.group('SPECIAL') is not None: special = n.group('SPECIAL') if special == "Rebuy": self.isRebuy = True elif special == "KO": self.isKO = True elif re.search("Matrix", special): self.isMatrix = True if matchNo != None: entryId = int(matchNo) else: entryId = 5 elif special == "Shootout": self.isShootout = True elif special in ('Heads Up', 'Heads-Up', 'Head\'s Up'): self.maxseats = 2 if n.group('SPEED1') is not None: if n.group('SPEED1') == 'Super Turbo': self.speed = 'Hyper' else: self.speed = n.group('SPEED1') if n.group('SPEED2') is not None: if n.group('SPEED2') == 'Super Turbo': self.speed = 'Hyper' else: self.speed = n.group('SPEED2') if n.group('GUARANTEE') != None: self.isGuarantee = True if self.isGuarantee and n.group('BUYINGUAR') != None: self.guaranteeAmt = int( 100 * Decimal(self.clearMoneyString(n.group('BUYINGUAR')))) if n.group('STEP') != None: self.isStep = True if n.group('STEPNO') != None: self.stepNo = int(n.group('STEPNO')) if self.isMatrix: self.buyin = self.prizepool / self.entries buyinfee = int( 100 * Decimal(self.clearMoneyString(n.group('BUYINGUAR')))) self.fee = buyinfee - self.buyin self.isSng = True return entryId
def endHand(self, collectees, returned): self.pot = Decimal(0) for player in self.players.values(): player.justacted = False player.chips = Decimal(0) if self.gamebase == 'draw': player.holecards = player.streetcards[self.street] for name, amount in collectees.items(): player = self.players[name] player.chips += amount player.action = "collected" player.justacted = True for name, amount in returned.items(): self.players[name].stack += amount
def readCollectPot(self,hand): if self.re_CollectPot2.search(hand.handText) and Card.games[hand.gametype['category']][2] == 's': re_CollectPot = self.re_CollectPot2 else: re_CollectPot = self.re_CollectPot1 for m in re_CollectPot.finditer(hand.handText): collect, pot = m.groupdict(), 0 if 'POT1' in collect and collect['POT1']!=None: pot += Decimal(self.clearMoneyString(collect['POT1'])) if 'POT2' in collect and collect['POT2']!=None: pot += Decimal(self.clearMoneyString(collect['POT2'])) if pot>0: player = self.playerSeatFromPosition('BovadaToFpdb.readCollectPot', hand.handid, collect['PNAME']) hand.addCollectPot(player=player,pot=str(pot))
def fixTourBlinds(self, hand, allinBlinds): # FIXME # The following should only trigger when a small blind is missing in a tournament, or the sb/bb is ALL_IN # see http://sourceforge.net/apps/mantisbt/fpdb/view.php?id=115 if hand.gametype['type'] == 'tour' or hand.gametype['secondGame']: if hand.gametype['sb'] == None and hand.gametype['bb'] == None: hand.gametype['sb'] = "1" hand.gametype['bb'] = "2" elif hand.gametype['sb'] == None: hand.gametype['sb'] = str( int(Decimal(hand.gametype['bb'])) / 2) elif hand.gametype['bb'] == None: hand.gametype['bb'] = str( int(Decimal(hand.gametype['sb'])) * 2) if int(Decimal(hand.gametype['bb'])) / 2 != int( Decimal(hand.gametype['sb'])): if int(Decimal(hand.gametype['bb'])) / 2 < int( Decimal(hand.gametype['sb'])): hand.gametype['bb'] = str( int(Decimal(hand.gametype['sb'])) * 2) else: hand.gametype['sb'] = str( int(Decimal(hand.gametype['bb'])) / 2) hand.sb = hand.gametype['sb'] hand.bb = hand.gametype['bb'] for player, blindtype in allinBlinds.iteritems(): if blindtype == 'big blind': self.adjustMergeTourneyStack(hand, player, hand.bb) hand.addBlind(player, 'big blind', hand.bb) else: self.adjustMergeTourneyStack(hand, player, hand.sb) hand.addBlind(player, 'small blind', hand.sb)