#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright 2008-2010, Carl Gherardi # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ######################################################################## import L10n _ = L10n.get_translation() # TODO: straighten out discards for draw games import sys from HandHistoryConverter import * from decimal_wrapper import Decimal # PokerStars HH Format class PokerStars(HandHistoryConverter): # Class Variables sitename = "PokerStars" filetype = "text" codepage = ("utf8", "cp1252") siteId = 2 # Needs to match id entry in Sites database mixes = { 'HORSE': 'horse', '8-Game': '8game', 'HOSE': 'hose'} # Legal mixed games sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\xe2\x82\xac", "GBP": "\xa3", "play": ""} # ADD Euro, Sterling, etc HERE substitutions = { 'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes 'LS' : "\$|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8) } # translations from captured groups to fpdb info strings Lim_Blinds = { '0.04': ('0.01', '0.02'), '0.10': ('0.02', '0.05'), '0.20': ('0.05', '0.10'), '0.40': ('0.10', '0.20'), '0.50': ('0.10', '0.25'), '1.00': ('0.25', '0.50'), '1': ('0.25', '0.50'), '2.00': ('0.50', '1.00'), '2': ('0.50', '1.00'), '4.00': ('1.00', '2.00'), '4': ('1.00', '2.00'), '6.00': ('1.00', '3.00'), '6': ('1.00', '3.00'), '8.00': ('2.00', '4.00'), '8': ('2.00', '4.00'), '10.00': ('2.00', '5.00'), '10': ('2.00', '5.00'), '20.00': ('5.00', '10.00'), '20': ('5.00', '10.00'), '30.00': ('10.00', '15.00'), '30': ('10.00', '15.00'), '40.00': ('10.00', '20.00'), '40': ('10.00', '20.00'), '60.00': ('15.00', '30.00'), '60': ('15.00', '30.00'), '80.00': ('20.00', '40.00'), '80': ('20.00', '40.00'), '100.00': ('25.00', '50.00'), '100': ('25.00', '50.00'), '200.00': ('50.00', '100.00'), '200': ('50.00', '100.00'), '400.00': ('100.00', '200.00'), '400': ('100.00', '200.00'), '800.00': ('200.00', '400.00'), '800': ('200.00', '400.00'), '1000.00': ('250.00', '500.00'),'1000': ('250.00', '500.00') } limits = { 'No Limit':'nl', 'Pot Limit':'pl', 'Limit':'fl', 'LIMIT':'fl' } games = { # base, category "Hold'em" : ('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'), 'Single Draw 2-7 Lowball' : ('draw','27_1draw'), '5 Card Draw' : ('draw','fivedraw') } currencies = { u'€':'EUR', '$':'USD', '':'T$' } # Static regexes re_GameInfo = re.compile(u""" PokerStars(\sHome)?\sGame\s\#(?P[0-9]+):\s+ (\{.*\}\s+)?(Tournament\s\# # open paren of tournament info (?P\d+),\s # here's how I plan to use LS (?P(?P[%(LS)s\d\.]+)?\+?(?P[%(LS)s\d\.]+)?\+?(?P[%(LS)s\d\.]+)?\s?(?P%(LEGAL_ISO)s)?|Freeroll)\s+)? # close paren of tournament info (?PHORSE|8\-Game|HOSE|Mixed PLH/PLO)?\s?\(? (?PHold\'em|Razz|RAZZ|7\sCard\sStud|7\sCard\sStud\sHi/Lo|Omaha|Omaha\sHi/Lo|Badugi|Triple\sDraw\s2\-7\sLowball|Single\sDraw\s2\-7\sLowball|5\sCard\sDraw)\s (?PNo\sLimit|Limit|LIMIT|Pot\sLimit)\)?,?\s (-\s)? (Match.*)? #TODO: waiting for reply from user as to what this means (Level\s(?P[IVXLC]+)\s)? \(? # open paren of the stakes (?P%(LS)s|)? (?P[.0-9]+)/(%(LS)s)? (?P[.0-9]+) (?P\s-\s[%(LS)s\d\.]+\sCap\s-\s)? # Optional Cap part \s?(?P%(LEGAL_ISO)s)? \) # close paren of the stakes (?P\s\[AAMS\sID:\s[A-Z0-9]+\])? # AAMS ID: in .it HH's \s-\s (?P.*$) """ % substitutions, re.MULTILINE|re.VERBOSE) re_PlayerInfo = re.compile(u""" ^Seat\s(?P[0-9]+):\s (?P.*)\s \((%(LS)s)?(?P[.0-9]+)\sin\schips\)""" % substitutions, re.MULTILINE|re.VERBOSE) re_HandInfo = re.compile(""" ^Table\s\'(?P[-\ \#a-zA-Z\d]+)\'\s ((?P\d+)-max\s)? (?P\(Play\sMoney\)\s)? (Seat\s\#(?P
[ a-zA-Z]+) - \$?(?P[.0-9]+)/\$?(?P[.0-9]+) - (?P.*) - (?P
[0-9]+):(?P[0-9]+) ET - (?P[0-9]+)/(?P[0-9]+)/(?P[0-9]+)Table (?P
[ a-zA-Z]+)\nSeat (?P