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

This commit is contained in:
sqlcoder 2009-12-16 18:18:03 +00:00
commit c081726a42
9 changed files with 201 additions and 134 deletions

View File

@ -1618,103 +1618,43 @@ class Database:
pdata[p]['street2Bets'],
pdata[p]['street3Bets'],
pdata[p]['street4Bets'],
pdata[p]['position'],
pdata[p]['tourneyTypeId'],
pdata[p]['startCards'],
pdata[p]['street0_3BChance'],
pdata[p]['street0_3BDone'],
pdata[p]['otherRaisedStreet1'],
pdata[p]['otherRaisedStreet2'],
pdata[p]['otherRaisedStreet3'],
pdata[p]['otherRaisedStreet4'],
pdata[p]['foldToOtherRaisedStreet1'],
pdata[p]['foldToOtherRaisedStreet2'],
pdata[p]['foldToOtherRaisedStreet3'],
pdata[p]['foldToOtherRaisedStreet4'],
pdata[p]['stealAttemptChance'],
pdata[p]['stealAttempted'],
pdata[p]['foldBbToStealChance'],
pdata[p]['foldedBbToSteal'],
pdata[p]['foldSbToStealChance'],
pdata[p]['foldedSbToSteal'],
pdata[p]['foldToStreet1CBChance'],
pdata[p]['foldToStreet1CBDone'],
pdata[p]['foldToStreet2CBChance'],
pdata[p]['foldToStreet2CBDone'],
pdata[p]['foldToStreet3CBChance'],
pdata[p]['foldToStreet3CBDone'],
pdata[p]['foldToStreet4CBChance'],
pdata[p]['foldToStreet4CBDone'],
pdata[p]['street1CheckCallRaiseChance'],
pdata[p]['street1CheckCallRaiseDone'],
pdata[p]['street2CheckCallRaiseChance'],
pdata[p]['street2CheckCallRaiseDone'],
pdata[p]['street3CheckCallRaiseChance'],
pdata[p]['street3CheckCallRaiseDone'],
pdata[p]['street4CheckCallRaiseChance']
) )
q = """INSERT INTO HandsPlayers (
handId,
playerId,
startCash,
seatNo,
card1,
card2,
card3,
card4,
card5,
card6,
card7,
winnings,
rake,
totalProfit,
street0VPI,
street1Seen,
street2Seen,
street3Seen,
street4Seen,
sawShowdown,
wonAtSD,
street0Aggr,
street1Aggr,
street2Aggr,
street3Aggr,
street4Aggr,
street1CBChance,
street2CBChance,
street3CBChance,
street4CBChance,
street1CBDone,
street2CBDone,
street3CBDone,
street4CBDone,
wonWhenSeenStreet1,
street0Calls,
street1Calls,
street2Calls,
street3Calls,
street4Calls,
street0Bets,
street1Bets,
street2Bets,
street3Bets,
street4Bets
)
VALUES (
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s
)"""
# position,
# tourneyTypeId,
# startCards,
# street0_3BChance,
# street0_3BDone,
# otherRaisedStreet1,
# otherRaisedStreet2,
# otherRaisedStreet3,
# otherRaisedStreet4,
# foldToOtherRaisedStreet1,
# foldToOtherRaisedStreet2,
# foldToOtherRaisedStreet3,
# foldToOtherRaisedStreet4,
# stealAttemptChance,
# stealAttempted,
# foldBbToStealChance,
# foldedBbToSteal,
# foldSbToStealChance,
# foldedSbToSteal,
# foldToStreet1CBChance,
# foldToStreet1CBDone,
# foldToStreet2CBChance,
# foldToStreet2CBDone,
# foldToStreet3CBChance,
# foldToStreet3CBDone,
# foldToStreet4CBChance,
# foldToStreet4CBDone,
# street1CheckCallRaiseChance,
# street1CheckCallRaiseDone,
# street2CheckCallRaiseChance,
# street2CheckCallRaiseDone,
# street3CheckCallRaiseChance,
# street3CheckCallRaiseDone,
# street4CheckCallRaiseChance,
# street4CheckCallRaiseDone,
q = self.sql.query['store_hands_players']
q = q.replace('%s', self.sql.query['placeholder'])
#print "DEBUG: inserts: %s" %inserts
@ -1927,8 +1867,10 @@ class Database:
,(name, site_id))
#Get last id might be faster here.
#c.execute ("SELECT id FROM Players WHERE name=%s", (name,))
tmp = [self.get_last_insert_id(c)]
return tmp[0]
result = self.get_last_insert_id(c)
else:
result = tmp[1]
return result
def insertGameTypes(self, row):
c = self.get_cursor()

