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 traceback
|
||||
import sys
|
||||
import re
|
||||
import xml.dom.minidom
|
||||
from xml.dom.minidom import Node
|
||||
from HandHistoryConverter import HandHistoryConverter
|
||||
|
@ -57,9 +58,27 @@ 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")
|
||||
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('(?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):
|
||||
pass
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user