Merge branch 'master' of git://git.assembla.com/free_poker_tools
This commit is contained in:
+64
-17
@@ -409,6 +409,20 @@ Add a raise on [street] by [player] to [amountTo]
|
||||
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):
|
||||
"""If all bets and blinds have been added, totals up the total pot size"""
|
||||
|
||||
@@ -566,20 +580,6 @@ dealt whether they were seen in a 'dealt to' line
|
||||
else:
|
||||
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__):
|
||||
from nevow import tags as T
|
||||
from nevow import flat
|
||||
@@ -771,6 +771,8 @@ Card ranks will be uppercased
|
||||
else:
|
||||
if name in self.shown:
|
||||
print >>fh, ("Seat %d: %s showed [%s] and lost with..." % (seatnum, name, " ".join(self.holecards['PREFLOP'][name])))
|
||||
elif name in self.mucked:
|
||||
print >>fh, ("Seat %d: %s mucked [%s] " % (seatnum, name, " ".join(self.holecards['PREFLOP'][name])))
|
||||
else:
|
||||
print >>fh, ("Seat %d: %s mucked" % (seatnum, name))
|
||||
|
||||
@@ -990,7 +992,7 @@ class StudHand(Hand):
|
||||
hhc.readStudPlayerCards(self, street)
|
||||
hhc.readAction(self, street)
|
||||
hhc.readCollectPot(self)
|
||||
#hhc.readShownCards(self) # not done yet
|
||||
hhc.readShownCards(self) # not done yet
|
||||
self.totalPot() # finalise it (total the pot)
|
||||
hhc.getRake(self)
|
||||
elif builtFrom == "DB":
|
||||
@@ -1013,6 +1015,42 @@ closed likewise, but known only to player
|
||||
except FpdbParseError, e:
|
||||
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 player == self.hero:
|
||||
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):
|
||||
def addComplete(self, street, player, amountTo):
|
||||
# assert street=='THIRD'
|
||||
@@ -1044,6 +1082,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||
self.actions['THIRD'].append(act)
|
||||
self.lastBet['THIRD'] = Decimal(bringin)
|
||||
self.pot.addMoney(player, Decimal(bringin))
|
||||
|
||||
|
||||
def writeHand(self, fh=sys.__stdout__):
|
||||
# PokerStars format.
|
||||
@@ -1180,11 +1219,13 @@ Add a complete on [street] by [player] to [amountTo]
|
||||
seatnum = player[0]
|
||||
name = player[1]
|
||||
if name in self.collectees and name in self.shown:
|
||||
print >>fh, _("Seat %d: %s showed [%s] and won ($%s)" % (seatnum, name, " ".join(self.holecards[name]), self.collectees[name]))
|
||||
print >>fh, _("Seat %d: %s showed [%s] and won ($%s)" % (seatnum, name, self.join_holecards(name), self.collectees[name]))
|
||||
elif name in self.collectees:
|
||||
print >>fh, _("Seat %d: %s collected ($%s)" % (seatnum, name, self.collectees[name]))
|
||||
elif name in self.shown:
|
||||
print >>fh, _("Seat %d: %s showed [%s]" % (seatnum, name, " ".join(self.holecards[name])))
|
||||
print >>fh, _("Seat %d: %s showed [%s]" % (seatnum, name, self.join_holecards(name)))
|
||||
elif name in self.mucked:
|
||||
print >>fh, _("Seat %d: %s mucked [%s]" % (seatnum, name, self.join_holecards(name)))
|
||||
elif name in self.folded:
|
||||
print >>fh, _("Seat %d: %s folded" % (seatnum, name))
|
||||
else:
|
||||
@@ -1193,6 +1234,12 @@ Add a complete on [street] by [player] to [amountTo]
|
||||
print >>fh, "\n\n"
|
||||
|
||||
|
||||
def join_holecards(self, player):
|
||||
holecards = []
|
||||
for street in self.holeStreets:
|
||||
if self.holecards[street].has_key(player):
|
||||
holecards = holecards + self.holecards[street][player][0]
|
||||
return " ".join(holecards)
|
||||
|
||||
class Pot(object):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user