View File

@ -17,6 +17,7 @@
#fpdb modules
import Card
from decimal import Decimal
DEBUG = False
@ -43,9 +44,9 @@ class DerivedStats():
self.handsplayers[player[1]]['totalProfit'] = 0
self.handsplayers[player[1]]['street4Seen'] = False
self.handsplayers[player[1]]['street4Aggr'] = False
self.handsplayers[player[1]]['wonWhenSeenStreet1'] = False
self.handsplayers[player[1]]['wonWhenSeenStreet1'] = 0.0
self.handsplayers[player[1]]['sawShowdown'] = False
self.handsplayers[player[1]]['wonAtSD'] = False
self.handsplayers[player[1]]['wonAtSD'] = 0.0
for i in range(5):
self.handsplayers[player[1]]['street%dCalls' % i] = 0
self.handsplayers[player[1]]['street%dBets' % i] = 0
@ -53,6 +54,27 @@ class DerivedStats():
self.handsplayers[player[1]]['street%dCBChance' %i] = False
self.handsplayers[player[1]]['street%dCBDone' %i] = False
#FIXME - Everything below this point is incomplete.
self.handsplayers[player[1]]['position'] = 2
self.handsplayers[player[1]]['tourneyTypeId'] = 1
self.handsplayers[player[1]]['startCards'] = 0
self.handsplayers[player[1]]['street0_3BChance'] = False
self.handsplayers[player[1]]['street0_3BDone'] = False
self.handsplayers[player[1]]['stealAttemptChance'] = False
self.handsplayers[player[1]]['stealAttempted'] = False
self.handsplayers[player[1]]['foldBbToStealChance'] = False
self.handsplayers[player[1]]['foldBbToStealChance'] = False
self.handsplayers[player[1]]['foldSbToStealChance'] = False
self.handsplayers[player[1]]['foldedSbToSteal'] = False
self.handsplayers[player[1]]['foldedBbToSteal'] = False
for i in range(1,5):
self.handsplayers[player[1]]['otherRaisedStreet%d' %i] = False
self.handsplayers[player[1]]['foldToOtherRaisedStreet%d' %i] = False
self.handsplayers[player[1]]['foldToStreet%dCBChance' %i] = False
self.handsplayers[player[1]]['foldToStreet%dCBDone' %i] = False
self.handsplayers[player[1]]['street%dCheckCallRaiseChance' %i] = False
self.handsplayers[player[1]]['street%dCheckCallRaiseDone' %i] = False
self.assembleHands(self.hand)
self.assembleHandsPlayers(self.hand)
@ -114,7 +136,7 @@ class DerivedStats():
#hand.players = [[seat, name, chips],[seat, name, chips]]
for player in hand.players:
self.handsplayers[player[1]]['seatNo'] = player[0]
self.handsplayers[player[1]]['startCash'] = player[2]
self.handsplayers[player[1]]['startCash'] = int(100 * Decimal(player[2]))
for i, street in enumerate(hand.actionStreets[2:]):
self.seen(self.hand, i+1)
@ -134,9 +156,9 @@ class DerivedStats():
# Should be fine for split-pots, but won't be accurate for multi-way pots
self.handsplayers[player]['rake'] = int(100* hand.rake)/len(hand.collectees)
if self.handsplayers[player]['street1Seen'] == True:
self.handsplayers[player]['wonWhenSeenStreet1'] = True
self.handsplayers[player]['wonWhenSeenStreet1'] = 1.0
if self.handsplayers[player]['sawShowdown'] == True:
self.handsplayers[player]['wonAtSD'] = True
self.handsplayers[player]['wonAtSD'] = 1.0
for player in hand.pot.committed:
self.handsplayers[player]['totalProfit'] = int(self.handsplayers[player]['winnings'] - (100*hand.pot.committed[player]))
@ -149,6 +171,7 @@ class DerivedStats():
for i, card in enumerate(hcs[:7], 1):
self.handsplayers[player[1]]['card%s' % i] = Card.encodeCard(card)
# position,
#Stud 3rd street card test
# denny501: brings in for $0.02
@ -159,16 +182,6 @@ class DerivedStats():
# u.pressure: folds (Seat 1)
# 123smoothie: calls $0.02
# gashpor: calls $0.02
# tourneyTypeId,
# startCards,
# street0_3BChance,street0_3BDone,
# otherRaisedStreet1-4
# foldToOtherRaisedStreet1-4
# stealAttemptChance,stealAttempted,
# foldBbToStealChance,foldedBbToSteal,
# foldSbToStealChance,foldedSbToSteal,
# foldToStreet1-4CBChance, foldToStreet1-4CBDone,
# street1-4CheckCallRaiseChance, street1-4CheckCallRaiseDone,
# Additional stats
# 3betSB, 3betBB

