Merge branch 'master' of git://git.assembla.com/fpdb.git

This commit is contained in:
Gerko de Roo 2010-06-27 20:55:27 +02:00
commit d90156a02a
12 changed files with 257 additions and 327 deletions

View File

@ -34,8 +34,8 @@ class Gametype(MappedBase):
@staticmethod
def get_or_create(session, siteId, gametype):
map = zip(
['type', 'base', 'category', 'limitType', 'smallBlind', 'bigBlind', 'smallBet', 'bigBet'],
['type', 'base', 'category', 'limitType', 'sb', 'bb', 'dummy', 'dummy', ])
['type', 'base', 'category', 'limitType', 'smallBlind', 'bigBlind', 'smallBet', 'bigBet', 'currency'],
['type', 'base', 'category', 'limitType', 'sb', 'bb', 'dummy', 'dummy', 'currency'])
gametype = dict([(new, gametype.get(old)) for new, old in map ])
hilo = "h"
@ -152,7 +152,8 @@ class HandInternal(DerivedStats):
'speed': 'speed',
'maxSeats': 'maxseats',
'knockout': 'isKO',
'rebuyOrAddon': 'isRebuy',
'rebuy': 'isRebuy',
'addOn': 'isAddOn',
'headsUp': 'isHU',
'shootout': 'isShootout',
'matrix': 'isMatrix',
@ -185,7 +186,7 @@ class HandInternal(DerivedStats):
# fetch and update tourney players
for hp in self.handPlayers:
tp = TourneyPlayer.get_or_create(session, tour.id, hp.playerId)
tp = TourneysPlayer.get_or_create(session, tour.id, hp.playerId)
# FIXME: other TourneysPlayers should be added here
session.flush()
@ -340,18 +341,20 @@ class HandPlayer(MappedBase):
class Site(object):
"""Class reflecting Players db table"""
INITIAL_DATA = [
(1 , 'Full Tilt Poker','USD'),
(2 , 'PokerStars', 'USD'),
(3 , 'Everleaf', 'USD'),
(4 , 'Win2day', 'USD'),
(5 , 'OnGame', 'USD'),
(6 , 'UltimateBet', 'USD'),
(7 , 'Betfair', 'USD'),
(8 , 'Absolute', 'USD'),
(9 , 'PartyPoker', 'USD'),
(10, 'Partouche', 'EUR'),
(1 , 'Full Tilt Poker','FT'),
(2 , 'PokerStars', 'PS'),
(3 , 'Everleaf', 'EV'),
(4 , 'Win2day', 'W2'),
(5 , 'OnGame', 'OG'),
(6 , 'UltimateBet', 'UB'),
(7 , 'Betfair', 'BF'),
(8 , 'Absolute', 'AB'),
(9 , 'PartyPoker', 'PP'),
(10, 'Partouche', 'PA'),
(11, 'Carbon', 'CA'),
(12, 'PKR', 'PK'),
]
INITIAL_DATA_KEYS = ('id', 'name', 'currency')
INITIAL_DATA_KEYS = ('id', 'name', 'code')
INITIAL_DATA_DICTS = [ dict(zip(INITIAL_DATA_KEYS, datum)) for datum in INITIAL_DATA ]
@ -372,7 +375,7 @@ class Tourney(MappedBase):
class TourneyType(MappedBase):
"""Class reflecting TourneysType db table"""
"""Class reflecting TourneyType db table"""
@classmethod
def get_or_create(cls, session, **kwargs):
@ -380,12 +383,12 @@ class TourneyType(MappedBase):
Required kwargs:
buyin fee speed maxSeats knockout
rebuyOrAddon headsUp shootout matrix sng
rebuy addOn headsUp shootout matrix sng currency
"""
return get_or_create(cls, session, **kwargs)[0]
class TourneyPlayer(MappedBase):
class TourneysPlayer(MappedBase):
"""Class reflecting TourneysPlayers db table"""
@classmethod
@ -437,7 +440,7 @@ mapper (Gametype, gametypes_table, properties={
})
mapper (Player, players_table, properties={
'playerHands': relation(HandPlayer, backref='player'),
'playerTourney': relation(TourneyPlayer, backref='player'),
'playerTourney': relation(TourneysPlayer, backref='player'),
})
mapper (Site, sites_table, properties={
'gametypes': relation(Gametype, backref = 'site'),
@ -455,7 +458,7 @@ mapper (Tourney, tourneys_table)
mapper (TourneyType, tourney_types_table, properties={
'tourneys': relation(Tourney, backref='type'),
})
mapper (TourneyPlayer, tourneys_players_table)
mapper (TourneysPlayer, tourneys_players_table)
class LambdaKeyDict(defaultdict):
"""Operates like defaultdict but passes key argument to the factory function"""

View File

@ -29,6 +29,7 @@ autorates_table = Table('Autorates', metadata,
gametypes_table = Table('Gametypes', metadata,
Column('id', SmallInteger, primary_key=True),
Column('siteId', SmallInteger, ForeignKey("Sites.id"), nullable=False), # SMALLINT
Column('currency', String(4), nullable=False), # varchar(4) NOT NULL
Column('type', String(4), nullable=False), # char(4) NOT NULL
Column('base', String(4), nullable=False), # char(4) NOT NULL
Column('category', String(9), nullable=False), # varchar(9) NOT NULL
@ -338,7 +339,7 @@ settings_table = Table('Settings', metadata,
sites_table = Table('Sites', metadata,
Column('id', SmallInteger, primary_key=True),
Column('name', String(32), nullable=False), # varchar(32) NOT NULL
Column('currency', String(3), nullable=False), # char(3) NOT NULL
Column('code', String(2), nullable=False), # char(2) NOT NULL
mysql_charset='utf8',
mysql_engine='InnoDB',
)
@ -352,17 +353,11 @@ tourneys_table = Table('Tourneys', metadata,
Column('prizepool', Integer), # INT NOT NULL
Column('tourStartTime', DateTime), # DATETIME NOT NULL
Column('tourEndTime', DateTime), # DATETIME
Column('buyinChips', Integer), # INT
Column('tourneyName', String(40)), # varchar(40)
# Mask use : 1=Positionnal Winnings|2=Match1|4=Match2|...|pow(2,n)=Matchn
Column('matrixIdProcessed',SmallInteger, default=0), # TINYINT UNSIGNED DEFAULT 0
Column('rebuyChips', Integer, default=0), # INT DEFAULT 0
Column('addonChips', Integer, default=0), # INT DEFAULT 0
Column('rebuyAmount', MoneyColumn, default=0), # INT DEFAULT 0
Column('addonAmount', MoneyColumn, default=0), # INT DEFAULT 0
Column('totalRebuys', Integer, default=0), # INT DEFAULT 0
Column('totalAddons', Integer, default=0), # INT DEFAULT 0
Column('koBounty', Integer, default=0), # INT DEFAULT 0
Column('totalRebuyCount', Integer, default=0), # INT DEFAULT 0
Column('totalAddOnCount', Integer, default=0), # INT DEFAULT 0
Column('comment', Text), # TEXT
Column('commentTs', DateTime), # DATETIME
mysql_charset='utf8',
@ -374,24 +369,35 @@ Index('siteTourneyNo', tourneys_table.c.siteTourneyNo, tourneys_table.c.tourneyT
tourney_types_table = Table('TourneyTypes', metadata,
Column('id', Integer, primary_key=True),
Column('siteId', SmallInteger, ForeignKey("Sites.id"), nullable=False),
Column('currency', String(4), nullable=False), # varchar(4) NOT NULL
Column('buyin', Integer, nullable=False), # INT NOT NULL
Column('fee', Integer, nullable=False, default=0), # INT NOT NULL
Column('fee', Integer, nullable=False), # INT NOT NULL
Column('buyInChips', Integer, nullable=False), # INT NOT NULL
Column('maxSeats', Boolean, nullable=False, default=-1), # INT NOT NULL DEFAULT -1
Column('rebuy', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
Column('rebuyCost', Integer), # INT
Column('rebuyChips', Integer), # INT
Column('addOn', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
Column('addOnCost', Integer), # INT
Column('addOnChips', Integer), # INT
Column('knockout', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
Column('rebuyOrAddon', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
Column('koBounty', Integer), # INT
Column('speed', String(10)), # varchar(10)
Column('headsUp', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
Column('shootout', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
Column('matrix', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
Column('sng', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
Column('satellite', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
Column('doubleOrNothing', Boolean, nullable=False, default=False), # BOOLEAN NOT NULL DEFAULT False
Column('guarantee', Integer, nullable=False, default=0), # INT NOT NULL DEFAULT 0
mysql_charset='utf8',
mysql_engine='InnoDB',
)
Index('tourneyTypes_all',
tourney_types_table.c.siteId, tourney_types_table.c.buyin, tourney_types_table.c.fee,
tourney_types_table.c.maxSeats, tourney_types_table.c.knockout, tourney_types_table.c.rebuyOrAddon,
tourney_types_table.c.speed, tourney_types_table.c.headsUp, tourney_types_table.c.shootout,
tourney_types_table.c.matrix, tourney_types_table.c.sng)
tourney_types_table.c.maxSeats, tourney_types_table.c.knockout, tourney_types_table.c.rebuy,
tourney_types_table.c.addOn, tourney_types_table.c.speed, tourney_types_table.c.headsUp,
tourney_types_table.c.shootout, tourney_types_table.c.matrix, tourney_types_table.c.sng)
tourneys_players_table = Table('TourneysPlayers', metadata,
@ -401,9 +407,10 @@ tourneys_players_table = Table('TourneysPlayers', metadata,
Column('payinAmount', Integer), # INT NOT NULL
Column('rank', Integer), # INT NOT NULL
Column('winnings', Integer), # INT NOT NULL
Column('nbRebuys', Integer, default=0), # INT DEFAULT 0
Column('nbAddons', Integer, default=0), # INT DEFAULT 0
Column('nbKO', Integer, default=0), # INT DEFAULT 0
Column('winningsCurrency', Text), # TEXT
Column('rebuyCount', Integer, default=0), # INT DEFAULT 0
Column('addOnCount', Integer, default=0), # INT DEFAULT 0
Column('koCount', Integer, default=0), # INT DEFAULT 0
Column('comment', Text), # TEXT
Column('commentTs', DateTime), # DATETIME
mysql_charset='utf8',

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Database.py
Create and manage the database objects.
@ -74,7 +75,7 @@ except ImportError:
use_numpy = False
DB_VERSION = 119
DB_VERSION = 121
# Variance created as sqlite has a bunch of undefined aggregate functions.
@ -1343,29 +1344,30 @@ class Database:
def fillDefaultData(self):
c = self.get_cursor()
c.execute("INSERT INTO Settings (version) VALUES (%s);" % (DB_VERSION))
c.execute("INSERT INTO Sites (name,currency) VALUES ('Full Tilt Poker', 'USD')")
c.execute("INSERT INTO Sites (name,currency) VALUES ('PokerStars', 'USD')")
c.execute("INSERT INTO Sites (name,currency) VALUES ('Everleaf', 'USD')")
c.execute("INSERT INTO Sites (name,currency) VALUES ('Win2day', 'USD')")
c.execute("INSERT INTO Sites (name,currency) VALUES ('OnGame', 'USD')")
c.execute("INSERT INTO Sites (name,currency) VALUES ('UltimateBet', 'USD')")
c.execute("INSERT INTO Sites (name,currency) VALUES ('Betfair', 'USD')")
c.execute("INSERT INTO Sites (name,currency) VALUES ('Absolute', 'USD')")
c.execute("INSERT INTO Sites (name,currency) VALUES ('PartyPoker', 'USD')")
c.execute("INSERT INTO Sites (name,currency) VALUES ('Partouche', 'EUR')")
c.execute("INSERT INTO Sites (name,currency) VALUES ('Carbon', 'USD')")
c.execute("INSERT INTO Sites (name,currency) VALUES ('PKR', 'USD')")
c.execute("INSERT INTO Sites (name,code) VALUES ('Full Tilt Poker', 'FT')")
c.execute("INSERT INTO Sites (name,code) VALUES ('PokerStars', 'PS')")
c.execute("INSERT INTO Sites (name,code) VALUES ('Everleaf', 'EV')")
c.execute("INSERT INTO Sites (name,code) VALUES ('Win2day', 'W2')")
c.execute("INSERT INTO Sites (name,code) VALUES ('OnGame', 'OG')")
c.execute("INSERT INTO Sites (name,code) VALUES ('UltimateBet', 'UB')")
c.execute("INSERT INTO Sites (name,code) VALUES ('Betfair', 'BF')")
c.execute("INSERT INTO Sites (name,code) VALUES ('Absolute', 'AB')")
c.execute("INSERT INTO Sites (name,code) VALUES ('PartyPoker', 'PP')")
c.execute("INSERT INTO Sites (name,code) VALUES ('Partouche', 'PA')")
c.execute("INSERT INTO Sites (name,code) VALUES ('Carbon', 'CA')")
c.execute("INSERT INTO Sites (name,code) VALUES ('PKR', 'PK')")
if self.backend == self.SQLITE:
c.execute("INSERT INTO TourneyTypes (id, siteId, buyin, fee) VALUES (NULL, 1, 0, 0);")
c.execute("""INSERT INTO TourneyTypes (id, siteId, currency, buyin, fee, buyInChips, maxSeats, knockout,
rebuy, addOn, speed, headsUp, shootout, matrix)
VALUES (NULL, 1, 'USD', 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0);""")
elif self.backend == self.PGSQL:
c.execute("""insert into TourneyTypes(siteId, buyin, fee, maxSeats, knockout
,rebuyOrAddon, speed, headsUp, shootout, matrix)
values (1, 0, 0, 0, False, False, null, False, False, False);""")
c.execute("""insert into TourneyTypes(siteId, currency, buyin, fee, buyInChips, maxSeats, knockout
,rebuy, addOn, speed, headsUp, shootout, matrix)
values (1, 'USD', 0, 0, 0, 0, False, False, False, null, False, False, False);""")
elif self.backend == self.MYSQL_INNODB:
c.execute("""insert into TourneyTypes(id, siteId, buyin, fee, maxSeats, knockout
,rebuyOrAddon, speed, headsUp, shootout, matrix)
values (DEFAULT, 1, 0, 0, 0, False, False, null, False, False, False);""")
c.execute("""insert into TourneyTypes(id, siteId, currency, buyin, fee, buyInChips, maxSeats, knockout
,rebuy, addOn, speed, headsUp, shootout, matrix)
values (DEFAULT, 1, 'USD', 0, 0, 0, 0, False, False, False, null, False, False, False);""")
#end def fillDefaultData
def rebuild_indexes(self, start=None):
@ -1373,6 +1375,7 @@ class Database:
self.createAllIndexes()
self.dropAllForeignKeys()
self.createAllForeignKeys()
#end def rebuild_indexes
def rebuild_hudcache(self, h_start=None, v_start=None):
"""clears hudcache and rebuilds from the individual handsplayers records"""
@ -1792,8 +1795,9 @@ class Database:
hilo = "s"
elif game['category'] in ['razz','27_3draw','badugi']:
hilo = "l"
tmp = self.insertGameTypes( (siteid, game['type'], game['base'], game['category'], game['limitType'], hilo,
tmp = self.insertGameTypes( (siteid, 'USD', game['type'], game['base'], game['category'], game['limitType'], hilo,
int(Decimal(game['sb'])*100), int(Decimal(game['bb'])*100), 0, 0) )
#FIXME: recognise currency
return tmp[0]
def getSqlPlayerIDs(self, pnames, siteid):
@ -1853,48 +1857,6 @@ class Database:
# Finish of NEWIMPORT CODE
#################################
def store_tourneys_players(self, tourney_id, player_ids, payin_amounts, ranks, winnings):
try:
result=[]
cursor = self.get_cursor()
#print "in store_tourneys_players. tourney_id:",tourney_id
#print "player_ids:",player_ids
#print "payin_amounts:",payin_amounts
#print "ranks:",ranks
#print "winnings:",winnings
for i in xrange(len(player_ids)):
try:
cursor.execute("savepoint ins_tplayer")
cursor.execute("""INSERT INTO TourneysPlayers
(tourneyId, playerId, payinAmount, rank, winnings) VALUES (%s, %s, %s, %s, %s)""".replace('%s', self.sql.query['placeholder']),
(tourney_id, player_ids[i], payin_amounts[i], ranks[i], winnings[i]))
tmp = self.get_last_insert_id(cursor)
result.append(tmp)
#print "created new tourneys_players.id:", tmp
except:
cursor.execute("rollback to savepoint ins_tplayer")
cursor.execute("SELECT id FROM TourneysPlayers WHERE tourneyId=%s AND playerId+0=%s".replace('%s', self.sql.query['placeholder'])
,(tourney_id, player_ids[i]))
tmp = cursor.fetchone()
#print "tried SELECTing tourneys_players.id:", tmp
try:
len(tmp)
result.append(tmp[0])
except:
print "tplayer id not found for tourney,player %s,%s" % (tourney_id, player_ids[i])
pass
except:
raise FpdbError( "store_tourneys_players error: " + str(sys.exc_value) )
cursor.execute("release savepoint ins_tplayer")
#print "store_tourneys_players returning", result
return result
#end def store_tourneys_players
# read HandToWrite objects from q and insert into database
def insert_queue_hands(self, q, maxwait=10, commitEachHand=True):
n,fails,maxTries,firstWait = 0,0,4,0.1
@ -1970,8 +1932,8 @@ class Database:
print "***Error sending finish: "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
# end def send_finish_msg():
def tRecogniseTourneyType(self, tourney):
log.debug("Database.tRecogniseTourneyType")
def recogniseTourneyType(self, tourney):
log.debug("Database.recogniseTourneyType")
typeId = 1
# Check if Tourney exists, and if so retrieve TTypeId : in that case, check values of the ttype
cursor = self.get_cursor()
@ -2020,7 +1982,7 @@ class Database:
typeId = self.get_last_insert_id(cursor)
return typeId
#end def tRecogniseTourneyType
#end def recogniseTourneyType

View File

@ -431,6 +431,11 @@ class DerivedStats():
self.handsplayers[player[1]]['street%sAggr' % i] = True
else:
self.handsplayers[player[1]]['street%sAggr' % i] = False
if len(aggrers)>0 and i>0:
for playername in others:
self.handsplayers[playername]['otherRaisedStreet%s' % i] = True
#print "otherRaised detected on handid "+str(hand.handid)+" for "+playername+" on street "+str(i)
if i > 0 and len(aggrers) > 0:
for playername in others:
@ -450,8 +455,7 @@ class DerivedStats():
for act in hand.actions[hand.actionStreets[i+1]]:
if act[1] in ('bets'):
self.handsplayers[act[0]]['street%sBets' % i] = 1 + self.handsplayers[act[0]]['street%sBets' % i]
def folds(self, hand, i):
for act in hand.actions[hand.actionStreets[i+1]]:
if act[1] in ('folds'):

View File

@ -66,7 +66,7 @@ class Fulltilt(HandHistoryConverter):
''', re.VERBOSE)
re_Button = re.compile('^The button is in seat #(?P<BUTTON>\d+)', re.MULTILINE)
re_PlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.{2,15}) \(\$(?P<CASH>[,.0-9]+)\)$', re.MULTILINE)
re_TourneyPlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.{2,15}) \(\$?(?P<CASH>[,.0-9]+)\)(, is sitting out)?$', re.MULTILINE)
re_TourneysPlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.{2,15}) \(\$?(?P<CASH>[,.0-9]+)\)(, is sitting out)?$', re.MULTILINE)
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
#static regex for tourney purpose
@ -87,8 +87,8 @@ class Fulltilt(HandHistoryConverter):
re_TourneyBuyInChips = re.compile("Buy-In Chips: (?P<BUYINCHIPS>\d+)")
re_TourneyEntries = re.compile("(?P<ENTRIES>\d+) Entries")
re_TourneyPrizePool = re.compile("Total Prize Pool: (?P<PRIZEPOOL_CURRENCY>\$|)?(?P<PRIZEPOOL>[.,0-9]+)")
re_TourneyRebuyAmount = re.compile("Rebuy: (?P<REBUY_CURRENCY>\$|)?(?P<REBUY_AMOUNT>[.,0-9]+)")
re_TourneyAddOnAmount = re.compile("Add-On: (?P<ADDON_CURRENCY>\$|)?(?P<ADDON_AMOUNT>[.,0-9]+)")
re_TourneyRebuyCost = re.compile("Rebuy: (?P<REBUY_CURRENCY>\$|)?(?P<REBUY_COST>[.,0-9]+)")
re_TourneyAddOnCost = re.compile("Add-On: (?P<ADDON_CURRENCY>\$|)?(?P<ADDON_COST>[.,0-9]+)")
re_TourneyRebuyCount = re.compile("performed (?P<REBUY_COUNT>\d+) Rebuy")
re_TourneyAddOnCount = re.compile("performed (?P<ADDON_COUNT>\d+) Add-On")
re_TourneyRebuysTotal = re.compile("Total Rebuys: (?P<REBUY_TOTAL>\d+)")
@ -96,10 +96,10 @@ class Fulltilt(HandHistoryConverter):
re_TourneyRebuyChips = re.compile("Rebuy Chips: (?P<REBUY_CHIPS>\d+)")
re_TourneyAddOnChips = re.compile("Add-On Chips: (?P<ADDON_CHIPS>\d+)")
re_TourneyKOBounty = re.compile("Knockout Bounty: (?P<KO_BOUNTY_CURRENCY>\$|)?(?P<KO_BOUNTY_AMOUNT>[.,0-9]+)")
re_TourneyCountKO = re.compile("received (?P<COUNT_KO>\d+) Knockout Bounty Award(s)?")
re_TourneyKoCount = re.compile("received (?P<COUNT_KO>\d+) Knockout Bounty Award(s)?")
re_TourneyTimeInfo = re.compile("Tournament started: (?P<STARTTIME>.*)\nTournament ((?P<IN_PROGRESS>is still in progress)?|(finished:(?P<ENDTIME>.*))?)$")
re_TourneyPlayersSummary = re.compile("^(?P<RANK>(Still Playing|\d+))( - |: )(?P<PNAME>[^\n,]+)(, )?(?P<WINNING_CURRENCY>\$|)?(?P<WINNING>[.\d]+)?", re.MULTILINE)
re_TourneysPlayersSummary = re.compile("^(?P<RANK>(Still Playing|\d+))( - |: )(?P<PNAME>[^\n,]+)(, )?(?P<WINNING_CURRENCY>\$|)?(?P<WINNING>[.\d]+)?", re.MULTILINE)
re_TourneyHeroFinishingP = re.compile("(?P<HERO_NAME>.*) finished in (?P<HERO_FINISHING_POS>\d+)(st|nd|rd|th) place")
#TODO: See if we need to deal with play money tourney summaries -- Not right now (they shouldn't pass the re_TourneyInfo)
@ -264,7 +264,7 @@ class Fulltilt(HandHistoryConverter):
if hand.gametype['type'] == "ring" :
m = self.re_PlayerInfo.finditer(pre)
else: #if hand.gametype['type'] == "tour"
m = self.re_TourneyPlayerInfo.finditer(pre)
m = self.re_TourneysPlayerInfo.finditer(pre)
for a in m:
hand.addPlayer(int(a.group('SEAT')), a.group('PNAME'), a.group('CASH'))
@ -430,7 +430,7 @@ class Fulltilt(HandHistoryConverter):
if m:
# info list should be 2 lines : Tourney infos & Finsihing postions with winnings
if (len(summaryInfoList) != 2 ):
log.info("Too many lines (%d) in file '%s' : '%s'" % (len(summaryInfoList), self.in_path, summaryInfoList) )
log.info("Too many or too few lines (%d) in file '%s' : '%s'" % (len(summaryInfoList), self.in_path, summaryInfoList) )
self.status = False
else:
self.tourney = Tourney.Tourney(sitename = self.sitename, gametype = None, summaryText = summaryInfoList, builtFrom = "HHC")
@ -566,8 +566,8 @@ class Fulltilt(HandHistoryConverter):
dictRegex = { "BUYINCHIPS" : self.re_TourneyBuyInChips,
"ENTRIES" : self.re_TourneyEntries,
"PRIZEPOOL" : self.re_TourneyPrizePool,
"REBUY_AMOUNT" : self.re_TourneyRebuyAmount,
"ADDON_AMOUNT" : self.re_TourneyAddOnAmount,
"REBUY_COST" : self.re_TourneyRebuyCost,
"ADDON_COST" : self.re_TourneyAddOnCost,
"REBUY_TOTAL" : self.re_TourneyRebuysTotal,
"ADDONS_TOTAL" : self.re_TourneyAddOnsTotal,
"REBUY_CHIPS" : self.re_TourneyRebuyChips,
@ -580,10 +580,10 @@ class Fulltilt(HandHistoryConverter):
dictHolders = { "BUYINCHIPS" : "buyInChips",
"ENTRIES" : "entries",
"PRIZEPOOL" : "prizepool",
"REBUY_AMOUNT" : "rebuyAmount",
"ADDON_AMOUNT" : "addOnAmount",
"REBUY_TOTAL" : "totalRebuys",
"ADDONS_TOTAL" : "totalAddOns",
"REBUY_COST" : "rebuyCost",
"ADDON_COST" : "addOnCost",
"REBUY_TOTAL" : "totalRebuyCount",
"ADDONS_TOTAL" : "totalAddOnCount",
"REBUY_CHIPS" : "rebuyChips",
"ADDON_CHIPS" : "addOnChips",
"STARTTIME" : "starttime",
@ -607,42 +607,41 @@ class Fulltilt(HandHistoryConverter):
if m is not None:
mg = m.groupdict()
if mg['REBUY_COUNT'] is not None :
tourney.countRebuys.update( { tourney.hero : Decimal(mg['REBUY_COUNT']) } )
tourney.rebuyCounts.update( { tourney.hero : Decimal(mg['REBUY_COUNT']) } )
m = self.re_TourneyAddOnCount.search(tourneyText)
if m is not None:
mg = m.groupdict()
if mg['ADDON_COUNT'] is not None :
tourney.countAddOns.update( { tourney.hero : Decimal(mg['ADDON_COUNT']) } )
m = self.re_TourneyCountKO.search(tourneyText)
tourney.addOnCounts.update( { tourney.hero : Decimal(mg['ADDON_COUNT']) } )
m = self.re_TourneyKoCount.search(tourneyText)
if m is not None:
mg = m.groupdict()
if mg['COUNT_KO'] is not None :
tourney.countKO.update( { tourney.hero : Decimal(mg['COUNT_KO']) } )
tourney.koCounts.update( { tourney.hero : Decimal(mg['COUNT_KO']) } )
# Deal with money amounts
tourney.koBounty = 100*Decimal(re.sub(u',', u'', "%s" % tourney.koBounty))
tourney.prizepool = 100*Decimal(re.sub(u',', u'', "%s" % tourney.prizepool))
tourney.rebuyAmount = 100*Decimal(re.sub(u',', u'', "%s" % tourney.rebuyAmount))
tourney.addOnAmount = 100*Decimal(re.sub(u',', u'', "%s" % tourney.addOnAmount))
tourney.rebuyCost = 100*Decimal(re.sub(u',', u'', "%s" % tourney.rebuyCost))
tourney.addOnCost = 100*Decimal(re.sub(u',', u'', "%s" % tourney.addOnCost))
# Calculate payin amounts and update winnings -- not possible to take into account nb of rebuys, addons or Knockouts for other players than hero on FTP
for p in tourney.players :
tourney.payinAmounts[p] = tourney.buyin + tourney.fee + (tourney.rebuyAmount * tourney.countRebuys[p]) + (tourney.addOnAmount * tourney.countAddOns[p])
tourney.payinAmounts[p] = tourney.buyin + tourney.fee + (tourney.rebuyCost * tourney.rebuyCounts[p]) + (tourney.addOnCost * tourney.addOnCounts[p])
#print " player %s : payinAmount = %d" %( p, tourney.payinAmounts[p])
if tourney.isKO :
#tourney.incrementPlayerWinnings(tourney.players[p], Decimal(tourney.koBounty)*Decimal(tourney.countKO[p]))
tourney.winnings[p] += Decimal(tourney.koBounty)*Decimal(tourney.countKO[p])
#tourney.incrementPlayerWinnings(tourney.players[p], Decimal(tourney.koBounty)*Decimal(tourney.koCounts[p]))
tourney.winnings[p] += Decimal(tourney.koBounty)*Decimal(tourney.koCounts[p])
#print "player %s : winnings %d" % (p, tourney.winnings[p])
#print mg
return True
#end def determineTourneyType
def getPlayersPositionsAndWinnings(self, tourney):
playersText = tourney.summaryText[1]
#print "Examine : '%s'" %(playersText)
m = self.re_TourneyPlayersSummary.finditer(playersText)
m = self.re_TourneysPlayersSummary.finditer(playersText)
for a in m:
if a.group('PNAME') is not None and a.group('RANK') is not None:
@ -656,7 +655,7 @@ class Fulltilt(HandHistoryConverter):
else:
winnings = "0"
tourney.addPlayer(rank, a.group('PNAME'), winnings, 0, 0, 0, 0)
tourney.addPlayer(rank, a.group('PNAME'), winnings, "USD", 0, 0, 0, 0) #TODO: make it store actual winnings currency
else:
print "FullTilt: Player finishing stats unreadable : %s" % a

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Returns a dict of SQL statements used in fpdb.
"""
# Copyright 2008-2009, Ray E. Barker
@ -114,18 +115,18 @@ class Sql:
self.query['createSitesTable'] = """CREATE TABLE Sites (
id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
name varchar(32) NOT NULL,
currency char(3) NOT NULL)
code char(2) NOT NULL)
ENGINE=INNODB"""
elif db_server == 'postgresql':
self.query['createSitesTable'] = """CREATE TABLE Sites (
id SERIAL, PRIMARY KEY (id),
name varchar(32),
currency char(3))"""
code char(2))"""
elif db_server == 'sqlite':
self.query['createSitesTable'] = """CREATE TABLE Sites (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
currency TEXT NOT NULL)"""
code TEXT NOT NULL)"""
################################
@ -136,6 +137,7 @@ class Sql:
self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
currency varchar(4) NOT NULL,
type char(4) NOT NULL,
base char(4) NOT NULL,
category varchar(9) NOT NULL,
@ -150,6 +152,7 @@ class Sql:
self.query['createGametypesTable'] = """CREATE TABLE Gametypes (
id SERIAL, PRIMARY KEY (id),
siteId INTEGER, FOREIGN KEY (siteId) REFERENCES Sites(id),
currency varchar(4),
type char(4),
base char(4),
category varchar(9),
@ -163,6 +166,7 @@ class Sql:
self.query['createGametypesTable'] = """CREATE TABLE GameTypes (
id INTEGER PRIMARY KEY,
siteId INTEGER,
currency TEXT,
type TEXT,
base TEXT,
category TEXT,
@ -356,50 +360,80 @@ class Sql:
if db_server == 'mysql':
self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
buyin INT NOT NULL,
fee INT NOT NULL,
maxSeats INT NOT NULL DEFAULT -1,
knockout BOOLEAN NOT NULL DEFAULT False,
rebuyOrAddon BOOLEAN NOT NULL DEFAULT False,
speed varchar(10),
headsUp BOOLEAN NOT NULL DEFAULT False,
shootout BOOLEAN NOT NULL DEFAULT False,
matrix BOOLEAN NOT NULL DEFAULT False,
sng BOOLEAN NOT NULL DEFAULT False
)
id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
siteId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
currency varchar(4) NOT NULL,
buyIn INT NOT NULL,
fee INT NOT NULL,
buyInChips INT NOT NULL,
maxSeats INT NOT NULL DEFAULT -1,
rebuy BOOLEAN NOT NULL DEFAULT False,
rebuyCost INT,
rebuyChips INT,
addOn BOOLEAN NOT NULL DEFAULT False,
addOnCost INT,
addOnChips INT,
knockout BOOLEAN NOT NULL DEFAULT False,
koBounty INT,
speed varchar(10),
headsUp BOOLEAN NOT NULL DEFAULT False,
shootout BOOLEAN NOT NULL DEFAULT False,
matrix BOOLEAN NOT NULL DEFAULT False,
sng BOOLEAN NOT NULL DEFAULT False,
satellite BOOLEAN NOT NULL DEFAULT False,
doubleOrNothing BOOLEAN NOT NULL DEFAULT False,
guarantee INT)
ENGINE=INNODB"""
elif db_server == 'postgresql':
self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
id SERIAL, PRIMARY KEY (id),
siteId INT NOT NULL, FOREIGN KEY (siteId) REFERENCES Sites(id),
currency varchar(4) NOT NULL,
buyin INT NOT NULL,
fee INT NOT NULL,
buyInChips INT NOT NULL,
maxSeats INT NOT NULL DEFAULT -1,
rebuy BOOLEAN NOT NULL DEFAULT False,
rebuyCost INT,
rebuyChips INT,
addOn BOOLEAN NOT NULL DEFAULT False,
addOnCost INT,
addOnChips INT,
knockout BOOLEAN NOT NULL DEFAULT False,
rebuyOrAddon BOOLEAN NOT NULL DEFAULT False,
koBounty INT,
speed varchar(10),
headsUp BOOLEAN NOT NULL DEFAULT False,
shootout BOOLEAN NOT NULL DEFAULT False,
matrix BOOLEAN NOT NULL DEFAULT False,
sng BOOLEAN NOT NULL DEFAULT False
)"""
sng BOOLEAN NOT NULL DEFAULT False,
satellite BOOLEAN NOT NULL DEFAULT False,
doubleOrNothing BOOLEAN NOT NULL DEFAULT False,
guarantee INT)"""
elif db_server == 'sqlite':
self.query['createTourneyTypesTable'] = """CREATE TABLE TourneyTypes (
id INTEGER PRIMARY KEY,
siteId INT NOT NULL,
currency VARCHAR(4) NOT NULL,
buyin INT NOT NULL,
fee INT NOT NULL,
buyInChips INT NOT NULL,
maxSeats INT NOT NULL DEFAULT -1,
rebuy BOOLEAN NOT NULL DEFAULT 0,
rebuyCost INT,
rebuyChips INT,
addOn BOOLEAN NOT NULL DEFAULT 0,
addOnCost INT,
addOnChips INT,
knockout BOOLEAN NOT NULL DEFAULT 0,
rebuyOrAddon BOOLEAN NOT NULL DEFAULT 0,
koBounty INT,
speed TEXT,
headsUp BOOLEAN NOT NULL DEFAULT 0,
shootout BOOLEAN NOT NULL DEFAULT 0,
matrix BOOLEAN NOT NULL DEFAULT 0,
sng BOOLEAN NOT NULL DEFAULT 0
)"""
sng BOOLEAN NOT NULL DEFAULT 0,
satellite BOOLEAN NOT NULL DEFAULT 0,
doubleOrNothing BOOLEAN NOT NULL DEFAULT 0,
guarantee INT)"""
################################
# Create Tourneys
@ -414,16 +448,10 @@ class Sql:
prizepool INT NOT NULL,
startTime DATETIME NOT NULL,
endTime DATETIME,
buyinChips INT,
tourneyName varchar(40),
matrixIdProcessed TINYINT UNSIGNED DEFAULT 0, /* Mask use : 1=Positionnal Winnings|2=Match1|4=Match2|...|pow(2,n)=Matchn */
rebuyChips INT DEFAULT 0,
addonChips INT DEFAULT 0,
rebuyAmount INT DEFAULT 0,
addonAmount INT DEFAULT 0,
totalRebuys INT DEFAULT 0,
totalAddons INT DEFAULT 0,
koBounty INT DEFAULT 0,
totalRebuyCount INT DEFAULT 0,
totalAddOnCount INT DEFAULT 0,
comment TEXT,
commentTs DATETIME)
ENGINE=INNODB"""
@ -436,16 +464,10 @@ class Sql:
prizepool INT,
startTime timestamp without time zone,
endTime timestamp without time zone,
buyinChips INT,
tourneyName varchar(40),
matrixIdProcessed SMALLINT DEFAULT 0, /* Mask use : 1=Positionnal Winnings|2=Match1|4=Match2|...|pow(2,n)=Matchn */
rebuyChips INT DEFAULT 0,
addonChips INT DEFAULT 0,
rebuyAmount INT DEFAULT 0,
addonAmount INT DEFAULT 0,
totalRebuys INT DEFAULT 0,
totalAddons INT DEFAULT 0,
koBounty INT DEFAULT 0,
totalRebuyCount INT DEFAULT 0,
totalAddOnCount INT DEFAULT 0,
comment TEXT,
commentTs timestamp without time zone)"""
elif db_server == 'sqlite':
@ -457,16 +479,10 @@ class Sql:
prizepool INT,
startTime REAL,
endTime REAL,
buyinChips INT,
tourneyName TEXT,
matrixIdProcessed INT UNSIGNED DEFAULT 0, /* Mask use : 1=Positionnal Winnings|2=Match1|4=Match2|...|pow(2,n)=Matchn */
rebuyChips INT DEFAULT 0,
addonChips INT DEFAULT 0,
rebuyAmount INT DEFAULT 0,
addonAmount INT DEFAULT 0,
totalRebuys INT DEFAULT 0,
totalAddons INT DEFAULT 0,
koBounty INT DEFAULT 0,
totalRebuyCount INT DEFAULT 0,
totalAddOnCount INT DEFAULT 0,
comment TEXT,
commentTs REAL)"""
################################
@ -613,7 +629,7 @@ class Sql:
totalProfit INT,
comment text,
commentTs timestamp without time zone,
tourneysPlayersId BIGINT,
tourneysPlayersId BIGINT, FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id),
tourneyTypeId INT NOT NULL DEFAULT 1, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
wonWhenSeenStreet1 FLOAT,
@ -703,9 +719,7 @@ class Sql:
street3Raises SMALLINT,
street4Raises SMALLINT,
actionString VARCHAR(15),
FOREIGN KEY (tourneysPlayersId) REFERENCES TourneysPlayers(id))"""
actionString VARCHAR(15))"""
elif db_server == 'sqlite':
self.query['createHandsPlayersTable'] = """CREATE TABLE HandsPlayers (
id INTEGER PRIMARY KEY,
@ -819,7 +833,7 @@ class Sql:
street2Raises INT,
street3Raises INT,
street4Raises INT,
actionString REAL)
actionString VARCHAR(15))
"""
@ -835,9 +849,10 @@ class Sql:
payinAmount INT NOT NULL,
rank INT NOT NULL,
winnings INT NOT NULL,
nbRebuys INT DEFAULT 0,
nbAddons INT DEFAULT 0,
nbKO INT DEFAULT 0,
winningsCurrency VARCHAR(4) NOT NULL,
rebuyCount INT DEFAULT 0,
addOnCount INT DEFAULT 0,
koCount INT DEFAULT 0,
comment TEXT,
commentTs DATETIME)
ENGINE=INNODB"""
@ -849,9 +864,10 @@ class Sql:
payinAmount INT,
rank INT,
winnings INT,
nbRebuys INT DEFAULT 0,
nbAddons INT DEFAULT 0,
nbKO INT DEFAULT 0,
winningsCurrency VARCHAR(4),
rebuyCount INT DEFAULT 0,
addOnCount INT DEFAULT 0,
koCount INT DEFAULT 0,
comment TEXT,
commentTs timestamp without time zone)"""
elif db_server == 'sqlite':
@ -862,9 +878,10 @@ class Sql:
payinAmount INT,
rank INT,
winnings INT,
nbRebuys INT DEFAULT 0,
nbAddons INT DEFAULT 0,
nbKO INT DEFAULT 0,
winningsCurrency VARCHAR(4),
rebuyCount INT DEFAULT 0,
addOnCount INT DEFAULT 0,
koCount INT DEFAULT 0,
comment TEXT,
commentTs timestamp without time zone,
FOREIGN KEY (tourneyId) REFERENCES Tourneys(id),
@ -1249,13 +1266,13 @@ class Sql:
if db_server == 'mysql':
self.query['addTTypesIndex'] = """ALTER TABLE TourneyTypes ADD UNIQUE INDEX tourneytypes_all(buyin, fee
, maxSeats, knockout, rebuyOrAddon, speed, headsUp, shootout, matrix, sng)"""
, maxSeats, knockout, rebuy, addOn, speed, headsUp, shootout, matrix, sng)"""
elif db_server == 'postgresql':
self.query['addTTypesIndex'] = """CREATE UNIQUE INDEX tourneyTypes_all ON TourneyTypes (buyin, fee
, maxSeats, knockout, rebuyOrAddon, speed, headsUp, shootout, matrix, sng)"""
, maxSeats, knockout, rebuy, addOn, speed, headsUp, shootout, matrix, sng)"""
elif db_server == 'sqlite':
self.query['addTTypesIndex'] = """CREATE UNIQUE INDEX tourneyTypes_all ON TourneyTypes (buyin, fee
, maxSeats, knockout, rebuyOrAddon, speed, headsUp, shootout, matrix, sng)"""
, maxSeats, knockout, rebuy, addOn, speed, headsUp, shootout, matrix, sng)"""
self.query['get_last_hand'] = "select max(id) from Hands"
@ -3559,9 +3576,9 @@ class Sql:
"""
self.query['insertGameTypes'] = """INSERT INTO Gametypes
(siteId, type, base, category, limitType
(siteId, currency, type, base, category, limitType
,hiLo, smallBlind, bigBlind, smallBet, bigBet)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"""
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"""
self.query['isAlreadyInDB'] = """SELECT id FROM Hands
WHERE gametypeId=%s AND siteHandNo=%s
@ -3572,7 +3589,8 @@ class Sql:
tt.fee,
tt.maxSeats,
tt.knockout,
tt.rebuyOrAddon,
tt.rebuy,
tt.addOn,
tt.speed,
tt.headsUp,
tt.shootout,
@ -3588,7 +3606,8 @@ class Sql:
AND buyin=%s
AND fee=%s
AND knockout=%s
AND rebuyOrAddon=%s
AND rebuy=%s
AND addOn=%s
AND speed=%s
AND headsUp=%s
AND shootout=%s
@ -3596,9 +3615,9 @@ class Sql:
"""
self.query['insertTourneyTypes'] = """INSERT INTO TourneyTypes
(siteId, buyin, fee, knockout, rebuyOrAddon
(siteId, buyin, fee, knockout, rebuy, addOn
,speed, headsUp, shootout, matrix)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
"""
self.query['getTourney'] = """SELECT t.id,
@ -3607,16 +3626,10 @@ class Sql:
t.prizepool,
t.startTime,
t.endTime,
t.buyinChips,
t.tourneyName,
t.matrixIdProcessed,
t.rebuyChips,
t.addonChips,
t.rebuyAmount,
t.addonAmount,
t.totalRebuys,
t.totalAddons,
t.koBounty,
t.totalRebuyCount,
t.totalAddOnCount,
t.comment
FROM Tourneys t
INNER JOIN TourneyTypes tt ON (t.tourneyTypeId = tt.id)
@ -3625,11 +3638,10 @@ class Sql:
self.query['insertTourney'] = """INSERT INTO Tourneys
(tourneyTypeId, siteTourneyNo, entries, prizepool,
startTime, endTime, buyinChips, tourneyName, matrixIdProcessed,
rebuyChips, addonChips, rebuyAmount, addonAmount, totalRebuys,
totalAddons, koBounty, comment, commentTs)
startTime, endTime, tourneyName, matrixIdProcessed,
totalRebuyCount, totalAddOnCount, comment, commentTs)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s, %s)
%s, %s)
"""
self.query['updateTourney'] = """UPDATE Tourneys
@ -3638,16 +3650,10 @@ class Sql:
prizepool = %s,
startTime = %s,
endTime = %s,
buyinChips = %s,
tourneyName = %s,
matrixIdProcessed = %s,
rebuyChips = %s,
addonChips = %s,
rebuyAmount = %s,
addonAmount = %s,
totalRebuys = %s,
totalAddons = %s,
koBounty = %s,
totalRebuyCount = %s,
totalAddOnCount = %s,
comment = %s,
commentTs = %s
WHERE id=%s
@ -3657,9 +3663,10 @@ class Sql:
payinAmount,
rank,
winnings,
nbRebuys,
nbAddons,
nbKO,
winningsCurrency,
rebuyCount,
addOnCount,
koCount,
comment,
commentTs
FROM TourneysPlayers
@ -3670,17 +3677,18 @@ class Sql:
SET payinAmount = %s,
rank = %s,
winnings = %s,
nbRebuys = %s,
nbAddons = %s,
nbKO = %s,
winningsCurrency = %s,
rebuyCount = %s,
addOnCount = %s,
koCount = %s,
comment = %s,
commentTs = %s
WHERE id=%s
"""
self.query['insertTourneysPlayers'] = """INSERT INTO TourneysPlayers
(tourneyId, playerId, payinAmount, rank, winnings, nbRebuys, nbAddons, nbKO, comment, commentTs)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
(tourneyId, playerId, payinAmount, rank, winnings, winningsCurrency, rebuyCount, addOnCount, koCount, comment, commentTs)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
"""
self.query['selectHandsPlayersWithWrongTTypeId'] = """SELECT id

