Merge branch 'master' of git://git.assembla.com/free_poker_tools
This commit is contained in:
commit
c3d463b689
|
@ -409,6 +409,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"""
|
||||||
|
|
||||||
|
@ -566,20 +580,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
|
||||||
|
@ -771,6 +771,8 @@ Card ranks will be uppercased
|
||||||
else:
|
else:
|
||||||
if name in self.shown:
|
if name in self.shown:
|
||||||
print >>fh, ("Seat %d: %s showed [%s] and lost with..." % (seatnum, name, " ".join(self.holecards['PREFLOP'][name])))
|
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:
|
else:
|
||||||
print >>fh, ("Seat %d: %s mucked" % (seatnum, name))
|
print >>fh, ("Seat %d: %s mucked" % (seatnum, name))
|
||||||
|
|
||||||
|
@ -990,7 +992,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":
|
||||||
|
@ -1013,6 +1015,42 @@ 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 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):
|
# TODO: def addComplete(self, player, amount):
|
||||||
def addComplete(self, street, player, amountTo):
|
def addComplete(self, street, player, amountTo):
|
||||||
# assert street=='THIRD'
|
# assert street=='THIRD'
|
||||||
|
@ -1045,6 +1083,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)))
|
||||||
|
@ -1180,11 +1219,13 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
seatnum = player[0]
|
seatnum = player[0]
|
||||||
name = player[1]
|
name = player[1]
|
||||||
if name in self.collectees and name in self.shown:
|
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:
|
elif name in self.collectees:
|
||||||
print >>fh, _("Seat %d: %s collected ($%s)" % (seatnum, name, self.collectees[name]))
|
print >>fh, _("Seat %d: %s collected ($%s)" % (seatnum, name, self.collectees[name]))
|
||||||
elif name in self.shown:
|
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:
|
elif name in self.folded:
|
||||||
print >>fh, _("Seat %d: %s folded" % (seatnum, name))
|
print >>fh, _("Seat %d: %s folded" % (seatnum, name))
|
||||||
else:
|
else:
|
||||||
|
@ -1193,6 +1234,12 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
print >>fh, "\n\n"
|
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):
|
class Pot(object):
|
||||||
|
|
||||||
|
|
|
@ -238,6 +238,7 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py.
|
||||||
logging.info("Unsupported game type: %s" % gametype)
|
logging.info("Unsupported game type: %s" % gametype)
|
||||||
|
|
||||||
if hand:
|
if hand:
|
||||||
|
# print hand
|
||||||
hand.writeHand(self.out_fh)
|
hand.writeHand(self.out_fh)
|
||||||
else:
|
else:
|
||||||
logging.info("Unsupported game type: %s" % gametype)
|
logging.info("Unsupported game type: %s" % gametype)
|
||||||
|
|
|
@ -109,7 +109,7 @@ follow : whether to tail -f the input"""
|
||||||
info['bb'] = mg['BB']
|
info['bb'] = mg['BB']
|
||||||
if 'CURRENCY' in mg:
|
if 'CURRENCY' in mg:
|
||||||
info['currency'] = currencies[mg['CURRENCY']]
|
info['currency'] = currencies[mg['CURRENCY']]
|
||||||
if 'MIXED' in mg:
|
if 'MIXED' in mg and mg['MIXED'] != None:
|
||||||
info['mixedType'] = mixes[mg['MIXED']]
|
info['mixedType'] = mixes[mg['MIXED']]
|
||||||
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
# NB: SB, BB must be interpreted as blinds or bets depending on limit type.
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ follow : whether to tail -f the input"""
|
||||||
# Also works with Omaha hands.
|
# Also works with Omaha hands.
|
||||||
cards = m.group('NEWCARDS')
|
cards = m.group('NEWCARDS')
|
||||||
cards = set(cards.split(' '))
|
cards = set(cards.split(' '))
|
||||||
hand.addHoleCards(cards, m.group('PNAME'), shown=False, mucked=False)
|
hand.addHoleCards(cards, m.group('PNAME'), shown=False, mucked=False, dealt=True)
|
||||||
|
|
||||||
def readDrawCards(self, hand, street):
|
def readDrawCards(self, hand, street):
|
||||||
logging.debug("readDrawCards")
|
logging.debug("readDrawCards")
|
||||||
|
@ -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