From faf19215e84f5c3198afef97a3f3a76330ab4b64 Mon Sep 17 00:00:00 2001 From: Worros Date: Sat, 14 Mar 2009 23:01:40 +0900 Subject: [PATCH] Make Hand initable without a hhc Proof of concept code in test_PokerStars.py --- pyfpdb/Hand.py | 118 ++++++++++++++++++++----------------- pyfpdb/PokerStarsToFpdb.py | 2 +- pyfpdb/test_PokerStars.py | 11 ++++ 3 files changed, 75 insertions(+), 56 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index b7bd5a4c..65d0e175 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -399,25 +399,28 @@ class HoldemOmahaHand(Hand): #Populate a HoldemOmahaHand #Generally, we call 'read' methods here, which get the info according to the particular filter (hhc) # which then invokes a 'addXXX' callback - hhc.readHandInfo(self) - hhc.readPlayerStacks(self) - hhc.compilePlayerRegexs(self) - hhc.markStreets(self) - hhc.readBlinds(self) - hhc.readButton(self) - hhc.readHeroCards(self) - hhc.readShowdownActions(self) - # Read actions in street order - for street in self.communityStreets: - if self.streets[street]: - hhc.readCommunityCards(self, street) - for street in self.actionStreets: - if self.streets[street]: - hhc.readAction(self, street) - hhc.readCollectPot(self) - hhc.readShownCards(self) - self.totalPot() # finalise it (total the pot) - hhc.getRake(self) + if builtFrom == "HHC": + hhc.readHandInfo(self) + hhc.readPlayerStacks(self) + hhc.compilePlayerRegexs(self) + hhc.markStreets(self) + hhc.readBlinds(self) + hhc.readButton(self) + hhc.readHeroCards(self) + hhc.readShowdownActions(self) + # Read actions in street order + for street in self.communityStreets: + if self.streets[street]: + hhc.readCommunityCards(self, street) + for street in self.actionStreets: + if self.streets[street]: + hhc.readAction(self, street) + hhc.readCollectPot(self) + hhc.readShownCards(self) + self.totalPot() # finalise it (total the pot) + hhc.getRake(self) + elif builtFrom == "DB": + self.select("dummy") # Will need a handId def addHoleCards(self, cards, player, shown=False): """\ @@ -553,24 +556,26 @@ class DrawHand(Hand): self.sb = gametype['sb'] self.bb = gametype['bb'] # Populate the draw hand. - hhc.readHandInfo(self) - hhc.readPlayerStacks(self) - hhc.compilePlayerRegexs(self) - hhc.markStreets(self) - hhc.readBlinds(self) - hhc.readButton(self) - hhc.readShowdownActions(self) - # Read actions in street order - for street in self.streetList: - if self.streets[street]: - # hhc.readCommunityCards(self, street) - hhc.readDrawCards(self, street) - hhc.readAction(self, street) - hhc.readCollectPot(self) - hhc.readShownCards(self) - self.totalPot() # finalise it (total the pot) - hhc.getRake(self) - + if builtFrom == "HHC": + hhc.readHandInfo(self) + hhc.readPlayerStacks(self) + hhc.compilePlayerRegexs(self) + hhc.markStreets(self) + hhc.readBlinds(self) + hhc.readButton(self) + hhc.readShowdownActions(self) + # Read actions in street order + for street in self.streetList: + if self.streets[street]: + # hhc.readCommunityCards(self, street) + hhc.readDrawCards(self, street) + hhc.readAction(self, street) + hhc.readCollectPot(self) + hhc.readShownCards(self) + self.totalPot() # finalise it (total the pot) + hhc.getRake(self) + elif builtFrom == "DB": + self.select("dummy") # Will need a handId # Draw games (at least Badugi has blinds - override default Holdem addBlind def addBlind(self, player, blindtype, amount): @@ -733,24 +738,27 @@ class StudHand(Hand): #Populate the StudHand #Generally, we call a 'read' method here, which gets the info according to the particular filter (hhc) # which then invokes a 'addXXX' callback - hhc.readHandInfo(self) - hhc.readPlayerStacks(self) - hhc.compilePlayerRegexs(self) - hhc.markStreets(self) - hhc.readAntes(self) - hhc.readBringIn(self) -# hhc.readShowdownActions(self) # not done yet - # Read actions in street order - for street in self.streetList: - if self.streets[street]: - logging.debug(street) - logging.debug(self.streets[street]) - hhc.readStudPlayerCards(self, street) - hhc.readAction(self, street) - hhc.readCollectPot(self) -# hhc.readShownCards(self) # not done yet - self.totalPot() # finalise it (total the pot) - hhc.getRake(self) + if builtFrom == "HHC": + hhc.readHandInfo(self) + hhc.readPlayerStacks(self) + hhc.compilePlayerRegexs(self) + hhc.markStreets(self) + hhc.readAntes(self) + hhc.readBringIn(self) + #hhc.readShowdownActions(self) # not done yet + # Read actions in street order + for street in self.streetList: + if self.streets[street]: + logging.debug(street) + logging.debug(self.streets[street]) + hhc.readStudPlayerCards(self, street) + hhc.readAction(self, street) + hhc.readCollectPot(self) + #hhc.readShownCards(self) # not done yet + self.totalPot() # finalise it (total the pot) + hhc.getRake(self) + elif builtFrom == "DB": + self.select("dummy") # Will need a handId def addPlayerCards(self, player, street, open=[], closed=[]): """\ diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 3d5ff83d..1915bb42 100755 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -46,7 +46,7 @@ follow : whether to tail -f the input""" if autostart: self.start() - + def compilePlayerRegexs(self, hand): players = set([player[1] for player in hand.players]) if not players <= self.compiledPlayers: # x <= y means 'x is subset of y' diff --git a/pyfpdb/test_PokerStars.py b/pyfpdb/test_PokerStars.py index e2d3925d..85107e6f 100644 --- a/pyfpdb/test_PokerStars.py +++ b/pyfpdb/test_PokerStars.py @@ -1,10 +1,21 @@ # -*- coding: utf-8 -*- import PokerStarsToFpdb +from Hand import * import py #regression-test-files/stars/badugi/ring-fl-badugi.txt # s0rrow: start $30.00 end: $22.65 total: ($7.35) +gametype = {'type':'ring', 'base':'draw', 'category':'badugi', 'limitType':'fl', 'sb':'0.25', 'bb':'0.50','currency':'USD'} +text = "" + +hhc = PokerStarsToFpdb.PokerStars(autostart=False) + +h = HoldemOmahaHand(None, "ASite", gametype, text, builtFrom = "Test") +h.addPlayer("1", "s0rrow", "100000") + +hhc.compilePlayerRegexs(h) + def checkGameInfo(hhc, header, info): assert hhc.determineGameType(header) == info