PartyPoker: improved handling of players with zero or unknown stacks

This commit is contained in:
Erki Ferenc 2010-09-28 15:46:51 +02:00
parent 2ecee26d99
commit d2f5633384

View File

@ -348,19 +348,19 @@ class PartyPoker(HandHistoryConverter):
def readPlayerStacks(self, hand): def readPlayerStacks(self, hand):
log.debug("readPlayerStacks") log.debug("readPlayerStacks")
m = self.re_PlayerInfo.finditer(hand.handText) m = self.re_PlayerInfo.finditer(hand.handText)
players = [] maxKnownStack = 0
zeroStackPlayers = []
for a in m: for a in m:
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), if a.group('CASH') > '0':
clearMoneyString(a.group('CASH'))) #record max known stack for use with players with unknown stack
maxKnownStack = max(a.group('CASH'),maxKnownStack)
# detecting new active players without a seat hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), clearMoneyString(a.group('CASH')))
# and new active players with zero stack else:
#zero stacked players are added later
zeroStackPlayers.append([int(a.group('SEAT')), a.group('PNAME'), clearMoneyString(a.group('CASH'))])
if hand.gametype['type'] == 'ring': if hand.gametype['type'] == 'ring':
re_JoiningPlayers = re.compile(r"(?P<PLAYERNAME>.*) has joined the table") #finds first vacant seat after an exact seat
re_BBPostingPlayers = re.compile(r"(?P<PLAYERNAME>.*) posts big blind")
seatedPlayers = list([(f[1]) for f in hand.players])
def findFirstEmptySeat(startSeat): def findFirstEmptySeat(startSeat):
while startSeat in occupiedSeats: while startSeat in occupiedSeats:
if startSeat >= hand.maxseats: if startSeat >= hand.maxseats:
@ -368,14 +368,25 @@ class PartyPoker(HandHistoryConverter):
startSeat += 1 startSeat += 1
return startSeat return startSeat
re_JoiningPlayers = re.compile(r"(?P<PLAYERNAME>.*) has joined the table")
re_BBPostingPlayers = re.compile(r"(?P<PLAYERNAME>.*) posts big blind")
match_JoiningPlayers = re_JoiningPlayers.findall(hand.handText) match_JoiningPlayers = re_JoiningPlayers.findall(hand.handText)
match_BBPostingPlayers = re_BBPostingPlayers.findall(hand.handText) match_BBPostingPlayers = re_BBPostingPlayers.findall(hand.handText)
ringLimit = self.re_GameInfoRing.search(hand.handText).groupdict()['RINGLIMIT']
unseatedActivePlayers = list(set(match_BBPostingPlayers) - set(seatedPlayers))
for player in seatedPlayers: #add every player with zero stack, but:
if hand.stacks[player] == 0 and player in match_BBPostingPlayers: #if a zero stacked player is just joined the table in this very hand then set his stack to maxKnownStack
hand.stacks[player] = Decimal(ringLimit) for p in zeroStackPlayers:
if p[1] in match_JoiningPlayers:
p[2] = clearMoneyString(maxKnownStack)
hand.addPlayer(p[0],p[1],p[2])
seatedPlayers = list([(f[1]) for f in hand.players])
#it works for all known cases as of 2010-09-28
#should be refined with using match_ActivePlayers instead of match_BBPostingPlayers
#as a leaving and rejoining player could be active without posting a BB (sample HH needed)
unseatedActivePlayers = list(set(match_BBPostingPlayers) - set(seatedPlayers))
if unseatedActivePlayers: if unseatedActivePlayers:
for player in unseatedActivePlayers: for player in unseatedActivePlayers:
@ -384,7 +395,7 @@ class PartyPoker(HandHistoryConverter):
occupiedSeats = list([(f[0]) for f in hand.players]) occupiedSeats = list([(f[0]) for f in hand.players])
occupiedSeats.sort() occupiedSeats.sort()
newPlayerSeat = findFirstEmptySeat(previousBBPosterSeat) newPlayerSeat = findFirstEmptySeat(previousBBPosterSeat)
hand.addPlayer(newPlayerSeat,player,clearMoneyString(ringLimit)) hand.addPlayer(newPlayerSeat,player,clearMoneyString(maxKnownStack))
def markStreets(self, hand): def markStreets(self, hand):
m = re.search( m = re.search(