View File

@ -479,7 +479,8 @@ class Filters(threading.Thread):
self.cursor.execute(self.sql.query['getLimits2'])
# selects limitType, bigBlind
result = self.db.cursor.fetchall()
fl, nl = False, False
found = {'nl':False, 'fl':False, 'ring':False, 'tour':False}
if len(result) >= 1:
hbox = gtk.HBox(True, 0)
vbox1.pack_start(hbox, False, False, 0)
@ -487,7 +488,6 @@ class Filters(threading.Thread):
hbox.pack_start(vbox2, False, False, 0)
vbox3 = gtk.VBox(False, 0)
hbox.pack_start(vbox3, False, False, 0)
found = {'nl':False, 'fl':False, 'ring':False, 'tour':False}
for i, line in enumerate(result):
if "UseType" in self.display:
if line[0] != self.display["UseType"]:

View File

@ -387,6 +387,18 @@ Left-Drag to Move"
<location seat="8" x="0" y="181"> </location>
<location seat="9" x="70" y="53"> </location>
</layout>
<layout fav_seat="6" height="547" max="10" width="794">
<location seat="1" x="698" y="69"> </location>
<location seat="2" x="716" y="243"> </location>
<location seat="3" x="699" y="301"> </location>
<location seat="4" x="456" y="391"> </location>
<location seat="5" x="338" y="369"> </location>
<location seat="6" x="98" y="363"> </location>
<location seat="7" x="15" y="242"> </location>
<location seat="8" x="11" y="55"> </location>
<location seat="9" x="341" y="30"> </location>
<location seat="10" x="562" y="8"> </location>
</layout>
</site>

View File

