Make Hand initable without a hhc

Proof of concept code in test_PokerStars.py
This commit is contained in:
Worros 2009-03-14 23:01:40 +09:00
parent d847a71c6e
commit faf19215e8
3 changed files with 75 additions and 56 deletions

View File

@ -399,25 +399,28 @@ class HoldemOmahaHand(Hand):
#Populate a HoldemOmahaHand #Populate a HoldemOmahaHand
#Generally, we call 'read' methods here, which get the info according to the particular filter (hhc) #Generally, we call 'read' methods here, which get the info according to the particular filter (hhc)
# which then invokes a 'addXXX' callback # which then invokes a 'addXXX' callback
hhc.readHandInfo(self) if builtFrom == "HHC":
hhc.readPlayerStacks(self) hhc.readHandInfo(self)
hhc.compilePlayerRegexs(self) hhc.readPlayerStacks(self)
hhc.markStreets(self) hhc.compilePlayerRegexs(self)
hhc.readBlinds(self) hhc.markStreets(self)
hhc.readButton(self) hhc.readBlinds(self)
hhc.readHeroCards(self) hhc.readButton(self)
hhc.readShowdownActions(self) hhc.readHeroCards(self)
# Read actions in street order hhc.readShowdownActions(self)
for street in self.communityStreets: # Read actions in street order
if self.streets[street]: for street in self.communityStreets:
hhc.readCommunityCards(self, street) if self.streets[street]:
for street in self.actionStreets: hhc.readCommunityCards(self, street)
if self.streets[street]: for street in self.actionStreets:
hhc.readAction(self, street) if self.streets[street]:
hhc.readCollectPot(self) hhc.readAction(self, street)
hhc.readShownCards(self) hhc.readCollectPot(self)
self.totalPot() # finalise it (total the pot) hhc.readShownCards(self)
hhc.getRake(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): def addHoleCards(self, cards, player, shown=False):
"""\ """\
@ -553,24 +556,26 @@ class DrawHand(Hand):
self.sb = gametype['sb'] self.sb = gametype['sb']
self.bb = gametype['bb'] self.bb = gametype['bb']
# Populate the draw hand. # Populate the draw hand.
hhc.readHandInfo(self) if builtFrom == "HHC":
hhc.readPlayerStacks(self) hhc.readHandInfo(self)
hhc.compilePlayerRegexs(self) hhc.readPlayerStacks(self)
hhc.markStreets(self) hhc.compilePlayerRegexs(self)
hhc.readBlinds(self) hhc.markStreets(self)
hhc.readButton(self) hhc.readBlinds(self)
hhc.readShowdownActions(self) hhc.readButton(self)
# Read actions in street order hhc.readShowdownActions(self)
for street in self.streetList: # Read actions in street order
if self.streets[street]: for street in self.streetList:
# hhc.readCommunityCards(self, street) if self.streets[street]:
hhc.readDrawCards(self, street) # hhc.readCommunityCards(self, street)
hhc.readAction(self, street) hhc.readDrawCards(self, street)
hhc.readCollectPot(self) hhc.readAction(self, street)
hhc.readShownCards(self) hhc.readCollectPot(self)
self.totalPot() # finalise it (total the pot) hhc.readShownCards(self)
hhc.getRake(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 # Draw games (at least Badugi has blinds - override default Holdem addBlind
def addBlind(self, player, blindtype, amount): def addBlind(self, player, blindtype, amount):
@ -733,24 +738,27 @@ class StudHand(Hand):
#Populate the StudHand #Populate the StudHand
#Generally, we call a 'read' method here, which gets the info according to the particular filter (hhc) #Generally, we call a 'read' method here, which gets the info according to the particular filter (hhc)
# which then invokes a 'addXXX' callback # which then invokes a 'addXXX' callback
hhc.readHandInfo(self) if builtFrom == "HHC":
hhc.readPlayerStacks(self) hhc.readHandInfo(self)
hhc.compilePlayerRegexs(self) hhc.readPlayerStacks(self)
hhc.markStreets(self) hhc.compilePlayerRegexs(self)
hhc.readAntes(self) hhc.markStreets(self)
hhc.readBringIn(self) hhc.readAntes(self)
# hhc.readShowdownActions(self) # not done yet hhc.readBringIn(self)
# Read actions in street order #hhc.readShowdownActions(self) # not done yet
for street in self.streetList: # Read actions in street order
if self.streets[street]: for street in self.streetList:
logging.debug(street) if self.streets[street]:
logging.debug(self.streets[street]) logging.debug(street)
hhc.readStudPlayerCards(self, street) logging.debug(self.streets[street])
hhc.readAction(self, street) hhc.readStudPlayerCards(self, street)
hhc.readCollectPot(self) hhc.readAction(self, street)
# hhc.readShownCards(self) # not done yet hhc.readCollectPot(self)
self.totalPot() # finalise it (total the pot) #hhc.readShownCards(self) # not done yet
hhc.getRake(self) 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=[]): def addPlayerCards(self, player, street, open=[], closed=[]):
"""\ """\

View File

@ -1,10 +1,21 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import PokerStarsToFpdb import PokerStarsToFpdb
from Hand import *
import py import py
#regression-test-files/stars/badugi/ring-fl-badugi.txt #regression-test-files/stars/badugi/ring-fl-badugi.txt
# s0rrow: start $30.00 end: $22.65 total: ($7.35) # 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): def checkGameInfo(hhc, header, info):
assert hhc.determineGameType(header) == info assert hhc.determineGameType(header) == info