From 5f425e0910077f6fe8e855251cebf1534a013a5f Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 20 Aug 2010 17:59:52 +0800 Subject: [PATCH] OnGame: Fix determineGameType Assumes that its a cash game at the moment, and needs some love for non-limit holdem --- pyfpdb/OnGameToFpdb.py | 63 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/pyfpdb/OnGameToFpdb.py b/pyfpdb/OnGameToFpdb.py index d9c069a7..5f8e1683 100755 --- a/pyfpdb/OnGameToFpdb.py +++ b/pyfpdb/OnGameToFpdb.py @@ -43,14 +43,44 @@ class OnGame(HandHistoryConverter): codepage = ("utf8", "cp1252") siteId = 5 # Needs to match id entry in Sites database + substitutions = { + 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes + 'LS' : "\$|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8) + } + + limits = { 'NO LIMIT':'nl', 'LIMIT':'fl'} + + games = { # base, category + "TEXAS_HOLDEM" : ('hold','holdem'), + # 'Omaha' : ('hold','omahahi'), + # 'Omaha Hi/Lo' : ('hold','omahahilo'), + # 'Razz' : ('stud','razz'), + # 'RAZZ' : ('stud','razz'), + # '7 Card Stud' : ('stud','studhi'), + # '7 Card Stud Hi/Lo' : ('stud','studhilo'), + # 'Badugi' : ('draw','badugi'), + # 'Triple Draw 2-7 Lowball' : ('draw','27_3draw'), + # '5 Card Draw' : ('draw','fivedraw') + } + #self.rexx.setGameInfoRegex('.*Blinds \$?(?P[.0-9]+)/\$?(?P[.0-9]+)') # Static regexes re_SplitHands = re.compile('\n\n\n+') - - #Texas Hold'em $.5-$1 NL (real money), hand #P4-76915775-797 - #Table Kuopio, 20 Sep 2008 11:59 PM - re_HandInfo = re.compile(r"Texas Hold'em \$?(?P[.0-9]+)-\$?(?P[.0-9]+) NL \(real money\), hand #(?P[-A-Z\d]+)\nTable\ (?P[\' \w]+), (?P\d\d \w+ \d\d\d\d \d\d:\d\d (AM|PM))") - # SB BB HID TABLE DAY MON YEAR HR12 MIN AMPM + + # ***** History for hand R5-75443872-57 ***** + # Start hand: Wed Aug 18 19:29:10 GMT+0100 2010 + # Table: someplace [75443872] (LIMIT TEXAS_HOLDEM 0.50/1, Real money) + re_HandInfo = re.compile(u""" + \*\*\*\*\*\sHistory\sfor\shand\s(?P[-A-Z\d]+).* + Start\shand:\s(?P.*) + Table:\s(?P
[\'\w]+)\s\[\d+\]\s\( + ( + (?PNo\sLimit|Limit|LIMIT|Pot\sLimit)\s + (?PTEXAS_HOLDEM|RAZZ)\s + (?P[.0-9]+)/ + (?P[.0-9]+) + )? + """ % substitutions, re.MULTILINE|re.DOTALL|re.VERBOSE) # self.rexx.button_re = re.compile('#SUMMARY\nDealer: (?P.*)\n') @@ -80,8 +110,9 @@ class OnGame(HandHistoryConverter): pass def determineGameType(self, handText): - # Cheating with this regex, only support nlhe at the moment - gametype = ["ring", "hold", "nl"] + # 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: @@ -90,10 +121,20 @@ class OnGame(HandHistoryConverter): log.error(_("determineGameType: Raising FpdbParseError")) raise FpdbParseError(_("Unable to recognise gametype from: '%s'") % tmp) - gametype = gametype + [m.group('SB')] - gametype = gametype + [m.group('BB')] - - return gametype + mg = m.groupdict() + + info['type'] = 'ring' + + 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'] + + return info def readHandInfo(self, hand): m = self.re_HandInfo.search(hand.string)