Reads rank and winnings from pokerstars hand history

This commit is contained in:
evilny0 2011-04-11 23:10:47 +02:00
parent b611e23e5d
commit 3ac124903f
3 changed files with 25 additions and 2 deletions

View File

@ -2834,7 +2834,7 @@ class Database:
else: else:
if source=="HHC": if source=="HHC":
cursor.execute (self.sql.query['insertTourneysPlayer'].replace('%s', self.sql.query['placeholder']), cursor.execute (self.sql.query['insertTourneysPlayer'].replace('%s', self.sql.query['placeholder']),
(hand.tourneyId, playerId, None, None, None, None, None, None)) (hand.tourneyId, playerId, player[3], player[4], None, None, None, None))
elif source=="TS": elif source=="TS":
#print "all values: tourneyId",hand.tourneyId, "playerId",playerId, "rank",hand.ranks[player], "winnings",hand.winnings[player], "winCurr",hand.winningsCurrency[player], hand.rebuyCounts[player], hand.addOnCounts[player], hand.koCounts[player] #print "all values: tourneyId",hand.tourneyId, "playerId",playerId, "rank",hand.ranks[player], "winnings",hand.winnings[player], "winCurr",hand.winningsCurrency[player], hand.rebuyCounts[player], hand.addOnCounts[player], hand.koCounts[player]
if hand.ranks[player]: if hand.ranks[player]:

View File

@ -469,7 +469,7 @@ If a player has None chips he won't be added."""
log.debug("addPlayer: %s %s (%s)" % (seat, name, chips)) log.debug("addPlayer: %s %s (%s)" % (seat, name, chips))
if chips is not None: if chips is not None:
chips = chips.replace(u',', u'') #some sites have commas chips = chips.replace(u',', u'') #some sites have commas
self.players.append([seat, name, chips]) self.players.append([seat, name, chips, 0, 0])
self.stacks[name] = Decimal(chips) self.stacks[name] = Decimal(chips)
self.pot.addPlayer(name) self.pot.addPlayer(name)
for street in self.actionStreets: for street in self.actionStreets:
@ -478,6 +478,17 @@ If a player has None chips he won't be added."""
#self.discards[name] = {} # dict from street names. #self.discards[name] = {} # dict from street names.
def addPlayerRank(self, name, winnings, rank):
"""\
name (string) player name
winnings (int) winnings
rank (int) rank the player finished the tournament"""
log.debug("addPlayerRank: %s %s (%s)" % (name, winnings, rank))
for player in self.players:
if player[1] == name:
player[3]=rank
player[4]=winnings
def addStreets(self, match): def addStreets(self, match):
# go through m and initialise actions to empty list for each street. # go through m and initialise actions to empty list for each street.
if match: if match:

View File

@ -159,6 +159,9 @@ class PokerStars(HandHistoryConverter):
re_sitsOut = re.compile("^%s sits out" % short_subst['PLYR'], re.MULTILINE) re_sitsOut = re.compile("^%s sits out" % short_subst['PLYR'], re.MULTILINE)
re_ShownCards = re.compile("^Seat (?P<SEAT>[0-9]+): %s (\(.*\) )?(?P<SHOWED>showed|mucked) \[(?P<CARDS>.*)\]( and won \([.\d]+\) with (?P<STRING>.*))?" % short_subst['PLYR'], re.MULTILINE) re_ShownCards = re.compile("^Seat (?P<SEAT>[0-9]+): %s (\(.*\) )?(?P<SHOWED>showed|mucked) \[(?P<CARDS>.*)\]( and won \([.\d]+\) with (?P<STRING>.*))?" % short_subst['PLYR'], re.MULTILINE)
re_CollectPot = re.compile(r"Seat (?P<SEAT>[0-9]+): %(PLYR)s (\(button\) |\(small blind\) |\(big blind\) |\(button\) \(small blind\) |\(button\) \(big blind\) )?(collected|showed \[.*\] and won) \(%(CUR)s(?P<POT>[.\d]+)\)(, mucked| with.*|)" % short_subst, re.MULTILINE) re_CollectPot = re.compile(r"Seat (?P<SEAT>[0-9]+): %(PLYR)s (\(button\) |\(small blind\) |\(big blind\) |\(button\) \(small blind\) |\(button\) \(big blind\) )?(collected|showed \[.*\] and won) \(%(CUR)s(?P<POT>[.\d]+)\)(, mucked| with.*|)" % short_subst, re.MULTILINE)
re_WinningRankOne = re.compile(u"^%(PLYR)s wins the tournament and receives %(CUR)s(?P<AMT>[\.0-9]+) - congratulations!$" % short_subst, re.MULTILINE)
re_WinningRankOther = re.compile(u"^%(PLYR)s finished the tournament in (?P<RANK>[0-9]+)(st|nd|rd|th) place and received %(CUR)s(?P<AMT>[.0-9]+)\.$" % short_subst, re.MULTILINE)
re_RankOther = re.compile(u"^%(PLYR)s finished the tournament in (?P<RANK>[0-9]+)(st|nd|rd|th) place$" % short_subst, re.MULTILINE)
def compilePlayerRegexs(self, hand): def compilePlayerRegexs(self, hand):
pass pass
@ -453,6 +456,15 @@ class PokerStars(HandHistoryConverter):
cards = shows.group('CARDS').split(' ') cards = shows.group('CARDS').split(' ')
hand.addShownCards(cards, shows.group('PNAME')) hand.addShownCards(cards, shows.group('PNAME'))
for winningrankone in self.re_WinningRankOne.finditer(hand.handText):
hand.addPlayerRank (winningrankone.group('PNAME'),int(100*Decimal(winningrankone.group('AMT'))),1)
for winningrankothers in self.re_WinningRankOther.finditer(hand.handText):
hand.addPlayerRank (winningrankothers.group('PNAME'),int(100*Decimal(winningrankothers.group('AMT'))),winningrankothers.group('RANK'))
for rankothers in self.re_RankOther.finditer(hand.handText):
hand.addPlayerRank (rankothers.group('PNAME'),0,rankothers.group('RANK'))
def readCollectPot(self,hand): def readCollectPot(self,hand):
for m in self.re_CollectPot.finditer(hand.handText): for m in self.re_CollectPot.finditer(hand.handText):
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT')) hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))