From 0d5af4c9741f5f22a1940f6aeeb935fdead95a76 Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 16 Jul 2009 12:58:39 +0800 Subject: [PATCH] Make Win2day client use updated readHeroCards api --- pyfpdb/HandHistoryConverter.py | 2 +- pyfpdb/Win2dayToFpdb.py | 31 ++++++++++++++----------------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 16a89267..94ca5fec 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -173,6 +173,7 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py. def processHand(self, handText): gametype = self.determineGameType(handText) logging.debug("gametype %s" % gametype) + hand = None if gametype is None: l = None gametype = "unmatched" @@ -185,7 +186,6 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py. limit = gametype['limitType'] l = [type] + [base] + [limit] if l in self.readSupportedGames(): - hand = None if gametype['base'] == 'hold': logging.debug("hand = Hand.HoldemOmahaHand(self, self.sitename, gametype, handtext)") hand = Hand.HoldemOmahaHand(self, self.sitename, gametype, handText) diff --git a/pyfpdb/Win2dayToFpdb.py b/pyfpdb/Win2dayToFpdb.py index 0417dcb1..ab66ab5e 100755 --- a/pyfpdb/Win2dayToFpdb.py +++ b/pyfpdb/Win2dayToFpdb.py @@ -19,6 +19,7 @@ ######################################################################## import sys +import datetime from HandHistoryConverter import * # Win2day HH Format @@ -140,11 +141,7 @@ class Win2day(HandHistoryConverter): for key in info: if key == 'DATETIME': # Win2day uses UTC timestamp - # m2 = re.search("(?P[0-9]{4})\/(?P[0-9]{2})\/(?P[0-9]{2})[\- ]+(?P[0-9]+):(?P[0-9]+):(?P[0-9]+)", 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])) + hand.starttime = datetime.datetime.fromtimestamp(int(info[key])) if key == 'HID': hand.handid = info[key] if key == 'TABLE': @@ -225,18 +222,18 @@ class Win2day(HandHistoryConverter): hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB')) def readHeroCards(self, hand): - m = self.re_HeroCards.search(hand.handText) - if(m == None): - #Not involved in hand - hand.involved = False - else: +# streets PREFLOP, PREDRAW, and THIRD are special cases beacause +# we need to grab hero's cards + m = self.re_HeroCards.finditer(hand.streets['PREFLOP']) + newcards = [] + 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') - holeCards = set([]) - for card in self.re_Card.finditer(m.group('CARDS')): - holeCards.add(self.convertWin2dayCards(card.group('CARD'))) - - hand.addHoleCards(holeCards, m.group('PNAME')) + #hand.addHoleCards(holeCards, m.group('PNAME')) + hand.addHoleCards('PREFLOP', hand.hero, closed=newcards, shown=False, mucked=False, dealt=True) def convertWin2dayCards(self, card): card = int(card) @@ -346,7 +343,7 @@ class Win2day(HandHistoryConverter): for shows in self.re_ShowdownAction.finditer(hand.handText): showdownCards = set([]) 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'))) hand.addShownCards(showdownCards, shows.group('PNAME'))