Get shown and mucked cards for stud games.
This commit is contained in:
parent
23a4ca34c8
commit
f323447313
|
@ -410,6 +410,20 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
self.collectees[player] += Decimal(pot)
|
self.collectees[player] += Decimal(pot)
|
||||||
|
|
||||||
|
|
||||||
|
def addShownCards(self, cards, player, holeandboard=None, shown=True, mucked=False):
|
||||||
|
"""\
|
||||||
|
For when a player shows cards for any reason (for showdown or out of choice).
|
||||||
|
Card ranks will be uppercased
|
||||||
|
"""
|
||||||
|
logging.debug("addShownCards %s hole=%s all=%s" % (player, cards, holeandboard))
|
||||||
|
if cards is not None:
|
||||||
|
self.addHoleCards(cards,player,shown, mucked)
|
||||||
|
elif holeandboard is not None:
|
||||||
|
holeandboard = set([self.card(c) for c in holeandboard])
|
||||||
|
board = set([c for s in self.board.values() for c in s])
|
||||||
|
self.addHoleCards(holeandboard.difference(board),player,shown, mucked)
|
||||||
|
|
||||||
|
|
||||||
def totalPot(self):
|
def totalPot(self):
|
||||||
"""If all bets and blinds have been added, totals up the total pot size"""
|
"""If all bets and blinds have been added, totals up the total pot size"""
|
||||||
|
|
||||||
|
@ -567,20 +581,6 @@ dealt whether they were seen in a 'dealt to' line
|
||||||
else:
|
else:
|
||||||
self.holecards['PREFLOP'][player] = cardset
|
self.holecards['PREFLOP'][player] = cardset
|
||||||
|
|
||||||
def addShownCards(self, cards, player, holeandboard=None, shown=True, mucked=False):
|
|
||||||
"""\
|
|
||||||
For when a player shows cards for any reason (for showdown or out of choice).
|
|
||||||
Card ranks will be uppercased
|
|
||||||
"""
|
|
||||||
logging.debug("addShownCards %s hole=%s all=%s" % (player, cards, holeandboard))
|
|
||||||
if cards is not None:
|
|
||||||
self.addHoleCards(cards,player,shown, mucked)
|
|
||||||
elif holeandboard is not None:
|
|
||||||
holeandboard = set([self.card(c) for c in holeandboard])
|
|
||||||
board = set([c for s in self.board.values() for c in s])
|
|
||||||
self.addHoleCards(holeandboard.difference(board),player,shown, mucked)
|
|
||||||
|
|
||||||
|
|
||||||
def writeHTMLHand(self, fh=sys.__stdout__):
|
def writeHTMLHand(self, fh=sys.__stdout__):
|
||||||
from nevow import tags as T
|
from nevow import tags as T
|
||||||
from nevow import flat
|
from nevow import flat
|
||||||
|
@ -991,7 +991,7 @@ class StudHand(Hand):
|
||||||
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
|
||||||
self.totalPot() # finalise it (total the pot)
|
self.totalPot() # finalise it (total the pot)
|
||||||
hhc.getRake(self)
|
hhc.getRake(self)
|
||||||
elif builtFrom == "DB":
|
elif builtFrom == "DB":
|
||||||
|
@ -1014,6 +1014,36 @@ 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):
|
||||||
|
"""\
|
||||||
|
Assigns observed holecards to a player.
|
||||||
|
cards list of card bigrams e.g. ['2h','Jc']
|
||||||
|
player (string) name of player
|
||||||
|
shown whether they were revealed at showdown
|
||||||
|
mucked whether they were mucked at showdown
|
||||||
|
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
|
||||||
|
|
||||||
|
if dealt:
|
||||||
|
self.dealt.add(player)
|
||||||
|
if shown:
|
||||||
|
self.shown.add(player)
|
||||||
|
if mucked:
|
||||||
|
self.mucked.add(player)
|
||||||
|
if len(cards) > 2:
|
||||||
|
self.holecards['THIRD'][player] = (cards[0:3], None)
|
||||||
|
if len(cards) > 6:
|
||||||
|
self.holecards['SEVENTH'][player] = (cards[6], None)
|
||||||
|
|
||||||
# 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'
|
||||||
|
@ -1046,6 +1076,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
self.lastBet['THIRD'] = Decimal(bringin)
|
self.lastBet['THIRD'] = Decimal(bringin)
|
||||||
self.pot.addMoney(player, Decimal(bringin))
|
self.pot.addMoney(player, Decimal(bringin))
|
||||||
|
|
||||||
|
|
||||||
def writeHand(self, fh=sys.__stdout__):
|
def writeHand(self, fh=sys.__stdout__):
|
||||||
# PokerStars format.
|
# PokerStars format.
|
||||||
# print >>fh, _("%s Game #%s: %s ($%s/$%s) - %s" %("PokerStars", self.handid, self.getGameTypeAsString(), self.sb, self.bb, time.strftime('%Y/%m/%d - %H:%M:%S (ET)', self.starttime)))
|
# print >>fh, _("%s Game #%s: %s ($%s/$%s) - %s" %("PokerStars", self.handid, self.getGameTypeAsString(), self.sb, self.bb, time.strftime('%Y/%m/%d - %H:%M:%S (ET)', self.starttime)))
|
||||||
|
|
|
@ -317,7 +317,7 @@ follow : whether to tail -f the input"""
|
||||||
for m in self.re_ShownCards.finditer(hand.handText):
|
for m in self.re_ShownCards.finditer(hand.handText):
|
||||||
if m.group('CARDS') is not None:
|
if m.group('CARDS') is not None:
|
||||||
cards = m.group('CARDS')
|
cards = m.group('CARDS')
|
||||||
cards = set(cards.split(' '))
|
cards = cards.split(' ') # needs to be a list, not a set--stud needs the order
|
||||||
|
|
||||||
(shown, mucked) = (False, False)
|
(shown, mucked) = (False, False)
|
||||||
if m.group('SHOWED') == "showed": shown = True
|
if m.group('SHOWED') == "showed": shown = True
|
||||||
|
|
Loading…
Reference in New Issue
Block a user