@ -55,6 +55,8 @@ class Hand(object):
self.handText = handText
self.handid = 0
self.dbid_hands = 0
self.dbid_pids = None
self.dbid_gt = 0
self.tablename = ""
self.hero = ""
self.maxseats = None
@ -189,22 +191,21 @@ dealt whether they were seen in a 'dealt to' line
self.holecards[street][player] = [open, closed]
def prepInsert(self, db):
pass
#####
# Players, Gametypes, TourneyTypes are all shared functions that are needed for additional tables
# These functions are intended for prep insert eventually
#####
# Players - base playerid and siteid tuple
self.dbid_pids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId)
#Gametypes
self.dbid_gt = db.getGameTypeId(self.siteId, self.gametype)
def insert(self, db):
""" Function to insert Hand into database
Should not commit, and do minimal selects. Callers may want to cache commits
db: a connected fpdb_db object"""
#####
# Players, Gametypes, TourneyTypes are all shared functions that are needed for additional tables
# These functions are intended for prep insert eventually
#####
# 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)
self.stats.getStats(self)
@ -213,14 +214,14 @@ db: a connected fpdb_db object"""
#####
hh = self.stats.getHands()
if not db.isDuplicate(gtid, hh['siteHandNo']):
if not db.isDuplicate(self.dbid_gt, hh['siteHandNo']):
# Hands - Summary information of hand indexed by handId - gameinfo
hh['gameTypeId'] = gtid
hh['gameTypeId'] = self.dbid_gt
# seats TINYINT NOT NULL,
hh['seats'] = len(sqlids)
hh['seats'] = len(self.dbid_pids)
self.dbid_hands = db.storeHand(hh)
db.storeHandsPlayers(self.dbid_hands, sqlids, self.stats.getHandsPlayers())
db.storeHandsPlayers(self.dbid_hands, self.dbid_pids, self.stats.getHandsPlayers())
# HandsActions - all actions for all players for all streets - self.actions
# HudCache data can be generated from HandsActions (HandsPlayers?)
# Tourneys ?

View File

@ -3325,8 +3325,105 @@ class Sql:
%s, %s, %s, %s, %s, %s, %s, %s, %s)"""
self.query['store_hands_players'] = """INSERT INTO HandsPlayers (
handId,
playerId,
startCash,
seatNo,
card1,
card2,
card3,
card4,
card5,
card6,
card7,
winnings,
rake,
totalProfit,
street0VPI,
street1Seen,
street2Seen,
street3Seen,
street4Seen,
sawShowdown,
wonAtSD,
street0Aggr,
street1Aggr,
street2Aggr,
street3Aggr,
street4Aggr,
street1CBChance,
street2CBChance,
street3CBChance,
street4CBChance,
street1CBDone,
street2CBDone,
street3CBDone,
street4CBDone,
wonWhenSeenStreet1,
street0Calls,
street1Calls,
street2Calls,
street3Calls,
street4Calls,
street0Bets,
street1Bets,
street2Bets,
street3Bets,
street4Bets,
position,
tourneyTypeId,
startCards,
street0_3BChance,
street0_3BDone,
otherRaisedStreet1,
otherRaisedStreet2,
otherRaisedStreet3,
otherRaisedStreet4,
foldToOtherRaisedStreet1,
foldToOtherRaisedStreet2,
foldToOtherRaisedStreet3,
foldToOtherRaisedStreet4,
stealAttemptChance,
stealAttempted,
foldBbToStealChance,
foldedBbToSteal,
foldSbToStealChance,
foldedSbToSteal,
foldToStreet1CBChance,
foldToStreet1CBDone,
foldToStreet2CBChance,
foldToStreet2CBDone,
foldToStreet3CBChance,
foldToStreet3CBDone,
foldToStreet4CBChance,
foldToStreet4CBDone,
street1CheckCallRaiseChance,
street1CheckCallRaiseDone,
street2CheckCallRaiseChance,
street2CheckCallRaiseDone,
street3CheckCallRaiseChance,
street3CheckCallRaiseDone,
street4CheckCallRaiseChance
)
VALUES (
%s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s,
%s, %s, %s, %s, %s
)"""
if db_server == 'mysql':
self.query['placeholder'] = u'%s'

View File

@ -237,7 +237,8 @@ class fpdb:
dia.set_comments("GTK AboutDialog comments here")
dia.set_license("GPL v3")
dia.set_website("http://fpdb.sourceforge.net/")
dia.set_authors("Steffen, Eratosthenes, s0rrow, EricBlade, _mt, sqlcoder, Bostik, and others")
dia.set_authors(['Steffen', 'Eratosthenes', 's0rrow',
'EricBlade', '_mt', 'sqlcoder', 'Bostik', 'and others'])
dia.set_program_name("Free Poker Database (FPDB)")
db_version = ""

View File

@ -158,7 +158,7 @@ class fpdb_db:
if not os.path.isdir(Configuration.DIR_DATABASES) and not database == ":memory:":
print "Creating directory: '%s'" % (Configuration.DIR_DATABASES)
os.mkdir(Configuration.DIR_DATABASES)
database = os.path.join(Configuration.DIR_DATABASE, database)
database = os.path.join(Configuration.DIR_DATABASES, database)
self.db = sqlite3.connect(database, detect_types=sqlite3.PARSE_DECLTYPES )
sqlite3.register_converter("bool", lambda x: bool(int(x)))
sqlite3.register_adapter(bool, lambda x: "1" if x else "0")

View File

@ -435,13 +435,14 @@ class Importer:
for hand in handlist:
#try, except duplicates here?
#hand.prepInsert()
hand.prepInsert(self.database)
hand.insert(self.database)
if self.callHud and hand.dbid_hands != 0:
#print "DEBUG: call to HUD: handsId: %s" % hand.dbid_hands
#pipe the Hands.id out to the HUD
# print "fpdb_import: sending hand to hud", handsId, "pipe =", self.caller.pipe_to_hud
print "fpdb_import: sending hand to hud", hand.dbid_hands, "pipe =", self.caller.pipe_to_hud
self.caller.pipe_to_hud.stdin.write("%s" % (hand.dbid_hands) + os.linesep)
self.database.commit()
errors = getattr(hhc, 'numErrors')
stored = getattr(hhc, 'numHands')