Hand: Refactor addBlind function

addBlind was separate for draw and flop games.

There should only be 2 lines difference between the functions, so merged them with appropriate changes.
This commit is contained in:
Worros 2011-01-14 14:18:14 +08:00
parent acdd1aa507
commit 5ec9c41efb

View File

@ -512,7 +512,6 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio
# Player in the big blind posts
# - this is a call of 1 sb and a raise to 1 bb
#
log.debug("addBlind: %s posts %s, %s" % (player, blindtype, amount))
if player is not None:
amount = re.sub(u',', u'', amount) #some sites have commas
@ -532,9 +531,16 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio
self.bets['BLINDSANTES'][player].append(Decimal(self.sb))
self.pot.addCommonMoney(player, Decimal(self.sb))
self.bets['PREFLOP'][player].append(Decimal(amount))
street = 'BLAH'
if self.gametype['base'] == 'hold':
street = 'PREFLOP'
elif self.gametype['base'] == 'draw':
street = 'DEAL'
self.bets[street][player].append(Decimal(amount))
self.pot.addMoney(player, Decimal(amount))
self.lastBet['PREFLOP'] = Decimal(amount)
self.lastBet[street] = Decimal(amount)
self.posted = self.posted + [[player,blindtype]]
@ -1154,34 +1160,6 @@ class DrawHand(Hand):
elif builtFrom == "DB":
self.select("dummy") # Will need a handId
# Draw games (at least Badugi has blinds - override default Holdem addBlind
def addBlind(self, player, blindtype, amount):
# if player is None, it's a missing small blind.
# The situation we need to cover are:
# Player in small blind posts
# - this is a bet of 1 sb, as yet uncalled.
# Player in the big blind posts
# - this is a call of 1 sb and a raise to 1 bb
#
log.debug("addBlind: %s posts %s, %s" % (player, blindtype, amount))
if player is not None:
self.bets['DEAL'][player].append(Decimal(amount))
self.stacks[player] -= Decimal(amount)
#print "DEBUG %s posts, stack %s" % (player, self.stacks[player])
act = (player, blindtype, Decimal(amount), self.stacks[player]==0)
self.actions['BLINDSANTES'].append(act)
self.pot.addMoney(player, Decimal(amount))
if blindtype == 'big blind':
self.lastBet['DEAL'] = Decimal(amount)
elif blindtype == 'both':
# extra small blind is 'dead'
amount = Decimal(amount)/3
amount += amount
self.lastBet['DEAL'] = Decimal(amount)
self.posted = self.posted + [[player,blindtype]]
#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)