From ebf16c6aa9459cbc16cc57109493a8b6ffdd7c7d Mon Sep 17 00:00:00 2001 From: steffen123 Date: Thu, 15 Jul 2010 00:27:57 +0200 Subject: [PATCH] TOURNEY: store HandsPlayers.tourneysPlayersId --- pyfpdb/Database.py | 8 ++++---- pyfpdb/DerivedStats.py | 4 ++++ pyfpdb/SQL.py | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index d176bd87..f35fe19a 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -1657,6 +1657,7 @@ class Database: pdata[p]['street4Bets'], pdata[p]['position'], pdata[p]['tourneyTypeId'], + pdata[p]['tourneysPlayersIds'], pdata[p]['startCards'], pdata[p]['street0_3BChance'], pdata[p]['street0_3BDone'], @@ -2074,7 +2075,7 @@ class Database: #end def createOrUpdateTourney def createOrUpdateTourneysPlayers(self, hand, source):#note: this method is used on Hand and TourneySummary objects - tourneysPlayersIds=[] + tourneysPlayersIds={} for player in hand.players: if source=="TS": #TODO remove this horrible hack playerId = hand.dbid_pids[player] @@ -2094,9 +2095,8 @@ class Database: updateDb=False resultDict = dict(zip(columnNames, result)) - tourneysPlayersIds.append(result[0]) + tourneysPlayersIds[player[1]]=result[0] if source=="TS": - tourneysPlayersId=result[0] for ev in expectedValues : handAttribute=ev if ev!="winnings" and ev!="winningsCurrency": @@ -2124,7 +2124,7 @@ class Database: cursor.execute (self.sql.query['insertTourneysPlayer'].replace('%s', self.sql.query['placeholder']), (hand.tourneyId, playerId, None, None, None, hand.rebuyCounts[player], hand.addOnCounts[player], hand.koCounts[player])) - tourneysPlayersIds.append(self.get_last_insert_id(cursor)) + tourneysPlayersIds[player[1]]=self.get_last_insert_id(cursor) return tourneysPlayersIds #end def createOrUpdateTourneysPlayers diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index 96928486..f34a8673 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -140,6 +140,10 @@ class DerivedStats(): self.handsplayers[player[1]]['seatNo'] = player[0] self.handsplayers[player[1]]['startCash'] = int(100 * Decimal(player[2])) self.handsplayers[player[1]]['sitout'] = False #TODO: implement actual sitout detection + if hand.gametype["type"]=="tour": + self.handsplayers[player[1]]['tourneysPlayersIds'] = hand.tourneysPlayersIds[player[1]] + else: + self.handsplayers[player[1]]['tourneysPlayersIds'] = None # XXX: enumerate(list, start=x) is python 2.6 syntax; 'start' #for i, street in enumerate(hand.actionStreets[2:], start=1): diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 5041ae35..515c8a24 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -3853,6 +3853,7 @@ class Sql: street4Bets, position, tourneyTypeId, + tourneysPlayersId, startCards, street0_3BChance, street0_3BDone, @@ -3910,7 +3911,7 @@ class Sql: %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, - %s + %s, %s )""" ################################