From c53d78491ae31de50de5135f575240e2e277069b Mon Sep 17 00:00:00 2001 From: Worros Date: Sun, 9 Nov 2008 16:27:27 +1000 Subject: [PATCH] Minor update to Carbon poker - read gametype + sb/bb --- pyfpdb/CarbonToFpdb.py | 29 ++++++++++++++++++++++++----- pyfpdb/HandHistoryConverter.py | 19 +++++++++++++++++-- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/pyfpdb/CarbonToFpdb.py b/pyfpdb/CarbonToFpdb.py index 8282b3f2..cf9fc8d3 100644 --- a/pyfpdb/CarbonToFpdb.py +++ b/pyfpdb/CarbonToFpdb.py @@ -22,6 +22,7 @@ import Configuration import traceback import sys +import re import xml.dom.minidom from xml.dom.minidom import Node from HandHistoryConverter import HandHistoryConverter @@ -56,11 +57,29 @@ class CarbonPoker(HandHistoryConverter): def readSupportedGames(self): pass - def determineGameType(self): - desc_node = doc.getElementsByTagName("description") - type = desc_node.getAttribute("type") - stakes = desc_node.getAttribute("stakes") - + def determineGameType(self): + gametype = [] + desc_node = self.doc.getElementsByTagName("description") + #TODO: no examples of non ring type yet + gametype = gametype + ["ring"] + type = desc_node[0].getAttribute("type") + if(type == "Holdem"): + gametype = gametype + ["hold"] + else: + print "Unknown gametype: '%s'" % (type) + + stakes = desc_node[0].getAttribute("stakes") + #TODO: no examples of anything except nlhe + m = re.match('(?PNo Limit)\s\(\$?(?P[.0-9]+)/\$?(?P[.0-9]+)\)', stakes) + + if(m.group('LIMIT') == "No Limit"): + gametype = gametype + ["nl"] + + gametype = gametype + [self.float2int(m.group('SB'))] + gametype = gametype + [self.float2int(m.group('BB'))] + + return gametype + def readPlayerStacks(self): pass def readBlinds(self): diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 6b7c8a76..ec1308cd 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -49,7 +49,7 @@ class HandHistoryConverter: tmp = tmp + "\tgametype: '%s'\n" % (self.gametype[0]) tmp = tmp + "\tgamebase: '%s'\n" % (self.gametype[1]) tmp = tmp + "\tlimit: '%s'\n" % (self.gametype[2]) - tmp = tmp + "\tsb/bb: '%s'\n" % (self.gametype[3], self.gametype[4]) + tmp = tmp + "\tsb/bb: '%s/%s'\n" % (self.gametype[3], self.gametype[4]) return tmp # Functions to be implemented in the inheriting class @@ -94,7 +94,7 @@ class HandHistoryConverter: print "Cowardly refusing to continue after failed sanity check" return self.readFile(self.file) - gametype = self.determineGameType() + self.gametype = self.determineGameType() def readFile(self, filename): """Read file""" @@ -133,3 +133,18 @@ class HandHistoryConverter: # ## SUMMARY STUFF +#takes a poker float (including , for thousand seperator and converts it to an int + def float2int (self, string): + pos=string.find(",") + if (pos!=-1): #remove , the thousand seperator + string=string[0:pos]+string[pos+1:] + + pos=string.find(".") + if (pos!=-1): #remove decimal point + string=string[0:pos]+string[pos+1:] + + result = int(string) + if pos==-1: #no decimal point - was in full dollars - need to multiply with 100 + result*=100 + return result +#end def float2int