View File

@ -1,4 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2009 Eric Blade, and the FPDB team.
@ -51,7 +52,7 @@ class SummaryParser(htmllib.HTMLParser): # derive new HTML parser
self.nextPool = False
self.TourneyPool = None
self.nextPlayers = False
self.TourneyPlayers = None
self.TourneysPlayers = None
self.nextAllowRebuys = False
self.TourneyRebuys = None
self.parseResultsA = False
@ -134,7 +135,7 @@ class SummaryParser(htmllib.HTMLParser): # derive new HTML parser
if not self.nextPlayers and x == "Player Count:":
self.nextPlayers = True
elif self.nextPlayers:
self.TourneyPlayers = x
self.TourneysPlayers = x
self.nextPlayers = False
if not self.nextAllowRebuys and x == "Rebuys possible?:":
@ -179,7 +180,7 @@ class EverleafSummary:
print "site=",self.parser.SiteName, "tourneyname=", self.parser.TourneyName, "tourneyid=", self.parser.TourneyId
print "start time=",self.parser.TourneyStartTime, "end time=",self.parser.TourneyEndTime
print "structure=", self.parser.TourneyStructure, "game type=",self.parser.TourneyGameType
print "buy-in=", self.parser.TourneyBuyIn, "rebuys=", self.parser.TourneyRebuys, "total players=", self.parser.TourneyPlayers, "pool=", self.parser.TourneyPool
print "buy-in=", self.parser.TourneyBuyIn, "rebuys=", self.parser.TourneyRebuys, "total players=", self.parser.TourneysPlayers, "pool=", self.parser.TourneyPool
print "results=", self.parser.Results

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""TourneyTracker.py
Based on HUD_main .. who knows if we want to actually use this or not
"""
@ -86,7 +87,7 @@ class Tournament:
self.buyin = summary.parser.TourneyBuyIn # need to remember to parse the Fee out of this and move it to self.fee
self.rebuys = (summary.parser.TourneyRebuys == "yes")
self.prizepool = summary.parser.TourneyPool
self.numplayers = summary.parser.TourneyPlayers
self.numplayers = summary.parser.TourneysPlayers
self.openwindow() # let's start by getting any info we need.. meh

View File

@ -1,4 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#Copyright 2009 Stephane Alessio
#This program is free software: you can redistribute it and/or modify
@ -73,21 +74,26 @@ class Tourney(object):
self.subTourneyFee = None
self.rebuyChips = 0
self.addOnChips = 0
self.rebuyAmount = 0
self.addOnAmount = 0
self.totalRebuys = 0
self.totalAddOns = 0
self.rebuyCost = 0
self.addOnCost = 0
self.totalRebuyCount = 0
self.totalAddOnCount = 0
self.koBounty = 0
self.tourneyComment = None
self.players = []
self.isSng = False
self.isSatellite = False
self.isDoubleOrNothing = False
self.guarantee = 0
# Collections indexed by player names
self.finishPositions = {}
self.winnings = {}
self.winningsCurrency = {}
self.payinAmounts = {}
self.countRebuys = {}
self.countAddOns = {}
self.countKO = {}
self.rebuyCounts = {}
self.addOnCounts = {}
self.koCounts = {}
# currency symbol for this summary
self.sym = None
@ -119,12 +125,16 @@ class Tourney(object):
("SUB TOURNEY FEE", self.subTourneyFee),
("REBUY CHIPS", self.rebuyChips),
("ADDON CHIPS", self.addOnChips),
("REBUY AMOUNT", self.rebuyAmount),
("ADDON AMOUNT", self.addOnAmount),
("TOTAL REBUYS", self.totalRebuys),
("TOTAL ADDONS", self.totalAddOns),
("REBUY COST", self.rebuyCost),
("ADDON COST", self.addOnCost),
("TOTAL REBUYS", self.totalRebuyCount),
("TOTAL ADDONS", self.totalAddOnCount),
("KO BOUNTY", self.koBounty),
("TOURNEY COMMENT", self.tourneyComment)
("TOURNEY COMMENT", self.tourneyComment),
("SNG", self.isSng),
("SATELLITE", self.isSatellite),
("DOUBLE OR NOTHING", self.isDoubleOrNothing),
("GUARANTEE", self.guarantee)
)
structs = ( ("GAMETYPE", self.gametype),
@ -132,9 +142,9 @@ class Tourney(object):
("PAYIN AMOUNTS", self.payinAmounts),
("POSITIONS", self.finishPositions),
("WINNINGS", self.winnings),
("COUNT REBUYS", self.countRebuys),
("COUNT ADDONS", self.countAddOns),
("NB OF KO", self.countKO)
("COUNT REBUYS", self.rebuyCounts),
("COUNT ADDONS", self.addOnCounts),
("NB OF KO", self.koCounts)
)
str = ''
for (name, var) in vars:
@ -161,18 +171,18 @@ class Tourney(object):
# Starttime may not match the one in the Summary file : HH = time of the first Hand / could be slighltly different from the one in the summary file
# Note: If the TourneyNo could be a unique id .... this would really be a relief to deal with matrix matches ==> Ask on the IRC / Ask Fulltilt ??
dbTourneyTypeId = db.tRecogniseTourneyType(self)
dbTourneyTypeId = db.recogniseTourneyType(self)
logging.debug("Tourney Type ID = %d" % dbTourneyTypeId)
dbTourneyId = db.tRecognizeTourney(self, dbTourneyTypeId)
logging.debug("Tourney ID = %d" % dbTourneyId)
dbTourneysPlayersIds = db.tStoreTourneyPlayers(self, dbTourneyId)
dbTourneysPlayersIds = db.tStoreTourneysPlayers(self, dbTourneyId)
logging.debug("TourneysPlayersId = %s" % dbTourneysPlayersIds)
db.tUpdateTourneysHandsPlayers(self, dbTourneysPlayersIds, dbTourneyTypeId)
logging.debug("tUpdateTourneysHandsPlayers done")
logging.debug("Tourney Insert done")
# TO DO : Return what has been done (tourney created, updated, nothing)
# ?? stored = 1 if tourney is fully created / duplicates = 1, if everything was already here and correct / partial=1 if some things were already here (between tourney, tourneyPlayers and handsplayers)
# ?? stored = 1 if tourney is fully created / duplicates = 1, if everything was already here and correct / partial=1 if some things were already here (between tourney, tourneysPlayers and handsPlayers)
# if so, prototypes may need changes to know what has been done or make some kind of dict in Tourney object that could be updated during the insert process to store that information
stored = 0
duplicates = 0
@ -181,83 +191,12 @@ class Tourney(object):
ttime = 0
return (stored, duplicates, partial, errors, ttime)
def old_insert_from_Hand(self, db):
""" Function to insert Hand into database
Should not commit, and do minimal selects. Callers may want to cache commits
db: a connected Database object"""
# TODO:
# Players - base playerid and siteid tuple
sqlids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId)
#Gametypes
gtid = db.getGameTypeId(self.siteId, self.gametype)
# HudCache data to come from DerivedStats class
# HandsActions - all actions for all players for all streets - self.actions
# Hands - Summary information of hand indexed by handId - gameinfo
#This should be moved to prepInsert
hh = {}
hh['siteHandNo'] = self.handid
hh['handStart'] = self.starttime
hh['gameTypeId'] = gtid
# seats TINYINT NOT NULL,
hh['tableName'] = self.tablename
hh['maxSeats'] = self.maxseats
hh['seats'] = len(sqlids)
# Flop turn and river may all be empty - add (likely) too many elements and trim with range
boardcards = self.board['FLOP'] + self.board['TURN'] + self.board['RIVER'] + [u'0x', u'0x', u'0x', u'0x', u'0x']
cards = [Card.encodeCard(c) for c in boardcards[0:5]]
hh['boardcard1'] = cards[0]
hh['boardcard2'] = cards[1]
hh['boardcard3'] = cards[2]
hh['boardcard4'] = cards[3]
hh['boardcard5'] = cards[4]
# texture smallint,
# playersVpi SMALLINT NOT NULL, /* num of players vpi */
# Needs to be recorded
# playersAtStreet1 SMALLINT NOT NULL, /* num of players seeing flop/street4 */
# Needs to be recorded
# playersAtStreet2 SMALLINT NOT NULL,
# Needs to be recorded
# playersAtStreet3 SMALLINT NOT NULL,
# Needs to be recorded
# playersAtStreet4 SMALLINT NOT NULL,
# Needs to be recorded
# playersAtShowdown SMALLINT NOT NULL,
# Needs to be recorded
# street0Raises TINYINT NOT NULL, /* num small bets paid to see flop/street4, including blind */
# Needs to be recorded
# street1Raises TINYINT NOT NULL, /* num small bets paid to see turn/street5 */
# Needs to be recorded
# street2Raises TINYINT NOT NULL, /* num big bets paid to see river/street6 */
# Needs to be recorded
# street3Raises TINYINT NOT NULL, /* num big bets paid to see sd/street7 */
# Needs to be recorded
# street4Raises TINYINT NOT NULL, /* num big bets paid to see showdown */
# Needs to be recorded
#print "DEBUG: self.getStreetTotals = (%s, %s, %s, %s, %s)" % self.getStreetTotals()
#FIXME: Pot size still in decimal, needs to be converted to cents
(hh['street1Pot'], hh['street2Pot'], hh['street3Pot'], hh['street4Pot'], hh['showdownPot']) = self.getStreetTotals()
# comment TEXT,
# commentTs DATETIME
#print hh
handid = db.storeHand(hh)
# HandsPlayers - ? ... Do we fix winnings?
# Tourneys ?
# TourneysPlayers
pass
def select(self, tourneyId):
""" Function to create Tourney object from database """
def addPlayer(self, rank, name, winnings, payinAmount, nbRebuys, nbAddons, nbKO):
def addPlayer(self, rank, name, winnings, winningsCurrency, payinAmount, rebuyCount, addOnCount, koCount):
"""\
Adds a player to the tourney, and initialises data structures indexed by player.
rank (int) indicating the finishing rank (can be -1 if unknown)
@ -268,10 +207,11 @@ winnings (decimal) the money the player ended the tourney with (can be 0, or
self.players.append(name)
self.finishPositions.update( { name : Decimal(rank) } )
self.winnings.update( { name : Decimal(winnings) } )
self.winningsCurrency.update( { name : winningsCurrency } )
self.payinAmounts.update( {name : Decimal(payinAmount) } )
self.countRebuys.update( {name: Decimal(nbRebuys) } )
self.countAddOns.update( {name: Decimal(nbAddons) } )
self.countKO.update( {name : Decimal(nbKO) } )
self.rebuyCounts.update( {name: Decimal(rebuyCount) } )
self.addOnCounts.update( {name: Decimal(addOnCount) } )
self.koCounts.update( {name : Decimal(koCount) } )
def incrementPlayerWinnings(self, name, additionnalWinnings):

View File

@ -36,7 +36,10 @@ if os.name == 'nt' and sys.version[0:3] not in ('2.5', '2.6') and '-r' not in sy
os.environ['PATH'] = tmppath
print "Python " + sys.version[0:3] + ' - press return to continue\n'
sys.stdin.readline()
os.execvpe('pythonw.exe', ('pythonw.exe', 'fpdb.pyw', '-r'), os.environ) # first arg is ignored (name of program being run)
if os.name=='nt':
os.execvpe('pythonw.exe', ('pythonw.exe', 'fpdb.pyw', '-r'), os.environ) # first arg is ignored (name of program being run)
else:
os.execvpe('python', ('python', 'fpdb.pyw', '-r'), os.environ) # first arg is ignored (name of program being run)
else:
print "\npython 2.5 not found, please install python 2.5 or 2.6 for fpdb\n"
raw_input("Press ENTER to continue.")

1
readme.txt Normal file
View File

@ -0,0 +1 @@
Please visit http://fpdb.sourceforge.net for documentation, tips and help.

View File

@ -1,4 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#Copyright 2008 Carl Gherardi
#This program is free software: you can redistribute it and/or modify