Hand.py: Use str.replace instead of re.sub for stripping commas.
From: Scott Wolchok <scott@wolchok.org>
This commit is contained in:
parent
1e482a8a37
commit
cf937285ea
|
@ -445,7 +445,7 @@ chips (string) the chips the player has at the start of the hand (can be None)
|
|||
If a player has None chips he won't be added."""
|
||||
log.debug("addPlayer: %s %s (%s)" % (seat, name, chips))
|
||||
if chips is not None:
|
||||
chips = re.sub(u',', u'', chips) #some sites have commas
|
||||
chips = chips.replace(u',', u'') #some sites have commas
|
||||
self.players.append([seat, name, chips])
|
||||
self.stacks[name] = Decimal(chips)
|
||||
self.pot.addPlayer(name)
|
||||
|
@ -487,7 +487,7 @@ If a player has None chips he won't be added."""
|
|||
For sites (currently only Carbon Poker) which record "all in" as a special action, which can mean either "calls and is all in" or "raises all in".
|
||||
"""
|
||||
self.checkPlayerExists(player)
|
||||
amount = re.sub(u',', u'', amount) #some sites have commas
|
||||
amount = amount.replace(u',', u'') #some sites have commas
|
||||
Ai = Decimal(amount)
|
||||
Bp = self.lastBet[street]
|
||||
Bc = reduce(operator.add, self.bets[street][player], 0)
|
||||
|
@ -503,7 +503,7 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio
|
|||
def addAnte(self, player, ante):
|
||||
log.debug("%s %s antes %s" % ('BLINDSANTES', player, ante))
|
||||
if player is not None:
|
||||
ante = re.sub(u',', u'', ante) #some sites have commas
|
||||
ante = ante.replace(u',', u'') #some sites have commas
|
||||
self.bets['BLINDSANTES'][player].append(Decimal(ante))
|
||||
self.stacks[player] -= Decimal(ante)
|
||||
act = (player, 'ante', Decimal(ante), self.stacks[player]==0)
|
||||
|
@ -522,7 +522,7 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio
|
|||
#
|
||||
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
|
||||
amount = amount.replace(u',', u'') #some sites have commas
|
||||
self.stacks[player] -= Decimal(amount)
|
||||
act = (player, blindtype, Decimal(amount), self.stacks[player]==0)
|
||||
self.actions['BLINDSANTES'].append(act)
|
||||
|
@ -555,7 +555,7 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio
|
|||
|
||||
def addCall(self, street, player=None, amount=None):
|
||||
if amount:
|
||||
amount = re.sub(u',', u'', amount) #some sites have commas
|
||||
amount = amount.replace(u',', u'') #some sites have commas
|
||||
log.debug(_("%s %s calls %s") %(street, player, amount))
|
||||
# Potentially calculate the amount of the call if not supplied
|
||||
# corner cases include if player would be all in
|
||||
|
@ -583,7 +583,7 @@ Add a raise by amountBy on [street] by [player]
|
|||
# then: C = Bp - Bc (amount to call)
|
||||
# Rt = Bp + Rb (raise to)
|
||||
#
|
||||
amountBy = re.sub(u',', u'', amountBy) #some sites have commas
|
||||
amountBy = amountBy.replace(u',', u'') #some sites have commas
|
||||
self.checkPlayerExists(player)
|
||||
Rb = Decimal(amountBy)
|
||||
Bp = self.lastBet[street]
|
||||
|
@ -601,7 +601,7 @@ Add a raise by amountBy on [street] by [player]
|
|||
"""\
|
||||
For sites which by "raises x" mean "calls and raises putting a total of x in the por". """
|
||||
self.checkPlayerExists(player)
|
||||
amount = re.sub(u',', u'', amount) #some sites have commas
|
||||
amount = amount.replace(u',', u'') #some sites have commas
|
||||
CRb = Decimal(amount)
|
||||
Bp = self.lastBet[street]
|
||||
Bc = reduce(operator.add, self.bets[street][player], 0)
|
||||
|
@ -617,7 +617,7 @@ Add a raise on [street] by [player] to [amountTo]
|
|||
"""
|
||||
#CG - No idea if this function has been test/verified
|
||||
self.checkPlayerExists(player)
|
||||
amountTo = re.sub(u',', u'', amountTo) #some sites have commas
|
||||
amountTo = amountTo.replace(u',', u'') #some sites have commas
|
||||
Bp = self.lastBet[street]
|
||||
Bc = reduce(operator.add, self.bets[street][player], 0)
|
||||
Rt = Decimal(amountTo)
|
||||
|
@ -638,7 +638,7 @@ Add a raise on [street] by [player] to [amountTo]
|
|||
|
||||
def addBet(self, street, player, amount):
|
||||
log.debug(_("%s %s bets %s") %(street, player, amount))
|
||||
amount = re.sub(u',', u'', amount) #some sites have commas
|
||||
amount = amount.replace(u',', u'') #some sites have commas
|
||||
self.checkPlayerExists(player)
|
||||
self.bets[street][player].append(Decimal(amount))
|
||||
self.stacks[player] -= Decimal(amount)
|
||||
|
@ -1377,7 +1377,7 @@ closed likewise, but known only to player
|
|||
Add a complete on [street] by [player] to [amountTo]
|
||||
"""
|
||||
log.debug(_("%s %s completes %s") % (street, player, amountTo))
|
||||
amountTo = re.sub(u',', u'', amountTo) #some sites have commas
|
||||
amountTo = amountTo.replace(u',', u'') #some sites have commas
|
||||
self.checkPlayerExists(player)
|
||||
Bp = self.lastBet['THIRD']
|
||||
Bc = reduce(operator.add, self.bets[street][player], 0)
|
||||
|
|
Loading…
Reference in New Issue
Block a user