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

This commit is contained in:
grindi 2009-08-09 16:31:33 +04:00
commit ebbb2afcd3
2 changed files with 92 additions and 66 deletions

View File

@ -28,6 +28,7 @@ import sys
import traceback import traceback
from datetime import datetime, date, time, timedelta from datetime import datetime, date, time, timedelta
from time import time, strftime, sleep from time import time, strftime, sleep
from decimal import Decimal
import string import string
import re import re
import logging import logging
@ -1043,7 +1044,7 @@ class Database:
q = "SELECT name, id FROM Players WHERE siteid=%s and name=%s" q = "SELECT name, id FROM Players WHERE siteid=%s and name=%s"
q = q.replace('%s', self.sql.query['placeholder']) q = q.replace('%s', self.sql.query['placeholder'])
print "DEBUG: name: %s site: %s" %(name, site_id) #print "DEBUG: name: %s site: %s" %(name, site_id)
c.execute (q, (site_id, name)) c.execute (q, (site_id, name))
@ -1121,10 +1122,10 @@ class Database:
def storeHand(self, p): def storeHand(self, p):
#stores into table hands: #stores into table hands:
self.cursor.execute ("""INSERT INTO Hands ( q = """INSERT INTO Hands (
tablename, tablename,
sitehandno,
gametypeid, gametypeid,
sitehandno,
handstart, handstart,
importtime, importtime,
seats, seats,
@ -1133,58 +1134,63 @@ class Database:
boardcard2, boardcard2,
boardcard3, boardcard3,
boardcard4, boardcard4,
boardcard5, boardcard5
-- texture,
playersVpi,
playersAtStreet1,
playersAtStreet2,
playersAtStreet3,
playersAtStreet4,
playersAtShowdown,
street0Raises,
street1Raises,
street2Raises,
street3Raises,
street4Raises,
-- street1Pot,
-- street2Pot,
-- street3Pot,
-- street4Pot,
-- showdownPot
) )
VALUES 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)"""
( #--- texture,
p['tablename'], #-- playersVpi,
p['sitehandno'], #-- playersAtStreet1,
p['gametypeid'], #-- playersAtStreet2,
#-- playersAtStreet3,
#-- playersAtStreet4,
#-- playersAtShowdown,
#-- street0Raises,
#-- street1Raises,
#-- street2Raises,
#-- street3Raises,
#-- street4Raises,
#-- street1Pot,
#-- street2Pot,
#-- street3Pot,
#-- street4Pot,
#-- showdownPot
#-- seats,
q = q.replace('%s', self.sql.query['placeholder'])
print "DEBUG: p: %s" %p
print "DEBUG: gtid: %s" % p['gameTypeId']
self.cursor.execute(q, (
p['tableName'],
p['gameTypeId'],
p['siteHandNo'],
p['handStart'], p['handStart'],
datetime.datetime.today(), datetime.today(), #importtime
len(p['names']), # len(p['names']), #seats
p['maxSeats'], p['maxSeats'],
p['seats'],
p['boardcard1'], p['boardcard1'],
p['boardcard2'], p['boardcard2'],
p['boardcard3'], p['boardcard3'],
p['boardcard4'], p['boardcard4'],
p['boardcard5'], p['boardcard5'])
hudCache['playersVpi'], # hudCache['playersVpi'],
hudCache['playersAtStreet1'], # hudCache['playersAtStreet1'],
hudCache['playersAtStreet2'], # hudCache['playersAtStreet2'],
hudCache['playersAtStreet3'], # hudCache['playersAtStreet3'],
hudCache['playersAtStreet4'], # hudCache['playersAtStreet4'],
hudCache['playersAtShowdown'], # hudCache['playersAtShowdown'],
hudCache['street0Raises'], # hudCache['street0Raises'],
hudCache['street1Raises'], # hudCache['street1Raises'],
hudCache['street2Raises'], # hudCache['street2Raises'],
hudCache['street3Raises'], # hudCache['street3Raises'],
hudCache['street4Raises'], # hudCache['street4Raises'],
hudCache['street1Pot'], # hudCache['street1Pot'],
hudCache['street2Pot'], # hudCache['street2Pot'],
hudCache['street3Pot'], # hudCache['street3Pot'],
hudCache['street4Pot'], # hudCache['street4Pot'],
hudCache['showdownPot'] # hudCache['showdownPot']
)
) )
#return getLastInsertId(backend, conn, cursor) #return getLastInsertId(backend, conn, cursor)
# def storeHand # def storeHand

View File

@ -185,31 +185,51 @@ db: a connected fpdb_db object"""
# TODO: # TODO:
# Players - base playerid and siteid tuple # Players - base playerid and siteid tuple
sqlids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId) sqlids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId)
#Gametypes
print "DEBUG: self.gametype %s" % self.gametype
#Nice way to discover if the game is already listed in the db?
#Also this is using an old method from fpdb_simple - should probably conform to the rest of the inserts
hilo = "h"
if self.gametype['category'] in ['studhilo', 'omahahilo']:
hilo = "s"
elif self.gametype['category'] in ['razz','27_3draw','badugi']:
hilo = "l"
gtid = db.insertGameTypes( (self.siteId, self.gametype['type'], self.gametype['base'],
self.gametype['category'], self.gametype['limitType'], hilo,
int(Decimal(self.gametype['sb'])*100), int(Decimal(self.gametype['bb'])*100), 0, 0) )
# HudCache data to come from DerivedStats class # HudCache data to come from DerivedStats class
# HandsActions - all actions for all players for all streets - self.actions # HandsActions - all actions for all players for all streets - self.actions
# BoardCards - Skip - no longer necessary
# Hands - Summary information of hand indexed by handId - gameinfo # Hands - Summary information of hand indexed by handId - gameinfo
#hh['siteHandNo'] = self.handid #This should be moved to prepInsert
# gametypeId SMALLINT UNSIGNED NOT NULL, FOREIGN KEY (gametypeId) REFERENCES Gametypes(id), hh = {}
# hh['siteHandNo'] = self.handid
#hh['handStart'] = self.starttime hh['handStart'] = self.starttime
hh['gameTypeId'] = gtid[0]
# seats TINYINT NOT NULL, # seats TINYINT NOT NULL,
# hh['tableName'] = self.tablename
#hh['tableName'] = self.tablenam hh['maxSeats'] = self.maxseats
#hh['maxSeats'] = self.maxseats hh['seats'] = len(sqlids)
# boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */ # boardcard1 smallint, /* 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As */
# boardcard2 smallint, # boardcard2 smallint,
# boardcard3 smallint, # boardcard3 smallint,
# boardcard4 smallint, # boardcard4 smallint,
# boardcard5 smallint, # boardcard5 smallint,
# Flop turn and river may all be empty - add (likely) too many elements and trim with range # Flop turn and river may all be empty - add (likely) too many elements and trim with range
# boardcards = board['FLOP'] + board['TURN'] + board['RIVER'] + [u'0x', u'0x', u'0x', u'0x', u'0x'] boardcards = self.board['FLOP'] + self.board['TURN'] + self.board['RIVER'] + [u'0x', u'0x', u'0x', u'0x', u'0x']
# cards = [Card.cardFromValueSuit(v,s) for v,s in boardcards[0:4]] cards = [Card.encodeCard(c) for c in boardcards[0:5]]
# hh['boardcard1'] = cards[0] hh['boardcard1'] = cards[0]
# hh['boardcard2'] = cards[1] hh['boardcard2'] = cards[1]
# hh['boardcard3'] = cards[2] hh['boardcard3'] = cards[2]
# hh['boardcard4'] = cards[3] hh['boardcard4'] = cards[3]
# hh['boardcard5'] = cards[4] hh['boardcard5'] = cards[4]
print hh
# texture smallint, # texture smallint,
# playersVpi SMALLINT NOT NULL, /* num of players vpi */ # playersVpi SMALLINT NOT NULL, /* num of players vpi */
# Needs to be recorded # Needs to be recorded
@ -244,7 +264,7 @@ db: a connected fpdb_db object"""
# showdownPot INT, /* pot size at sd/street7 */ # showdownPot INT, /* pot size at sd/street7 */
# comment TEXT, # comment TEXT,
# commentTs DATETIME # commentTs DATETIME
# handid = db.storeHand(hh) handid = db.storeHand(hh)
# HandsPlayers - ? ... Do we fix winnings? # HandsPlayers - ? ... Do we fix winnings?
# Tourneys ? # Tourneys ?
# TourneysPlayers # TourneysPlayers