Merge branch 'chaz' of git://github.com/ChazDazzle/fpdb-chaz
This commit is contained in:
commit
a964b17de6
|
@ -126,6 +126,7 @@ class Database:
|
||||||
, {'tab':'Hands', 'col':'gametypeId', 'drop':0} # mct 22/3/09
|
, {'tab':'Hands', 'col':'gametypeId', 'drop':0} # mct 22/3/09
|
||||||
#, {'tab':'Hands', 'col':'siteHandNo', 'drop':0} unique indexes not dropped
|
#, {'tab':'Hands', 'col':'siteHandNo', 'drop':0} unique indexes not dropped
|
||||||
, {'tab':'HandsActions', 'col':'handsPlayerId', 'drop':0}
|
, {'tab':'HandsActions', 'col':'handsPlayerId', 'drop':0}
|
||||||
|
, {'tab':'HandsActions', 'col':'actionId', 'drop':1}
|
||||||
, {'tab':'HandsPlayers', 'col':'handId', 'drop':1}
|
, {'tab':'HandsPlayers', 'col':'handId', 'drop':1}
|
||||||
, {'tab':'HandsPlayers', 'col':'playerId', 'drop':1}
|
, {'tab':'HandsPlayers', 'col':'playerId', 'drop':1}
|
||||||
, {'tab':'HandsPlayers', 'col':'tourneysPlayersId', 'drop':0}
|
, {'tab':'HandsPlayers', 'col':'tourneysPlayersId', 'drop':0}
|
||||||
|
@ -149,6 +150,8 @@ class Database:
|
||||||
, {'tab':'HandsPlayers', 'col':'handId', 'drop':0}
|
, {'tab':'HandsPlayers', 'col':'handId', 'drop':0}
|
||||||
, {'tab':'HandsPlayers', 'col':'playerId', 'drop':0}
|
, {'tab':'HandsPlayers', 'col':'playerId', 'drop':0}
|
||||||
, {'tab':'HandsPlayers', 'col':'tourneysPlayersId', 'drop':0}
|
, {'tab':'HandsPlayers', 'col':'tourneysPlayersId', 'drop':0}
|
||||||
|
, {'tab':'HandsActions', 'col':'handsPlayerId', 'drop':0}
|
||||||
|
, {'tab':'HandsActions', 'col':'actionId', 'drop':1}
|
||||||
, {'tab':'HudCache', 'col':'gametypeId', 'drop':1}
|
, {'tab':'HudCache', 'col':'gametypeId', 'drop':1}
|
||||||
, {'tab':'HudCache', 'col':'playerId', 'drop':0}
|
, {'tab':'HudCache', 'col':'playerId', 'drop':0}
|
||||||
, {'tab':'HudCache', 'col':'tourneyTypeId', 'drop':0}
|
, {'tab':'HudCache', 'col':'tourneyTypeId', 'drop':0}
|
||||||
|
@ -172,6 +175,7 @@ class Database:
|
||||||
, {'fktab':'HandsPlayers', 'fkcol':'playerId', 'rtab':'Players', 'rcol':'id', 'drop':1}
|
, {'fktab':'HandsPlayers', 'fkcol':'playerId', 'rtab':'Players', 'rcol':'id', 'drop':1}
|
||||||
, {'fktab':'HandsPlayers', 'fkcol':'tourneysPlayersId','rtab':'TourneysPlayers','rcol':'id', 'drop':1}
|
, {'fktab':'HandsPlayers', 'fkcol':'tourneysPlayersId','rtab':'TourneysPlayers','rcol':'id', 'drop':1}
|
||||||
, {'fktab':'HandsActions', 'fkcol':'handsPlayerId', 'rtab':'HandsPlayers', 'rcol':'id', 'drop':1}
|
, {'fktab':'HandsActions', 'fkcol':'handsPlayerId', 'rtab':'HandsPlayers', 'rcol':'id', 'drop':1}
|
||||||
|
, {'fktab':'HandsActions', 'fkcol':'actionId', 'rtab':'Actions', 'rcol':'id', 'drop':1}
|
||||||
, {'fktab':'HudCache', 'fkcol':'gametypeId', 'rtab':'Gametypes', 'rcol':'id', 'drop':1}
|
, {'fktab':'HudCache', 'fkcol':'gametypeId', 'rtab':'Gametypes', 'rcol':'id', 'drop':1}
|
||||||
, {'fktab':'HudCache', 'fkcol':'playerId', 'rtab':'Players', 'rcol':'id', 'drop':0}
|
, {'fktab':'HudCache', 'fkcol':'playerId', 'rtab':'Players', 'rcol':'id', 'drop':0}
|
||||||
, {'fktab':'HudCache', 'fkcol':'tourneyTypeId', 'rtab':'TourneyTypes', 'rcol':'id', 'drop':1}
|
, {'fktab':'HudCache', 'fkcol':'tourneyTypeId', 'rtab':'TourneyTypes', 'rcol':'id', 'drop':1}
|
||||||
|
@ -181,6 +185,7 @@ class Database:
|
||||||
, {'fktab':'HandsPlayers', 'fkcol':'handId', 'rtab':'Hands', 'rcol':'id', 'drop':1}
|
, {'fktab':'HandsPlayers', 'fkcol':'handId', 'rtab':'Hands', 'rcol':'id', 'drop':1}
|
||||||
, {'fktab':'HandsPlayers', 'fkcol':'playerId', 'rtab':'Players', 'rcol':'id', 'drop':1}
|
, {'fktab':'HandsPlayers', 'fkcol':'playerId', 'rtab':'Players', 'rcol':'id', 'drop':1}
|
||||||
, {'fktab':'HandsActions', 'fkcol':'handsPlayerId', 'rtab':'HandsPlayers', 'rcol':'id', 'drop':1}
|
, {'fktab':'HandsActions', 'fkcol':'handsPlayerId', 'rtab':'HandsPlayers', 'rcol':'id', 'drop':1}
|
||||||
|
, {'fktab':'HandsActions', 'fkcol':'actionId', 'rtab':'Actions', 'rcol':'id', 'drop':1}
|
||||||
, {'fktab':'HudCache', 'fkcol':'gametypeId', 'rtab':'Gametypes', 'rcol':'id', 'drop':1}
|
, {'fktab':'HudCache', 'fkcol':'gametypeId', 'rtab':'Gametypes', 'rcol':'id', 'drop':1}
|
||||||
, {'fktab':'HudCache', 'fkcol':'playerId', 'rtab':'Players', 'rcol':'id', 'drop':0}
|
, {'fktab':'HudCache', 'fkcol':'playerId', 'rtab':'Players', 'rcol':'id', 'drop':0}
|
||||||
, {'fktab':'HudCache', 'fkcol':'tourneyTypeId', 'rtab':'TourneyTypes', 'rcol':'id', 'drop':1}
|
, {'fktab':'HudCache', 'fkcol':'tourneyTypeId', 'rtab':'TourneyTypes', 'rcol':'id', 'drop':1}
|
||||||
|
@ -302,7 +307,7 @@ class Database:
|
||||||
|
|
||||||
tables=self.cursor.execute(self.sql.query['list_tables'])
|
tables=self.cursor.execute(self.sql.query['list_tables'])
|
||||||
tables=self.cursor.fetchall()
|
tables=self.cursor.fetchall()
|
||||||
for table in (u'Autorates', u'Backings', u'Gametypes', u'Hands', u'HandsActions', u'HandsPlayers', u'HudCache', u'Players', u'RawHands', u'RawTourneys', u'Settings', u'Sites', u'TourneyTypes', u'Tourneys', u'TourneysPlayers'):
|
for table in (u'Actions', u'Autorates', u'Backings', u'Gametypes', u'Hands', u'HandsActions', u'HandsPlayers', u'HudCache', u'Players', u'RawHands', u'RawTourneys', u'Settings', u'Sites', u'TourneyTypes', u'Tourneys', u'TourneysPlayers'):
|
||||||
print "table:", table
|
print "table:", table
|
||||||
result+="###################\nTable "+table+"\n###################\n"
|
result+="###################\nTable "+table+"\n###################\n"
|
||||||
rows=self.cursor.execute(self.sql.query['get'+table])
|
rows=self.cursor.execute(self.sql.query['get'+table])
|
||||||
|
@ -1151,6 +1156,7 @@ class Database:
|
||||||
c.execute(self.sql.query['createSettingsTable'])
|
c.execute(self.sql.query['createSettingsTable'])
|
||||||
|
|
||||||
log.debug("Creating tables")
|
log.debug("Creating tables")
|
||||||
|
c.execute(self.sql.query['createActionsTable'])
|
||||||
c.execute(self.sql.query['createSitesTable'])
|
c.execute(self.sql.query['createSitesTable'])
|
||||||
c.execute(self.sql.query['createGametypesTable'])
|
c.execute(self.sql.query['createGametypesTable'])
|
||||||
c.execute(self.sql.query['createPlayersTable'])
|
c.execute(self.sql.query['createPlayersTable'])
|
||||||
|
@ -1422,6 +1428,7 @@ class Database:
|
||||||
def fillDefaultData(self):
|
def fillDefaultData(self):
|
||||||
c = self.get_cursor()
|
c = self.get_cursor()
|
||||||
c.execute("INSERT INTO Settings (version) VALUES (%s);" % (DB_VERSION))
|
c.execute("INSERT INTO Settings (version) VALUES (%s);" % (DB_VERSION))
|
||||||
|
#Fill Sites
|
||||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Full Tilt Poker', 'FT')")
|
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 ('PokerStars', 'PS')")
|
||||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Everleaf', 'EV')")
|
c.execute("INSERT INTO Sites (name,code) VALUES ('Everleaf', 'EV')")
|
||||||
|
@ -1436,6 +1443,22 @@ class Database:
|
||||||
c.execute("INSERT INTO Sites (name,code) VALUES ('PKR', 'PK')")
|
c.execute("INSERT INTO Sites (name,code) VALUES ('PKR', 'PK')")
|
||||||
c.execute("INSERT INTO Sites (name,code) VALUES ('iPoker', 'IP')")
|
c.execute("INSERT INTO Sites (name,code) VALUES ('iPoker', 'IP')")
|
||||||
c.execute("INSERT INTO Sites (name,code) VALUES ('Winamax', 'WM')")
|
c.execute("INSERT INTO Sites (name,code) VALUES ('Winamax', 'WM')")
|
||||||
|
#Fill Actions
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('ante', 'A')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('small blind', 'SB')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('secondsb', 'SSB')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('big blind', 'BB')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('both', 'SBBB')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('calls', 'C')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('raises', 'R')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('bets', 'B')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('stands pat', 'S')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('folds', 'F')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('checks', 'K')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('discards', 'D')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('bringin', 'I')")
|
||||||
|
c.execute("INSERT INTO Actions (name,code) VALUES ('completes', 'P')")
|
||||||
|
|
||||||
#end def fillDefaultData
|
#end def fillDefaultData
|
||||||
|
|
||||||
def rebuild_indexes(self, start=None):
|
def rebuild_indexes(self, start=None):
|
||||||
|
@ -1653,6 +1676,7 @@ class Database:
|
||||||
pp.pprint(pdata)
|
pp.pprint(pdata)
|
||||||
|
|
||||||
inserts = []
|
inserts = []
|
||||||
|
hpid = {}
|
||||||
for p in pdata:
|
for p in pdata:
|
||||||
inserts.append( (hid,
|
inserts.append( (hid,
|
||||||
pids[p],
|
pids[p],
|
||||||
|
@ -1757,39 +1781,41 @@ class Database:
|
||||||
#print "DEBUG: inserts: %s" %inserts
|
#print "DEBUG: inserts: %s" %inserts
|
||||||
#print "DEBUG: q: %s" % q
|
#print "DEBUG: q: %s" % q
|
||||||
c = self.get_cursor()
|
c = self.get_cursor()
|
||||||
c.executemany(q, inserts)
|
|
||||||
|
for r in inserts:
|
||||||
|
c.execute(q, r)
|
||||||
|
hpid[(r[0], r[1])] = self.get_last_insert_id(c)
|
||||||
|
|
||||||
|
return hpid
|
||||||
|
|
||||||
def storeHandsActions(self, hid, pids, adata, printdata = False):
|
def storeHandsActions(self, hid, pids, hpid, adata, printdata = False):
|
||||||
#print "DEBUG: %s %s %s" %(hid, pids, adata)
|
#print "DEBUG: %s %s %s" %(hid, pids, adata)
|
||||||
if printdata:
|
if printdata:
|
||||||
import pprint
|
import pprint
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
pp = pprint.PrettyPrinter(indent=4)
|
||||||
pp.pprint(adata)
|
pp.pprint(adata)
|
||||||
|
|
||||||
#inserts = []
|
inserts = []
|
||||||
#for p in pdata:
|
for a in adata:
|
||||||
# inserts.append( (hid,
|
inserts.append( (hpid[(hid, pids[adata[a]['player']])],
|
||||||
# pids[p],
|
#self.getHandsPlayerId(self.hid, pids[adata[a]['player']]),
|
||||||
# adata[p]['startCash'],
|
adata[a]['street'],
|
||||||
# adata[p]['seatNo'],
|
adata[a]['actionNo'],
|
||||||
# adata[p]['sitout'],
|
adata[a]['streetActionNo'],
|
||||||
# adata[p]['card1'],
|
adata[a]['actionId'],
|
||||||
|
adata[a]['amount'],
|
||||||
#handsPlayerId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
|
adata[a]['raiseTo'],
|
||||||
#street SMALLINT NOT NULL,
|
adata[a]['amountCalled'],
|
||||||
#actionNo SMALLINT NOT NULL,
|
adata[a]['numDiscarded'],
|
||||||
#action CHAR(5) NOT NULL,
|
adata[a]['cardsDiscarded'],
|
||||||
#allIn BOOLEAN NOT NULL,
|
adata[a]['allIn']
|
||||||
#amount INT NOT NULL,
|
) )
|
||||||
|
|
||||||
|
|
||||||
q = self.sql.query['store_hands_actions']
|
q = self.sql.query['store_hands_actions']
|
||||||
#q = q.replace('%s', self.sql.query['placeholder'])
|
q = q.replace('%s', self.sql.query['placeholder'])
|
||||||
|
|
||||||
#print "DEBUG: inserts: %s" %inserts
|
c = self.get_cursor()
|
||||||
#print "DEBUG: q: %s" % q
|
c.executemany(q, inserts)
|
||||||
#c = self.get_cursor()
|
|
||||||
#c.executemany(q, inserts)
|
|
||||||
|
|
||||||
def storeHudCache(self, gid, pids, starttime, pdata):
|
def storeHudCache(self, gid, pids, starttime, pdata):
|
||||||
"""Update cached statistics. If update fails because no record exists, do an insert."""
|
"""Update cached statistics. If update fails because no record exists, do an insert."""
|
||||||
|
|
|
@ -23,13 +23,6 @@ import logging
|
||||||
# logging has been set up in fpdb.py or HUD_main.py, use their settings:
|
# logging has been set up in fpdb.py or HUD_main.py, use their settings:
|
||||||
log = logging.getLogger("parser")
|
log = logging.getLogger("parser")
|
||||||
|
|
||||||
DEBUG = False
|
|
||||||
|
|
||||||
if DEBUG:
|
|
||||||
import pprint
|
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
|
||||||
|
|
||||||
|
|
||||||
class DerivedStats():
|
class DerivedStats():
|
||||||
def __init__(self, hand):
|
def __init__(self, hand):
|
||||||
self.hand = hand
|
self.hand = hand
|
||||||
|
@ -93,17 +86,9 @@ class DerivedStats():
|
||||||
self.assembleHands(self.hand)
|
self.assembleHands(self.hand)
|
||||||
self.assembleHandsPlayers(self.hand)
|
self.assembleHandsPlayers(self.hand)
|
||||||
|
|
||||||
if DEBUG:
|
if self.hand.saveActions:
|
||||||
self.assembleHandsActions(self.hand)
|
self.assembleHandsActions(self.hand)
|
||||||
|
|
||||||
if DEBUG:
|
|
||||||
#print "Hands:"
|
|
||||||
#pp.pprint(self.hands)
|
|
||||||
#print "HandsPlayers:"
|
|
||||||
#pp.pprint(self.handsplayers)
|
|
||||||
print "HandsActions:"
|
|
||||||
pp.pprint(self.handsactions)
|
|
||||||
|
|
||||||
def getHands(self):
|
def getHands(self):
|
||||||
return self.hands
|
return self.hands
|
||||||
|
|
||||||
|
@ -216,9 +201,35 @@ class DerivedStats():
|
||||||
# Squeeze, Ratchet?
|
# Squeeze, Ratchet?
|
||||||
|
|
||||||
def assembleHandsActions(self, hand):
|
def assembleHandsActions(self, hand):
|
||||||
print "DEBUG: hand.actions"
|
k = 0
|
||||||
pp.pprint(hand.actions)
|
for i, street in enumerate(hand.actionStreets):
|
||||||
pass
|
for j, act in enumerate(hand.actions[street]):
|
||||||
|
k += 1
|
||||||
|
self.handsactions[k] = {}
|
||||||
|
#default values
|
||||||
|
self.handsactions[k]['amount'] = 0
|
||||||
|
self.handsactions[k]['raiseTo'] = 0
|
||||||
|
self.handsactions[k]['amountCalled'] = 0
|
||||||
|
self.handsactions[k]['numDiscarded'] = 0
|
||||||
|
self.handsactions[k]['cardsDiscarded'] = None
|
||||||
|
self.handsactions[k]['allIn'] = False
|
||||||
|
#Insert values from hand.actions
|
||||||
|
self.handsactions[k]['player'] = act[0]
|
||||||
|
self.handsactions[k]['street'] = i-1
|
||||||
|
self.handsactions[k]['actionNo'] = k
|
||||||
|
self.handsactions[k]['streetActionNo'] = (j+1)
|
||||||
|
self.handsactions[k]['actionId'] = hand.ACTION[act[1]]
|
||||||
|
if act[1] not in ('discards') and len(act) > 2:
|
||||||
|
self.handsactions[k]['amount'] = int(100 * act[2])
|
||||||
|
if act[1] in ('raises', 'completes'):
|
||||||
|
self.handsactions[k]['raiseTo'] = int(100 * act[3])
|
||||||
|
self.handsactions[k]['amountCalled'] = int(100 * act[4])
|
||||||
|
if act[1] in ('discards'):
|
||||||
|
self.handsactions[k]['numDiscarded'] = int(act[2])
|
||||||
|
if act[1] in ('discards') and len(act) > 3:
|
||||||
|
self.handsactions[k]['cardsDiscarded'] = act[3]
|
||||||
|
if len(act) > 3 and act[1] not in ('discards'):
|
||||||
|
self.handsactions[k]['allIn'] = act[-1]
|
||||||
|
|
||||||
def setPositions(self, hand):
|
def setPositions(self, hand):
|
||||||
"""Sets the position for each player in HandsPlayers
|
"""Sets the position for each player in HandsPlayers
|
||||||
|
|
|
@ -49,11 +49,14 @@ class Hand(object):
|
||||||
LCS = {'H':'h', 'D':'d', 'C':'c', 'S':'s'}
|
LCS = {'H':'h', 'D':'d', 'C':'c', 'S':'s'}
|
||||||
SYMBOL = {'USD': '$', 'EUR': u'$', 'GBP': '$', 'T$': '', 'play': ''}
|
SYMBOL = {'USD': '$', 'EUR': u'$', 'GBP': '$', 'T$': '', 'play': ''}
|
||||||
MS = {'horse' : 'HORSE', '8game' : '8-Game', 'hose' : 'HOSE', 'ha': 'HA'}
|
MS = {'horse' : 'HORSE', '8game' : '8-Game', 'hose' : 'HOSE', 'ha': 'HA'}
|
||||||
|
ACTION = {'ante': 1, 'small blind': 2, 'secondsb': 3, 'big blind': 4, 'both': 5, 'calls': 6, 'raises': 7,
|
||||||
|
'bets': 8, 'stands pat': 9, 'folds': 10, 'checks': 11, 'discards': 12, 'bringin': 13, 'completes': 14}
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, config, sitename, gametype, handText, builtFrom = "HHC"):
|
def __init__(self, config, sitename, gametype, handText, builtFrom = "HHC"):
|
||||||
#log.debug( _("Hand.init(): handText is ") + str(handText) )
|
#log.debug( _("Hand.init(): handText is ") + str(handText) )
|
||||||
self.config = config
|
self.config = config
|
||||||
|
self.saveActions = self.config.get_import_parameters().get('saveActions')
|
||||||
#log = Configuration.get_logger("logging.conf", "db", log_dir=self.config.dir_log)
|
#log = Configuration.get_logger("logging.conf", "db", log_dir=self.config.dir_log)
|
||||||
self.sitename = sitename
|
self.sitename = sitename
|
||||||
self.siteId = self.config.get_site_id(sitename)
|
self.siteId = self.config.get_site_id(sitename)
|
||||||
|
@ -65,6 +68,7 @@ class Hand(object):
|
||||||
self.cancelled = False
|
self.cancelled = False
|
||||||
self.dbid_hands = 0
|
self.dbid_hands = 0
|
||||||
self.dbid_pids = None
|
self.dbid_pids = None
|
||||||
|
self.dbid_hpid = None
|
||||||
self.dbid_gt = 0
|
self.dbid_gt = 0
|
||||||
self.tablename = ""
|
self.tablename = ""
|
||||||
self.hero = ""
|
self.hero = ""
|
||||||
|
@ -262,10 +266,11 @@ db: a connected Database object"""
|
||||||
hh['seats'] = len(self.dbid_pids)
|
hh['seats'] = len(self.dbid_pids)
|
||||||
|
|
||||||
self.dbid_hands = db.storeHand(hh)
|
self.dbid_hands = db.storeHand(hh)
|
||||||
db.storeHandsPlayers(self.dbid_hands, self.dbid_pids, self.stats.getHandsPlayers(), printdata = printtest)
|
self.dbid_hpid = db.storeHandsPlayers(self.dbid_hands, self.dbid_pids,
|
||||||
# TODO HandsActions - all actions for all players for all streets - self.actions
|
self.stats.getHandsPlayers(), printdata = printtest)
|
||||||
# HudCache data can be generated from HandsActions (HandsPlayers?)
|
if self.saveActions:
|
||||||
#db.storeHandsActions(self.dbid_hands, self.dbid_pids, self.stats.getHandsActions(), printdata = printtest)
|
db.storeHandsActions(self.dbid_hands, self.dbid_pids, self.dbid_hpid,
|
||||||
|
self.stats.getHandsActions(), printdata = printtest)
|
||||||
else:
|
else:
|
||||||
log.info(_("Hand.insert(): hid #: %s is a duplicate") % hh['siteHandNo'])
|
log.info(_("Hand.insert(): hid #: %s is a duplicate") % hh['siteHandNo'])
|
||||||
self.is_duplicate = True # i.e. don't update hudcache
|
self.is_duplicate = True # i.e. don't update hudcache
|
||||||
|
@ -350,7 +355,7 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio
|
||||||
ante = re.sub(u',', u'', ante) #some sites have commas
|
ante = re.sub(u',', u'', ante) #some sites have commas
|
||||||
self.bets['BLINDSANTES'][player].append(Decimal(ante))
|
self.bets['BLINDSANTES'][player].append(Decimal(ante))
|
||||||
self.stacks[player] -= Decimal(ante)
|
self.stacks[player] -= Decimal(ante)
|
||||||
act = (player, 'posts', "ante", ante, self.stacks[player]==0)
|
act = (player, 'ante', Decimal(ante), self.stacks[player]==0)
|
||||||
self.actions['BLINDSANTES'].append(act)
|
self.actions['BLINDSANTES'].append(act)
|
||||||
# self.pot.addMoney(player, Decimal(ante))
|
# self.pot.addMoney(player, Decimal(ante))
|
||||||
self.pot.addCommonMoney(player, Decimal(ante))
|
self.pot.addCommonMoney(player, Decimal(ante))
|
||||||
|
@ -369,7 +374,7 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio
|
||||||
if player is not None:
|
if player is not None:
|
||||||
amount = re.sub(u',', u'', amount) #some sites have commas
|
amount = re.sub(u',', u'', amount) #some sites have commas
|
||||||
self.stacks[player] -= Decimal(amount)
|
self.stacks[player] -= Decimal(amount)
|
||||||
act = (player, 'posts', blindtype, amount, self.stacks[player]==0)
|
act = (player, blindtype, Decimal(amount), self.stacks[player]==0)
|
||||||
self.actions['BLINDSANTES'].append(act)
|
self.actions['BLINDSANTES'].append(act)
|
||||||
|
|
||||||
if blindtype == 'both':
|
if blindtype == 'both':
|
||||||
|
@ -402,7 +407,7 @@ For sites (currently only Carbon Poker) which record "all in" as a special actio
|
||||||
#self.lastBet[street] = Decimal(amount)
|
#self.lastBet[street] = Decimal(amount)
|
||||||
self.stacks[player] -= Decimal(amount)
|
self.stacks[player] -= Decimal(amount)
|
||||||
#print "DEBUG %s calls %s, stack %s" % (player, amount, self.stacks[player])
|
#print "DEBUG %s calls %s, stack %s" % (player, amount, self.stacks[player])
|
||||||
act = (player, 'calls', amount, self.stacks[player]==0)
|
act = (player, 'calls', Decimal(amount), self.stacks[player]==0)
|
||||||
self.actions[street].append(act)
|
self.actions[street].append(act)
|
||||||
self.pot.addMoney(player, Decimal(amount))
|
self.pot.addMoney(player, Decimal(amount))
|
||||||
|
|
||||||
|
@ -463,11 +468,11 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
Rb = Rt - C - Bc
|
Rb = Rt - C - Bc
|
||||||
self._addRaise(street, player, C, Rb, Rt)
|
self._addRaise(street, player, C, Rb, Rt)
|
||||||
|
|
||||||
def _addRaise(self, street, player, C, Rb, Rt):
|
def _addRaise(self, street, player, C, Rb, Rt, action = 'raises'):
|
||||||
log.debug(_("%s %s raise %s") %(street, player, Rt))
|
log.debug(_("%s %s raise %s") %(street, player, Rt))
|
||||||
self.bets[street][player].append(C + Rb)
|
self.bets[street][player].append(C + Rb)
|
||||||
self.stacks[player] -= (C + Rb)
|
self.stacks[player] -= (C + Rb)
|
||||||
act = (player, 'raises', Rb, Rt, C, self.stacks[player]==0)
|
act = (player, action, Rb, Rt, C, self.stacks[player]==0)
|
||||||
self.actions[street].append(act)
|
self.actions[street].append(act)
|
||||||
self.lastBet[street] = Rt # TODO check this is correct
|
self.lastBet[street] = Rt # TODO check this is correct
|
||||||
self.pot.addMoney(player, C+Rb)
|
self.pot.addMoney(player, C+Rb)
|
||||||
|
@ -481,7 +486,7 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
self.bets[street][player].append(Decimal(amount))
|
self.bets[street][player].append(Decimal(amount))
|
||||||
self.stacks[player] -= Decimal(amount)
|
self.stacks[player] -= Decimal(amount)
|
||||||
#print "DEBUG %s bets %s, stack %s" % (player, amount, self.stacks[player])
|
#print "DEBUG %s bets %s, stack %s" % (player, amount, self.stacks[player])
|
||||||
act = (player, 'bets', amount, self.stacks[player]==0)
|
act = (player, 'bets', Decimal(amount), self.stacks[player]==0)
|
||||||
self.actions[street].append(act)
|
self.actions[street].append(act)
|
||||||
self.lastBet[street] = Decimal(amount)
|
self.lastBet[street] = Decimal(amount)
|
||||||
self.pot.addMoney(player, Decimal(amount))
|
self.pot.addMoney(player, Decimal(amount))
|
||||||
|
@ -1020,7 +1025,7 @@ class DrawHand(Hand):
|
||||||
self.bets['DEAL'][player].append(Decimal(amount))
|
self.bets['DEAL'][player].append(Decimal(amount))
|
||||||
self.stacks[player] -= Decimal(amount)
|
self.stacks[player] -= Decimal(amount)
|
||||||
#print "DEBUG %s posts, stack %s" % (player, self.stacks[player])
|
#print "DEBUG %s posts, stack %s" % (player, self.stacks[player])
|
||||||
act = (player, 'posts', blindtype, amount, self.stacks[player]==0)
|
act = (player, blindtype, Decimal(amount), self.stacks[player]==0)
|
||||||
self.actions['BLINDSANTES'].append(act)
|
self.actions['BLINDSANTES'].append(act)
|
||||||
self.pot.addMoney(player, Decimal(amount))
|
self.pot.addMoney(player, Decimal(amount))
|
||||||
if blindtype == 'big blind':
|
if blindtype == 'big blind':
|
||||||
|
@ -1050,10 +1055,10 @@ class DrawHand(Hand):
|
||||||
def addDiscard(self, street, player, num, cards):
|
def addDiscard(self, street, player, num, cards):
|
||||||
self.checkPlayerExists(player)
|
self.checkPlayerExists(player)
|
||||||
if cards:
|
if cards:
|
||||||
act = (player, 'discards', num, cards)
|
act = (player, 'discards', Decimal(num), cards)
|
||||||
self.discardDrawHoleCards(cards, player, street)
|
self.discardDrawHoleCards(cards, player, street)
|
||||||
else:
|
else:
|
||||||
act = (player, 'discards', num)
|
act = (player, 'discards', Decimal(num))
|
||||||
self.actions[street].append(act)
|
self.actions[street].append(act)
|
||||||
|
|
||||||
def holecardsAsSet(self, street, player):
|
def holecardsAsSet(self, street, player):
|
||||||
|
@ -1246,7 +1251,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
Rt = Decimal(amountTo)
|
Rt = Decimal(amountTo)
|
||||||
C = Bp - Bc
|
C = Bp - Bc
|
||||||
Rb = Rt - C
|
Rb = Rt - C
|
||||||
self._addRaise(street, player, C, Rb, Rt)
|
self._addRaise(street, player, C, Rb, Rt, 'completes')
|
||||||
#~ self.bets[street][player].append(C + Rb)
|
#~ self.bets[street][player].append(C + Rb)
|
||||||
#~ self.stacks[player] -= (C + Rb)
|
#~ self.stacks[player] -= (C + Rb)
|
||||||
#~ act = (player, 'raises', Rb, Rt, C, self.stacks[player]==0)
|
#~ act = (player, 'raises', Rb, Rt, C, self.stacks[player]==0)
|
||||||
|
@ -1259,7 +1264,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
log.debug(_("Bringin: %s, %s") % (player , bringin))
|
log.debug(_("Bringin: %s, %s") % (player , bringin))
|
||||||
self.bets['THIRD'][player].append(Decimal(bringin))
|
self.bets['THIRD'][player].append(Decimal(bringin))
|
||||||
self.stacks[player] -= Decimal(bringin)
|
self.stacks[player] -= Decimal(bringin)
|
||||||
act = (player, 'bringin', bringin, self.stacks[player]==0)
|
act = (player, 'bringin', Decimal(bringin), self.stacks[player]==0)
|
||||||
self.actions['THIRD'].append(act)
|
self.actions['THIRD'].append(act)
|
||||||
self.lastBet['THIRD'] = Decimal(bringin)
|
self.lastBet['THIRD'] = Decimal(bringin)
|
||||||
self.pot.addMoney(player, Decimal(bringin))
|
self.pot.addMoney(player, Decimal(bringin))
|
||||||
|
|
|
@ -153,7 +153,28 @@ class Sql:
|
||||||
tourneyId BIGINT NOT NULL,
|
tourneyId BIGINT NOT NULL,
|
||||||
rawTourney TEXT NOT NULL,
|
rawTourney TEXT NOT NULL,
|
||||||
complain BOOLEAN NOT NULL DEFAULT FALSE)"""
|
complain BOOLEAN NOT NULL DEFAULT FALSE)"""
|
||||||
|
|
||||||
|
################################
|
||||||
|
# Create Actions
|
||||||
|
################################
|
||||||
|
|
||||||
|
if db_server == 'mysql':
|
||||||
|
self.query['createActionsTable'] = """CREATE TABLE Actions (
|
||||||
|
id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY (id),
|
||||||
|
name varchar(32) NOT NULL,
|
||||||
|
code char(2) NOT NULL)
|
||||||
|
ENGINE=INNODB"""
|
||||||
|
elif db_server == 'postgresql':
|
||||||
|
self.query['createActionsTable'] = """CREATE TABLE Actions (
|
||||||
|
id SERIAL, PRIMARY KEY (id),
|
||||||
|
name varchar(32),
|
||||||
|
code char(2))"""
|
||||||
|
elif db_server == 'sqlite':
|
||||||
|
self.query['createActionsTable'] = """CREATE TABLE Actions (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
code TEXT NOT NULL)"""
|
||||||
|
|
||||||
################################
|
################################
|
||||||
# Create Sites
|
# Create Sites
|
||||||
################################
|
################################
|
||||||
|
@ -989,11 +1010,14 @@ class Sql:
|
||||||
handsPlayerId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
|
handsPlayerId BIGINT UNSIGNED NOT NULL, FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
|
||||||
street SMALLINT NOT NULL,
|
street SMALLINT NOT NULL,
|
||||||
actionNo SMALLINT NOT NULL,
|
actionNo SMALLINT NOT NULL,
|
||||||
action CHAR(5) NOT NULL,
|
streetActionNo SMALLINT NOT NULL,
|
||||||
allIn BOOLEAN NOT NULL,
|
actionId SMALLINT NOT NULL, FOREIGN KEY (actionId) REFERENCES Actions(id),
|
||||||
amount INT NOT NULL,
|
amount INT NOT NULL,
|
||||||
comment TEXT,
|
raiseTo INT NOT NULL,
|
||||||
commentTs DATETIME)
|
amountCalled INT NOT NULL,
|
||||||
|
numDiscarded SMALLINT NOT NULL,
|
||||||
|
cardsDiscarded varchar(14),
|
||||||
|
allIn BOOLEAN NOT NULL)
|
||||||
ENGINE=INNODB"""
|
ENGINE=INNODB"""
|
||||||
elif db_server == 'postgresql':
|
elif db_server == 'postgresql':
|
||||||
self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
|
self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
|
||||||
|
@ -1001,24 +1025,31 @@ class Sql:
|
||||||
handsPlayerId BIGINT, FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
|
handsPlayerId BIGINT, FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
|
||||||
street SMALLINT,
|
street SMALLINT,
|
||||||
actionNo SMALLINT,
|
actionNo SMALLINT,
|
||||||
action CHAR(5),
|
streetActionNo SMALLINT,
|
||||||
allIn BOOLEAN,
|
actionId SMALLINT, FOREIGN KEY (actionId) REFERENCES Actions(id),
|
||||||
amount INT,
|
amount INT,
|
||||||
comment TEXT,
|
raiseTo INT,
|
||||||
commentTs timestamp without time zone)"""
|
amountCalled INT,
|
||||||
|
numDiscarded SMALLINT,
|
||||||
|
cardsDiscarded varchar(14),
|
||||||
|
allIn BOOLEAN)"""
|
||||||
elif db_server == 'sqlite':
|
elif db_server == 'sqlite':
|
||||||
self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
|
self.query['createHandsActionsTable'] = """CREATE TABLE HandsActions (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
handsPlayerId BIGINT,
|
handsPlayerId BIGINT,
|
||||||
street SMALLINT,
|
street SMALLINT,
|
||||||
actionNo SMALLINT,
|
actionNo SMALLINT,
|
||||||
action CHAR(5),
|
streetActionNo SMALLINT,
|
||||||
allIn INT,
|
actionId SMALLINT,
|
||||||
amount INT,
|
amount INT,
|
||||||
comment TEXT,
|
raiseTo INT,
|
||||||
commentTs timestamp without time zone,
|
amountCalled INT,
|
||||||
FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id)
|
numDiscarded SMALLINT,
|
||||||
)"""
|
cardsDiscarded TEXT,
|
||||||
|
allIn BOOLEAN,
|
||||||
|
FOREIGN KEY (handsPlayerId) REFERENCES HandsPlayers(id),
|
||||||
|
FOREIGN KEY (actionId) REFERENCES Actions(id) ON DELETE CASCADE
|
||||||
|
)"""
|
||||||
|
|
||||||
|
|
||||||
################################
|
################################
|
||||||
|
@ -4251,11 +4282,17 @@ class Sql:
|
||||||
handsPlayerId,
|
handsPlayerId,
|
||||||
street,
|
street,
|
||||||
actionNo,
|
actionNo,
|
||||||
action,
|
streetActionNo,
|
||||||
allIn,
|
actionId,
|
||||||
amount
|
amount,
|
||||||
|
raiseTo,
|
||||||
|
amountCalled,
|
||||||
|
numDiscarded,
|
||||||
|
cardsDiscarded,
|
||||||
|
allIn
|
||||||
)
|
)
|
||||||
VALUES (
|
VALUES (
|
||||||
|
%s, %s, %s, %s, %s,
|
||||||
%s, %s, %s, %s, %s,
|
%s, %s, %s, %s, %s,
|
||||||
%s
|
%s
|
||||||
)"""
|
)"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user