Make Win2day client use updated readHeroCards api

This commit is contained in:
Worros 2009-07-16 12:58:39 +08:00
parent d8df3ea11a
commit 0d5af4c974
2 changed files with 15 additions and 18 deletions

View File

@ -173,6 +173,7 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py.
def processHand(self, handText): def processHand(self, handText):
gametype = self.determineGameType(handText) gametype = self.determineGameType(handText)
logging.debug("gametype %s" % gametype) logging.debug("gametype %s" % gametype)
hand = None
if gametype is None: if gametype is None:
l = None l = None
gametype = "unmatched" gametype = "unmatched"
@ -185,7 +186,6 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py.
limit = gametype['limitType'] limit = gametype['limitType']
l = [type] + [base] + [limit] l = [type] + [base] + [limit]
if l in self.readSupportedGames(): if l in self.readSupportedGames():
hand = None
if gametype['base'] == 'hold': if gametype['base'] == 'hold':
logging.debug("hand = Hand.HoldemOmahaHand(self, self.sitename, gametype, handtext)") logging.debug("hand = Hand.HoldemOmahaHand(self, self.sitename, gametype, handtext)")
hand = Hand.HoldemOmahaHand(self, self.sitename, gametype, handText) hand = Hand.HoldemOmahaHand(self, self.sitename, gametype, handText)

View File

@ -19,6 +19,7 @@
######################################################################## ########################################################################
import sys import sys
import datetime
from HandHistoryConverter import * from HandHistoryConverter import *
# Win2day HH Format # Win2day HH Format
@ -140,11 +141,7 @@ class Win2day(HandHistoryConverter):
for key in info: for key in info:
if key == 'DATETIME': if key == 'DATETIME':
# Win2day uses UTC timestamp # Win2day uses UTC timestamp
# m2 = re.search("(?P<Y>[0-9]{4})\/(?P<M>[0-9]{2})\/(?P<D>[0-9]{2})[\- ]+(?P<H>[0-9]+):(?P<MIN>[0-9]+):(?P<S>[0-9]+)", info[key]) hand.starttime = datetime.datetime.fromtimestamp(int(info[key]))
# datetime = "%s/%s/%s %s:%s:%s" % (m2.group('Y'), m2.group('M'),m2.group('D'),m2.group('H'),m2.group('MIN'),m2.group('S'))
# hand.starttime = time.strptime(time.gmtime(info[key]))
# hand.starttime = time.gmtime(int(info[key]))
hand.starttime = time.gmtime(int(info[key]))
if key == 'HID': if key == 'HID':
hand.handid = info[key] hand.handid = info[key]
if key == 'TABLE': if key == 'TABLE':
@ -225,18 +222,18 @@ class Win2day(HandHistoryConverter):
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB')) hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB'))
def readHeroCards(self, hand): def readHeroCards(self, hand):
m = self.re_HeroCards.search(hand.handText) # streets PREFLOP, PREDRAW, and THIRD are special cases beacause
if(m == None): # we need to grab hero's cards
#Not involved in hand m = self.re_HeroCards.finditer(hand.streets['PREFLOP'])
hand.involved = False newcards = []
else: for found in m:
hand.hero = found.group('PNAME')
for card in self.re_Card.finditer(found.group('CARDS')):
print self.convertWin2dayCards(card.group('CARD'))
newcards.append(self.convertWin2dayCards(card.group('CARD')))
hand.hero = m.group('PNAME') #hand.addHoleCards(holeCards, m.group('PNAME'))
holeCards = set([]) hand.addHoleCards('PREFLOP', hand.hero, closed=newcards, shown=False, mucked=False, dealt=True)
for card in self.re_Card.finditer(m.group('CARDS')):
holeCards.add(self.convertWin2dayCards(card.group('CARD')))
hand.addHoleCards(holeCards, m.group('PNAME'))
def convertWin2dayCards(self, card): def convertWin2dayCards(self, card):
card = int(card) card = int(card)
@ -346,7 +343,7 @@ class Win2day(HandHistoryConverter):
for shows in self.re_ShowdownAction.finditer(hand.handText): for shows in self.re_ShowdownAction.finditer(hand.handText):
showdownCards = set([]) showdownCards = set([])
for card in self.re_Card.finditer(shows.group('CARDS')): for card in self.re_Card.finditer(shows.group('CARDS')):
print "DEBUG:", card, card.group('CARD'), self.convertWin2dayCards(card.group('CARD')) #print "DEBUG:", card, card.group('CARD'), self.convertWin2dayCards(card.group('CARD'))
showdownCards.add(self.convertWin2dayCards(card.group('CARD'))) showdownCards.add(self.convertWin2dayCards(card.group('CARD')))
hand.addShownCards(showdownCards, shows.group('PNAME')) hand.addShownCards(showdownCards, shows.group('PNAME'))