Minor update to Carbon poker - read gametype + sb/bb
This commit is contained in:
parent
43f8620dea
commit
c53d78491a
|
@ -22,6 +22,7 @@
|
||||||
import Configuration
|
import Configuration
|
||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
|
import re
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
from xml.dom.minidom import Node
|
from xml.dom.minidom import Node
|
||||||
from HandHistoryConverter import HandHistoryConverter
|
from HandHistoryConverter import HandHistoryConverter
|
||||||
|
@ -56,11 +57,29 @@ class CarbonPoker(HandHistoryConverter):
|
||||||
|
|
||||||
def readSupportedGames(self):
|
def readSupportedGames(self):
|
||||||
pass
|
pass
|
||||||
def determineGameType(self):
|
def determineGameType(self):
|
||||||
desc_node = doc.getElementsByTagName("description")
|
gametype = []
|
||||||
type = desc_node.getAttribute("type")
|
desc_node = self.doc.getElementsByTagName("description")
|
||||||
stakes = desc_node.getAttribute("stakes")
|
#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('(?P<LIMIT>No Limit)\s\(\$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.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):
|
def readPlayerStacks(self):
|
||||||
pass
|
pass
|
||||||
def readBlinds(self):
|
def readBlinds(self):
|
||||||
|
|
|
@ -49,7 +49,7 @@ class HandHistoryConverter:
|
||||||
tmp = tmp + "\tgametype: '%s'\n" % (self.gametype[0])
|
tmp = tmp + "\tgametype: '%s'\n" % (self.gametype[0])
|
||||||
tmp = tmp + "\tgamebase: '%s'\n" % (self.gametype[1])
|
tmp = tmp + "\tgamebase: '%s'\n" % (self.gametype[1])
|
||||||
tmp = tmp + "\tlimit: '%s'\n" % (self.gametype[2])
|
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
|
return tmp
|
||||||
|
|
||||||
# Functions to be implemented in the inheriting class
|
# Functions to be implemented in the inheriting class
|
||||||
|
@ -94,7 +94,7 @@ class HandHistoryConverter:
|
||||||
print "Cowardly refusing to continue after failed sanity check"
|
print "Cowardly refusing to continue after failed sanity check"
|
||||||
return
|
return
|
||||||
self.readFile(self.file)
|
self.readFile(self.file)
|
||||||
gametype = self.determineGameType()
|
self.gametype = self.determineGameType()
|
||||||
|
|
||||||
def readFile(self, filename):
|
def readFile(self, filename):
|
||||||
"""Read file"""
|
"""Read file"""
|
||||||
|
@ -133,3 +133,18 @@ class HandHistoryConverter:
|
||||||
#
|
#
|
||||||
## SUMMARY STUFF
|
## 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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user