Rationalized holecards for stud and draw games.
Cards are now lists of cards rather than sets. Removed some game-specific methods and replaced with general methods. Let the superclass handle some stuff.
This commit is contained in:
parent
3234f89aad
commit
dd1b442122
180
pyfpdb/Hand.py
180
pyfpdb/Hand.py
|
@ -15,6 +15,8 @@
|
||||||
#In the "official" distribution you can find the license in
|
#In the "official" distribution you can find the license in
|
||||||
#agpl-3.0.txt in the docs folder of the package.
|
#agpl-3.0.txt in the docs folder of the package.
|
||||||
|
|
||||||
|
# TODO: get writehand() encoding correct
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -147,7 +149,7 @@ shown whether they were revealed at showdown
|
||||||
mucked whether they were mucked at showdown
|
mucked whether they were mucked at showdown
|
||||||
dealt whether they were seen in a 'dealt to' line
|
dealt whether they were seen in a 'dealt to' line
|
||||||
"""
|
"""
|
||||||
logging.debug("addHoleCards %s %s" % (open + closed, player))
|
# logging.debug("addHoleCards %s %s" % (open + closed, player))
|
||||||
try:
|
try:
|
||||||
self.checkPlayerExists(player)
|
self.checkPlayerExists(player)
|
||||||
except FpdbParseError, e:
|
except FpdbParseError, e:
|
||||||
|
@ -158,7 +160,6 @@ dealt whether they were seen in a 'dealt to' line
|
||||||
if shown: self.shown.add(player)
|
if shown: self.shown.add(player)
|
||||||
if mucked: self.mucked.add(player)
|
if mucked: self.mucked.add(player)
|
||||||
|
|
||||||
print "stuff =", street, player, open, closed
|
|
||||||
self.holecards[street][player] = [open, closed]
|
self.holecards[street][player] = [open, closed]
|
||||||
|
|
||||||
def insert(self, db):
|
def insert(self, db):
|
||||||
|
@ -808,12 +809,13 @@ class DrawHand(Hand):
|
||||||
hhc.markStreets(self)
|
hhc.markStreets(self)
|
||||||
hhc.readBlinds(self)
|
hhc.readBlinds(self)
|
||||||
hhc.readButton(self)
|
hhc.readButton(self)
|
||||||
|
hhc.readHeroCards(self)
|
||||||
hhc.readShowdownActions(self)
|
hhc.readShowdownActions(self)
|
||||||
# Read actions in street order
|
# Read actions in street order
|
||||||
for street in self.streetList:
|
for street in self.streetList:
|
||||||
if self.streets[street]:
|
if self.streets[street]:
|
||||||
# hhc.readCommunityCards(self, street)
|
# hhc.readCommunityCards(self, street)
|
||||||
hhc.readDrawCards(self, street)
|
# hhc.readDrawCards(self, street)
|
||||||
hhc.readAction(self, street)
|
hhc.readAction(self, street)
|
||||||
hhc.readCollectPot(self)
|
hhc.readCollectPot(self)
|
||||||
hhc.readShownCards(self)
|
hhc.readShownCards(self)
|
||||||
|
@ -849,20 +851,28 @@ class DrawHand(Hand):
|
||||||
#print "DEBUG: self.posted: %s" %(self.posted)
|
#print "DEBUG: self.posted: %s" %(self.posted)
|
||||||
|
|
||||||
|
|
||||||
|
def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False):
|
||||||
|
if player == self.hero: # we have hero's cards just update shown/mucked
|
||||||
|
if shown: self.shown.add(player)
|
||||||
|
if mucked: self.mucked.add(player)
|
||||||
|
else:
|
||||||
|
# TODO: Probably better to find the last street with action and add the hole cards to that street
|
||||||
|
self.addHoleCards('DRAWTHREE', player, open=[], closed=cards, shown=shown, mucked=mucked, dealt=dealt)
|
||||||
|
|
||||||
def addDrawHoleCards(self, newcards, oldcards, player, street, shown=False):
|
|
||||||
"""\
|
# def addDrawHoleCards(self, newcards, oldcards, player, street, shown=False):
|
||||||
Assigns observed holecards to a player.
|
# """\
|
||||||
cards list of card bigrams e.g. ['2h','Jc']
|
#Assigns observed holecards to a player.
|
||||||
player (string) name of player
|
#cards list of card bigrams e.g. ['2h','Jc']
|
||||||
"""
|
#player (string) name of player
|
||||||
try:
|
#"""
|
||||||
self.checkPlayerExists(player)
|
# try:
|
||||||
# if shown and len(cardset) > 0:
|
# self.checkPlayerExists(player)
|
||||||
# self.shown.add(player)
|
## if shown and len(cardset) > 0:
|
||||||
self.holecards[street][player] = (newcards,oldcards)
|
## self.shown.add(player)
|
||||||
except FpdbParseError, e:
|
# self.holecards[street][player] = (newcards,oldcards)
|
||||||
print "[ERROR] Tried to add holecards for unknown player: %s" % (player,)
|
# except FpdbParseError, e:
|
||||||
|
# print "[ERROR] Tried to add holecards for unknown player: %s" % (player,)
|
||||||
|
|
||||||
|
|
||||||
def discardDrawHoleCards(self, cards, player, street):
|
def discardDrawHoleCards(self, cards, player, street):
|
||||||
|
@ -872,7 +882,6 @@ player (string) name of player
|
||||||
|
|
||||||
def addDiscard(self, street, player, num, cards):
|
def addDiscard(self, street, player, num, cards):
|
||||||
self.checkPlayerExists(player)
|
self.checkPlayerExists(player)
|
||||||
print "street, player, num, cards =", street, player, num, cards
|
|
||||||
if cards:
|
if cards:
|
||||||
act = (player, 'discards', num, cards)
|
act = (player, 'discards', num, cards)
|
||||||
self.discardDrawHoleCards(cards, player, street)
|
self.discardDrawHoleCards(cards, player, street)
|
||||||
|
@ -896,32 +905,32 @@ player (string) name of player
|
||||||
# self.addHoleCards(holeandboard.difference(board),player,shown=True)
|
# self.addHoleCards(holeandboard.difference(board),player,shown=True)
|
||||||
|
|
||||||
|
|
||||||
def addHoleCards(self, cards, player, shown, mucked, dealt=False):
|
# def addHoleCards(self, cards, player, shown, mucked, dealt=False):
|
||||||
"""\
|
# """\
|
||||||
Assigns observed holecards to a player.
|
#Assigns observed holecards to a player.
|
||||||
cards list of card bigrams e.g. ['2h','Jc']
|
#cards list of card bigrams e.g. ['2h','Jc']
|
||||||
player (string) name of player
|
#player (string) name of player
|
||||||
shown whether they were revealed at showdown
|
#shown whether they were revealed at showdown
|
||||||
mucked whether they were mucked at showdown
|
#mucked whether they were mucked at showdown
|
||||||
dealt whether they were seen in a 'dealt to' line
|
#dealt whether they were seen in a 'dealt to' line
|
||||||
"""
|
#"""
|
||||||
# I think this only gets called for shown cards.
|
## I think this only gets called for shown cards.
|
||||||
logging.debug("addHoleCards %s %s" % (cards, player))
|
# logging.debug("addHoleCards %s %s" % (cards, player))
|
||||||
try:
|
# try:
|
||||||
self.checkPlayerExists(player)
|
# self.checkPlayerExists(player)
|
||||||
except FpdbParseError, e:
|
# except FpdbParseError, e:
|
||||||
print "[ERROR] Tried to add holecards for unknown player: %s" % (player,)
|
# print "[ERROR] Tried to add holecards for unknown player: %s" % (player,)
|
||||||
return
|
# return
|
||||||
|
#
|
||||||
if dealt:
|
# if dealt:
|
||||||
self.dealt.add(player)
|
# self.dealt.add(player)
|
||||||
if shown:
|
# if shown:
|
||||||
self.shown.add(player)
|
# self.shown.add(player)
|
||||||
if mucked:
|
# if mucked:
|
||||||
self.mucked.add(player)
|
# self.mucked.add(player)
|
||||||
if player != self.hero: #skip hero, we know his cards
|
# if player != self.hero: #skip hero, we know his cards
|
||||||
print "player, cards =", player, cards
|
# print "player, cards =", player, cards
|
||||||
self.holecards[self.holeStreets[-1]][player] = (cards, set([]))
|
# self.holecards[self.holeStreets[-1]][player] = (cards, set([]))
|
||||||
|
|
||||||
def writeHand(self, fh=sys.__stdout__):
|
def writeHand(self, fh=sys.__stdout__):
|
||||||
# PokerStars format.
|
# PokerStars format.
|
||||||
|
@ -1023,13 +1032,14 @@ class StudHand(Hand):
|
||||||
hhc.markStreets(self)
|
hhc.markStreets(self)
|
||||||
hhc.readAntes(self)
|
hhc.readAntes(self)
|
||||||
hhc.readBringIn(self)
|
hhc.readBringIn(self)
|
||||||
|
hhc.readHeroCards(self)
|
||||||
#hhc.readShowdownActions(self) # not done yet
|
#hhc.readShowdownActions(self) # not done yet
|
||||||
# Read actions in street order
|
# Read actions in street order
|
||||||
for street in self.streetList:
|
for street in self.streetList:
|
||||||
if self.streets[street]:
|
if self.streets[street]:
|
||||||
logging.debug(street)
|
logging.debug(street)
|
||||||
logging.debug(self.streets[street])
|
logging.debug(self.streets[street])
|
||||||
hhc.readStudPlayerCards(self, street)
|
# hhc.readStudPlayerCards(self, street)
|
||||||
hhc.readAction(self, street)
|
hhc.readAction(self, street)
|
||||||
hhc.readCollectPot(self)
|
hhc.readCollectPot(self)
|
||||||
hhc.readShownCards(self) # not done yet
|
hhc.readShownCards(self) # not done yet
|
||||||
|
@ -1038,6 +1048,19 @@ class StudHand(Hand):
|
||||||
elif builtFrom == "DB":
|
elif builtFrom == "DB":
|
||||||
self.select("dummy") # Will need a handId
|
self.select("dummy") # Will need a handId
|
||||||
|
|
||||||
|
def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False):
|
||||||
|
if player == self.hero: # we have hero's cards just update shown/mucked
|
||||||
|
if shown: self.shown.add(player)
|
||||||
|
if mucked: self.mucked.add(player)
|
||||||
|
else:
|
||||||
|
# self.addHoleCards('PREFLOP', player, open=[], closed=cards, shown=shown, mucked=mucked, dealt=dealt)
|
||||||
|
self.addHoleCards('THIRD', player, open=[cards[2]], closed=cards[0:2], shown=shown, mucked=mucked)
|
||||||
|
self.addHoleCards('FOURTH', player, open=[cards[3]], closed=[], shown=shown, mucked=mucked)
|
||||||
|
self.addHoleCards('FIFTH', player, open=[cards[4]], closed=[], shown=shown, mucked=mucked)
|
||||||
|
self.addHoleCards('SIXTH', player, open=[cards[5]], closed=[], shown=shown, mucked=mucked)
|
||||||
|
self.addHoleCards('SEVENTH', player, open=[], closed=[cards[6]], shown=shown, mucked=mucked)
|
||||||
|
|
||||||
|
|
||||||
def addPlayerCards(self, player, street, open=[], closed=[]):
|
def addPlayerCards(self, player, street, open=[], closed=[]):
|
||||||
"""\
|
"""\
|
||||||
Assigns observed cards to a player.
|
Assigns observed cards to a player.
|
||||||
|
@ -1055,42 +1078,41 @@ closed likewise, but known only to player
|
||||||
except FpdbParseError, e:
|
except FpdbParseError, e:
|
||||||
print "[ERROR] Tried to add holecards for unknown player: %s" % (player,)
|
print "[ERROR] Tried to add holecards for unknown player: %s" % (player,)
|
||||||
|
|
||||||
def addHoleCards(self, cards, player, shown, mucked, dealt=False):
|
# def addHoleCards(self, cards, player, shown, mucked, dealt=False):
|
||||||
"""\
|
# """\
|
||||||
Assigns observed holecards to a player.
|
#Assigns observed holecards to a player.
|
||||||
cards list of card bigrams e.g. ['2h','Jc']
|
#cards list of card bigrams e.g. ['2h','Jc']
|
||||||
player (string) name of player
|
#player (string) name of player
|
||||||
shown whether they were revealed at showdown
|
#shown whether they were revealed at showdown
|
||||||
mucked whether they were mucked at showdown
|
#mucked whether they were mucked at showdown
|
||||||
dealt whether they were seen in a 'dealt to' line
|
#dealt whether they were seen in a 'dealt to' line
|
||||||
"""
|
#"""
|
||||||
|
##
|
||||||
|
## For stud games we just need to do the routine setting of shown/mucked/etc
|
||||||
|
## and then update the cards 'THIRD' and 'SEVENTH'
|
||||||
|
# logging.debug("addHoleCards %s %s" % (cards, player))
|
||||||
|
# try:
|
||||||
|
# self.checkPlayerExists(player)
|
||||||
|
# except FpdbParseError, e:
|
||||||
|
# print "[ERROR] Tried to add holecards for unknown player: %s" % (player,)
|
||||||
|
# return
|
||||||
#
|
#
|
||||||
# For stud games we just need to do the routine setting of shown/mucked/etc
|
# if dealt:
|
||||||
# and then update the cards 'THIRD' and 'SEVENTH'
|
# self.dealt.add(player)
|
||||||
logging.debug("addHoleCards %s %s" % (cards, player))
|
# if shown:
|
||||||
try:
|
# self.shown.add(player)
|
||||||
self.checkPlayerExists(player)
|
# if mucked:
|
||||||
except FpdbParseError, e:
|
# self.mucked.add(player)
|
||||||
print "[ERROR] Tried to add holecards for unknown player: %s" % (player,)
|
# if player == self.hero:
|
||||||
return
|
# if len(cards) > 2:
|
||||||
|
# self.holecards['THIRD'][player] = ([cards[0:3]], [])
|
||||||
if dealt:
|
# if len(cards) > 6:
|
||||||
self.dealt.add(player)
|
# self.holecards['SEVENTH'][player] = ([cards[6]], [])
|
||||||
if shown:
|
# else:
|
||||||
self.shown.add(player)
|
# if len(cards) > 2:
|
||||||
if mucked:
|
# self.holecards['THIRD'][player] = ([cards[0]], cards[1:3])
|
||||||
self.mucked.add(player)
|
# if len(cards) > 6:
|
||||||
if player == self.hero:
|
# self.holecards['SEVENTH'][player] = ([], [cards[6]])
|
||||||
if len(cards) > 2:
|
|
||||||
self.holecards['THIRD'][player] = ([cards[0:3]], [])
|
|
||||||
if len(cards) > 6:
|
|
||||||
self.holecards['SEVENTH'][player] = ([cards[6]], [])
|
|
||||||
else:
|
|
||||||
if len(cards) > 2:
|
|
||||||
self.holecards['THIRD'][player] = ([cards[0]], cards[1:3])
|
|
||||||
if len(cards) > 6:
|
|
||||||
self.holecards['SEVENTH'][player] = ([], [cards[6]])
|
|
||||||
|
|
||||||
# TODO: def addComplete(self, player, amount):
|
# TODO: def addComplete(self, player, amount):
|
||||||
def addComplete(self, street, player, amountTo):
|
def addComplete(self, street, player, amountTo):
|
||||||
# assert street=='THIRD'
|
# assert street=='THIRD'
|
||||||
|
|
|
@ -18,18 +18,19 @@
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
|
# TODO: play money currency showing up as T$
|
||||||
|
# TODO: straighten out discards for draw games
|
||||||
import sys
|
import sys
|
||||||
from HandHistoryConverter import *
|
from HandHistoryConverter import *
|
||||||
|
|
||||||
# PokerStars HH Format
|
# PokerStars HH Format
|
||||||
|
|
||||||
# TODO: fix finding hero in stud games
|
|
||||||
# TODO: fix open/closed hole cards for stud games
|
|
||||||
|
|
||||||
class PokerStars(HandHistoryConverter):
|
class PokerStars(HandHistoryConverter):
|
||||||
|
|
||||||
|
############################################################
|
||||||
|
# Class Variables
|
||||||
|
|
||||||
# Static regexes
|
# Static regexes
|
||||||
# re_GameInfo = re.compile("PokerStars Game #(?P<HID>[0-9]+):\s+(?P<MIXED>HORSE|8\-Game|HOSE)? \(?(?P<GAME>Hold\'em|Razz|7 Card Stud|7 Card Stud Hi/Lo|Omaha|Omaha Hi/Lo|Badugi) (?P<LIMIT>No Limit|Limit|Pot Limit),? \(?(?P<CURRENCY>\$|)?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+)\) - (?P<DATETIME>.*$)", re.MULTILINE)
|
|
||||||
re_GameInfo = re.compile("""PokerStars\sGame\s\#(?P<HID>[0-9]+):\s+
|
re_GameInfo = re.compile("""PokerStars\sGame\s\#(?P<HID>[0-9]+):\s+
|
||||||
(Tournament\s\#(?P<TOURNO>\d+),\s(?P<BUYIN>[\$\+\d\.]+)\s)?
|
(Tournament\s\#(?P<TOURNO>\d+),\s(?P<BUYIN>[\$\+\d\.]+)\s)?
|
||||||
(?P<MIXED>HORSE|8\-Game|HOSE)?\s?\(?
|
(?P<MIXED>HORSE|8\-Game|HOSE)?\s?\(?
|
||||||
|
@ -71,6 +72,9 @@ follow : whether to tail -f the input"""
|
||||||
players = set([player[1] for player in hand.players])
|
players = set([player[1] for player in hand.players])
|
||||||
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
||||||
# we need to recompile the player regexs.
|
# we need to recompile the player regexs.
|
||||||
|
# TODO: should probably rename re_HeroCards and corresponding method,
|
||||||
|
# since they are used to find all cards on lines starting with "Dealt to:"
|
||||||
|
# They still identify the hero.
|
||||||
self.compiledPlayers = players
|
self.compiledPlayers = players
|
||||||
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
|
player_re = "(?P<PNAME>" + "|".join(map(re.escape, players)) + ")"
|
||||||
logging.debug("player_re: " + player_re)
|
logging.debug("player_re: " + player_re)
|
||||||
|
@ -80,14 +84,12 @@ follow : whether to tail -f the input"""
|
||||||
self.re_BringIn = re.compile(r"^%s: brings[- ]in( low|) for \$?(?P<BRINGIN>[.0-9]+)" % player_re, re.MULTILINE)
|
self.re_BringIn = re.compile(r"^%s: brings[- ]in( low|) for \$?(?P<BRINGIN>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
self.re_PostBoth = re.compile(r"^%s: posts small \& big blinds \[\$? (?P<SBBB>[.0-9]+)" % player_re, re.MULTILINE)
|
self.re_PostBoth = re.compile(r"^%s: posts small \& big blinds \[\$? (?P<SBBB>[.0-9]+)" % player_re, re.MULTILINE)
|
||||||
self.re_HeroCards = re.compile(r"^Dealt to %s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % player_re, re.MULTILINE)
|
self.re_HeroCards = re.compile(r"^Dealt to %s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % player_re, re.MULTILINE)
|
||||||
# self.re_DealToCards = re.compile(r"^Dealt to %s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % player_re, re.MULTILINE)
|
|
||||||
# self.re_Action = re.compile(r"^%s:(?P<ATYPE> bets| checks| raises| calls| folds| discards| stands pat)( \$?(?P<BET>[.\d]+))?( to \$?(?P<BETTO>[.\d]+))?( (?P<NODISCARDED>\d) cards?( \[(?P<DISCARDED>.+?)\])?)?" % player_re, re.MULTILINE)
|
|
||||||
self.re_Action = re.compile(r"""^%s:(?P<ATYPE>\sbets|\schecks|\sraises|\scalls|\sfolds|\sdiscards|\sstands\spat)
|
self.re_Action = re.compile(r"""^%s:(?P<ATYPE>\sbets|\schecks|\sraises|\scalls|\sfolds|\sdiscards|\sstands\spat)
|
||||||
(\s\$?(?P<BET>[.\d]+))?(\sto\s\$?(?P<BETTO>[.\d]+))? # the number discarded goes in <BET>
|
(\s\$?(?P<BET>[.\d]+))?(\sto\s\$?(?P<BETTO>[.\d]+))? # the number discarded goes in <BET>
|
||||||
(\scards?(\s\[(?P<DISCARDED>.+?)\])?)?"""
|
(\scards?(\s\[(?P<DISCARDED>.+?)\])?)?"""
|
||||||
% player_re, re.MULTILINE|re.VERBOSE)
|
% player_re, re.MULTILINE|re.VERBOSE)
|
||||||
self.re_ShowdownAction = re.compile(r"^%s: shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
self.re_ShowdownAction = re.compile(r"^%s: shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
||||||
self.re_CollectPot = re.compile(r"Seat (?P<SEAT>[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$(?P<POT>[.\d]+)\)(, mucked| with.*|)" % player_re, re.MULTILINE)
|
self.re_CollectPot = re.compile(r"Seat (?P<SEAT>[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$?(?P<POT>[.\d]+)\)(, mucked| with.*|)" % player_re, re.MULTILINE)
|
||||||
self.re_sitsOut = re.compile("^%s sits out" % player_re, re.MULTILINE)
|
self.re_sitsOut = re.compile("^%s sits out" % player_re, re.MULTILINE)
|
||||||
self.re_ShownCards = re.compile("^Seat (?P<SEAT>[0-9]+): %s (\(.*\) )?(?P<SHOWED>showed|mucked) \[(?P<CARDS>.*)\].*" % player_re, re.MULTILINE)
|
self.re_ShownCards = re.compile("^Seat (?P<SEAT>[0-9]+): %s (\(.*\) )?(?P<SHOWED>showed|mucked) \[(?P<CARDS>.*)\].*" % player_re, re.MULTILINE)
|
||||||
|
|
||||||
|
@ -280,83 +282,96 @@ follow : whether to tail -f the input"""
|
||||||
# hand.addHoleCards(cards, m.group('PNAME'), shown=False, mucked=False, dealt=True)
|
# hand.addHoleCards(cards, m.group('PNAME'), shown=False, mucked=False, dealt=True)
|
||||||
|
|
||||||
def readHeroCards(self, hand):
|
def readHeroCards(self, hand):
|
||||||
# streets PREFLOP, PREDRAW, and THIRD are special cases
|
# streets PREFLOP, PREDRAW, and THIRD are special cases beacause
|
||||||
for street in ('PREFLOP', 'PREDRAW'):
|
# we need to grab hero's cards
|
||||||
|
for street in ('PREFLOP', 'DEAL'):
|
||||||
if street in hand.streets.keys():
|
if street in hand.streets.keys():
|
||||||
print "text =", hand.streets[street]
|
m = self.re_HeroCards.finditer(hand.streets[street])
|
||||||
m = self.re_HeroCards.search(hand.streets[street])
|
for found in m:
|
||||||
if m == None:
|
# if m == None:
|
||||||
hand.involved = False
|
# hand.involved = False
|
||||||
else:
|
# else:
|
||||||
hand.hero = m.group('PNAME')
|
hand.hero = found.group('PNAME')
|
||||||
newcards = m.group('NEWCARDS').split(' ')
|
newcards = found.group('NEWCARDS').split(' ')
|
||||||
hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True)
|
hand.addHoleCards(street, hand.hero, closed=newcards, shown=False, mucked=False, dealt=True)
|
||||||
|
|
||||||
# def readHeroCards(self, hand):
|
for street, text in hand.streets.iteritems():
|
||||||
# for street, text in hand.streets.iteritems():
|
if street in ('PREFLOP', 'DEAL'): continue # already done these
|
||||||
# m = self.re_HeroCards.search(hand.handText)
|
m = self.re_HeroCards.finditer(hand.streets[street])
|
||||||
# if(m == None):
|
for found in m:
|
||||||
# #Not involved in hand
|
player = found.group('PNAME')
|
||||||
# hand.involved = False
|
if found.group('NEWCARDS') == None:
|
||||||
# else:
|
newcards = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def readDrawCards(self, hand, street):
|
|
||||||
logging.debug("readDrawCards")
|
|
||||||
m = self.re_HeroCards.finditer(hand.streets[street])
|
|
||||||
if m == None:
|
|
||||||
hand.involved = False
|
|
||||||
else:
|
|
||||||
for player in m:
|
|
||||||
hand.hero = player.group('PNAME') # Only really need to do this once
|
|
||||||
newcards = player.group('NEWCARDS')
|
|
||||||
oldcards = player.group('OLDCARDS')
|
|
||||||
if newcards == None:
|
|
||||||
newcards = set()
|
|
||||||
else:
|
else:
|
||||||
newcards = set(newcards.split(' '))
|
newcards = found.group('NEWCARDS').split(' ')
|
||||||
if oldcards == None:
|
if found.group('OLDCARDS') == None:
|
||||||
oldcards = set()
|
oldcards = []
|
||||||
else:
|
else:
|
||||||
oldcards = set(oldcards.split(' '))
|
oldcards = found.group('OLDCARDS').split(' ')
|
||||||
hand.addDrawHoleCards(newcards, oldcards, player.group('PNAME'), street)
|
|
||||||
|
if street == 'THIRD' and len(newcards) == 3: # hero in stud game
|
||||||
|
hand.hero = player
|
||||||
|
hand.dealt.add(player) # need this for stud??
|
||||||
|
hand.addHoleCards(street, player, closed=newcards[0:2], open=[newcards[2]], shown=False, mucked=False, dealt=False)
|
||||||
|
else:
|
||||||
|
hand.addHoleCards(street, player, open=newcards, closed=oldcards, shown=False, mucked=False, dealt=False)
|
||||||
|
|
||||||
|
|
||||||
|
# def readDrawCards(self, hand, street):
|
||||||
|
# logging.debug("readDrawCards")
|
||||||
|
# m = self.re_HeroCards.finditer(hand.streets[street])
|
||||||
|
# if m == None:
|
||||||
|
# hand.involved = False
|
||||||
|
# else:
|
||||||
|
# for player in m:
|
||||||
|
# hand.hero = player.group('PNAME') # Only really need to do this once
|
||||||
|
# newcards = player.group('NEWCARDS')
|
||||||
|
# oldcards = player.group('OLDCARDS')
|
||||||
|
# if newcards == None:
|
||||||
|
# newcards = set()
|
||||||
|
# else:
|
||||||
|
# newcards = set(newcards.split(' '))
|
||||||
|
# if oldcards == None:
|
||||||
|
# oldcards = set()
|
||||||
|
# else:
|
||||||
|
# oldcards = set(oldcards.split(' '))
|
||||||
|
# hand.addDrawHoleCards(newcards, oldcards, player.group('PNAME'), street)
|
||||||
|
|
||||||
|
|
||||||
def readStudPlayerCards(self, hand, street):
|
# def readStudPlayerCards(self, hand, street):
|
||||||
# See comments of reference implementation in FullTiltToFpdb.py
|
# # See comments of reference implementation in FullTiltToFpdb.py
|
||||||
logging.debug("readStudPlayerCards")
|
# logging.debug("readStudPlayerCards")
|
||||||
m = self.re_HeroCards.finditer(hand.streets[street])
|
# m = self.re_HeroCards.finditer(hand.streets[street])
|
||||||
for player in m:
|
# for player in m:
|
||||||
#~ logging.debug(player.groupdict())
|
# #~ logging.debug(player.groupdict())
|
||||||
(pname, oldcards, newcards) = (player.group('PNAME'), player.group('OLDCARDS'), player.group('NEWCARDS'))
|
# (pname, oldcards, newcards) = (player.group('PNAME'), player.group('OLDCARDS'), player.group('NEWCARDS'))
|
||||||
if oldcards:
|
# if oldcards:
|
||||||
oldcards = [c.strip() for c in oldcards.split(' ')]
|
# oldcards = [c.strip() for c in oldcards.split(' ')]
|
||||||
if newcards:
|
# if newcards:
|
||||||
newcards = [c.strip() for c in newcards.split(' ')]
|
# newcards = [c.strip() for c in newcards.split(' ')]
|
||||||
if street=='ANTES':
|
# if street=='ANTES':
|
||||||
return
|
# return
|
||||||
elif street=='THIRD':
|
# elif street=='THIRD':
|
||||||
# we'll have observed hero holecards in CARDS and thirdstreet open cards in 'NEWCARDS'
|
# # we'll have observed hero holecards in CARDS and thirdstreet open cards in 'NEWCARDS'
|
||||||
# hero: [xx][o]
|
# # hero: [xx][o]
|
||||||
# others: [o]
|
# # others: [o]
|
||||||
hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = oldcards, open = newcards)
|
# hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = oldcards, open = newcards)
|
||||||
elif street in ('FOURTH', 'FIFTH', 'SIXTH'):
|
# elif street in ('FOURTH', 'FIFTH', 'SIXTH'):
|
||||||
# 4th:
|
# # 4th:
|
||||||
# hero: [xxo] [o]
|
# # hero: [xxo] [o]
|
||||||
# others: [o] [o]
|
# # others: [o] [o]
|
||||||
# 5th:
|
# # 5th:
|
||||||
# hero: [xxoo] [o]
|
# # hero: [xxoo] [o]
|
||||||
# others: [oo] [o]
|
# # others: [oo] [o]
|
||||||
# 6th:
|
# # 6th:
|
||||||
# hero: [xxooo] [o]
|
# # hero: [xxooo] [o]
|
||||||
# others: [ooo] [o]
|
# # others: [ooo] [o]
|
||||||
hand.addPlayerCards(player = player.group('PNAME'), street = street, open = newcards)
|
# hand.addPlayerCards(player = player.group('PNAME'), street = street, open = newcards)
|
||||||
# we may additionally want to check the earlier streets tally with what we have but lets trust it for now.
|
# # we may additionally want to check the earlier streets tally with what we have but lets trust it for now.
|
||||||
elif street=='SEVENTH' and newcards:
|
# elif street=='SEVENTH' and newcards:
|
||||||
# hero: [xxoooo] [x]
|
# # hero: [xxoooo] [x]
|
||||||
# others: not reported.
|
# # others: not reported.
|
||||||
hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = newcards)
|
# hand.addPlayerCards(player = player.group('PNAME'), street = street, closed = newcards)
|
||||||
|
|
||||||
def readAction(self, hand, street):
|
def readAction(self, hand, street):
|
||||||
m = self.re_Action.finditer(hand.streets[street])
|
m = self.re_Action.finditer(hand.streets[street])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user