p52 - much progress on tourneys and some minor stuff and a change of tables

migrated install-in-windows to website
renamed table tourneysgametypes to tourneytypes
This commit is contained in:
steffen123
2008-08-18 05:58:41 +01:00
parent 6eb42cd05e
commit 8fb57d3729
9 changed files with 71 additions and 157 deletions
+1 -1
View File
@@ -370,7 +370,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_title("Free Poker DB - version: alpha1+, p51")
self.window.set_title("Free Poker DB - version: alpha1+, p52")
self.window.set_border_width(1)
self.window.set_size_request(1020,400)
self.window.set_resizable(True)
+9 -7
View File
@@ -47,7 +47,7 @@ class fpdb_db:
try:
self.cursor.execute("SELECT * FROM Settings")
settings=self.cursor.fetchone()
if settings[0]!=50:
if settings[0]!=52:
print "outdated or too new database version - please recreate tables"
except:# _mysql_exceptions.ProgrammingError:
print "failed to read settings table - please recreate tables"
@@ -126,7 +126,9 @@ class fpdb_db:
self.cursor.execute("DROP TABLE IF EXISTS Tourneys;")
self.cursor.execute("DROP TABLE IF EXISTS Players;")
self.cursor.execute("DROP TABLE IF EXISTS Gametypes;")
self.cursor.execute("DROP TABLE IF EXISTS TourneysGametypes;")
if oldDbVersion>45 and oldDbVersion<=51:
self.cursor.execute("DROP TABLE IF EXISTS TourneysGametypes;")
self.cursor.execute("DROP TABLE IF EXISTS TourneyTypes;")
self.cursor.execute("DROP TABLE IF EXISTS Sites;")
self.db.commit()
@@ -213,7 +215,7 @@ class fpdb_db:
card5Value smallint,
card5Suit char(1))""")
self.create_table("""TourneysGametypes (
self.create_table("""TourneyTypes (
id SMALLINT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
siteId SMALLINT UNSIGNED, FOREIGN KEY (siteId) REFERENCES Sites(id),
buyin INT,
@@ -223,7 +225,7 @@ class fpdb_db:
self.create_table("""Tourneys (
id INT UNSIGNED UNIQUE AUTO_INCREMENT, PRIMARY KEY (id),
tourneysGametypeId SMALLINT UNSIGNED, FOREIGN KEY (tourneysGametypeId) REFERENCES TourneysGametypes(id),
tourneyTypeId SMALLINT UNSIGNED, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
siteTourneyNo BIGINT,
entries INT,
prizepool INT,
@@ -288,7 +290,7 @@ class fpdb_db:
playerId INT UNSIGNED, FOREIGN KEY (playerId) REFERENCES Players(id),
activeSeats SMALLINT,
position CHAR(1),
tourneysGametypeId SMALLINT UNSIGNED, FOREIGN KEY (tourneysGametypeId) REFERENCES TourneysGametypes(id),
tourneyTypeId SMALLINT UNSIGNED, FOREIGN KEY (tourneyTypeId) REFERENCES TourneyTypes(id),
HDs INT,
street0VPI INT,
@@ -351,10 +353,10 @@ class fpdb_db:
street4CheckCallRaiseChance INT,
street4CheckCallRaiseDone INT)""")
self.cursor.execute("INSERT INTO Settings VALUES (50);")
self.cursor.execute("INSERT INTO Settings VALUES (52);")
self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, \"Full Tilt Poker\", 'USD');")
self.cursor.execute("INSERT INTO Sites VALUES (DEFAULT, \"PokerStars\", 'USD');")
self.cursor.execute("INSERT INTO TourneysGametypes (id) VALUES (DEFAULT);")
self.cursor.execute("INSERT INTO TourneyTypes (id) VALUES (DEFAULT);")
self.db.commit()
print "finished recreating tables"
#end def recreate_tables
+7 -6
View File
@@ -44,7 +44,11 @@ def mainParser(db, cursor, site, category, hand):
fee=fpdb_simple.parseFee(hand[0])
entries=-1 #todo: parse this
prizepool=-1 #todo: parse this
knockout=0
tourneyStartTime=handStartTime #todo: read tourney start time
rebuyOrAddon=fpdb_simple.isRebuyOrAddon(hand[0])
tourneyTypeId=fpdb_simple.recogniseTourneyTypeId(cursor, siteID, buyin, fee, knockout, rebuyOrAddon)
fpdb_simple.isAlreadyInDB(cursor, gametypeID, siteHandNo)
#part 2: classify lines by type (e.g. cards, action, win, sectionchange) and street
@@ -110,16 +114,13 @@ def mainParser(db, cursor, site, category, hand):
hudImportData=fpdb_simple.generateHudData(playerIDs, category, actionTypes, actionTypeByNo, winnings, totalWinnings, positions)
if isTourney:
raise fpdb_simple.FpdbError ("tourneys are currently broken")
payin_amounts=fpdb_simple.calcPayin(len(names), buyin, fee)
ranks=[]
for i in range (len(names)):
ranks.append(0)
knockout=0
entries=-1
prizepool=-1
payin_amounts=fpdb_simple.calcPayin(len(names), buyin, fee)
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
result = fpdb_save_to_db.tourney_holdem_omaha(cursor, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks,
result = fpdb_save_to_db.tourney_holdem_omaha(cursor, category, siteTourneyNo, buyin, fee, knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteID,
siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
elif (category=="razz" or category=="studhi" or category=="studhilo"):
raise fpdb_simple.FpdbError ("stud/razz are currently broken")
+5 -21
View File
@@ -39,15 +39,7 @@ def ring_stud(cursor, category, site_hand_no, gametype_id, hand_start_time,
def ring_holdem_omaha(cursor, category, site_hand_no, gametype_id, hand_start_time, names, player_ids, start_cashes, positions, card_values, card_suits, board_values, board_suits, winnings, rakes, action_types, action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos):
"""stores a holdem/omaha hand into the database"""
#fill up the two player card arrays
if (category=="holdem"):
fpdb_simple.fillCardArrays(len(names), 2, card_values, card_suits)
elif (category=="omahahi" or category=="omahahilo"):
fpdb_simple.fillCardArrays(len(names), 4, card_values, card_suits)
else:
raise fpdb_simple.FpdbError ("invalid category: category")
fpdb_simple.fillCardArrays(len(names), category, card_values, card_suits)
fpdb_simple.fill_board_cards(board_values, board_suits)
hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats)
@@ -62,21 +54,13 @@ def ring_holdem_omaha(cursor, category, site_hand_no, gametype_id, hand_start_ti
return site_hand_no
#end def ring_holdem_omaha
def tourney_holdem_omaha(cursor, category, site_tourney_no, buyin, fee, knockout, entries, prizepool, tourney_start, payin_amounts, ranks, #end of tourney specific params
site_hand_no, gametype_id, hand_start_time, names, player_ids, start_cashes, positions, card_values, card_suits, board_values, board_suits, winnings, rakes, action_types, action_amounts, actionNos, hudImportData):
def tourney_holdem_omaha(cursor, category, site_tourney_no, buyin, fee, knockout, entries, prizepool, tourney_start, payin_amounts, ranks, tourneyTypeId, siteId, #end of tourney specific params
site_hand_no, gametype_id, hand_start_time, names, player_ids, start_cashes, positions, card_values, card_suits, board_values, board_suits, winnings, rakes, action_types, action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos):
"""stores a tourney holdem/omaha hand into the database"""
#fill up the two player card arrays
if (category=="holdem"):
fpdb_simple.fillCardArrays(len(names), 2, card_values, card_suits)
elif (category=="omahahi" or category=="omahahilo"):
fpdb_simple.fillCardArrays(len(names), 4, card_values, card_suits)
else:
raise fpdb_simple.FpdbError ("invalid category: category")
fpdb_simple.fillCardArrays(len(names), category, card_values, card_suits)
fpdb_simple.fill_board_cards(board_values, board_suits)
tourney_id=fpdb_simple.store_tourneys(cursor, site_id, site_tourney_no, buyin, fee, knockout, entries, prizepool, tourney_start)
tourney_id=fpdb_simple.store_tourneys(cursor, siteId, site_tourney_no, buyin, fee, knockout, entries, prizepool, tourney_start)
tourneys_players_ids=fpdb_simple.store_tourneys_players(cursor, tourney_id, player_ids, payin_amounts, ranks, winnings)
hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names)
+32 -7
View File
@@ -250,12 +250,17 @@ def fill_board_cards(board_values, board_suits):
board_suits.append("x")
#end def fill_board_cards
def fillCardArrays(player_count, card_count, card_values, card_suits):
#fills up the two card arrays
#print "fillCardArrays, player_count:", player_count," card_count:",card_count
#print "card_values:",card_values
def fillCardArrays(player_count, category, card_values, card_suits):
"""fills up the two card arrays"""
if (category=="holdem"):
cardCount=2
elif (category=="omahahi" or category=="omahahilo"):
cardCount=4
else:
raise fpdb_simple.FpdbError ("invalid category: category")
for i in range (player_count):
while (len(card_values[i])<card_count):
while (len(card_values[i])<cardCount):
card_values[i].append(0)
card_suits[i].append("x")
#end def fillCardArrays
@@ -465,6 +470,11 @@ def isAlreadyInDB(cursor, gametypeID, siteHandNo):
raise DuplicateError ("dupl")
#end isAlreadyInDB
def isRebuyOrAddon(topline):
"""isRebuyOrAddon not implemented yet"""
return False
#end def isRebuyOrAddon
#returns whether the passed topline indicates a tournament or not
def isTourney(topline):
if (topline.find("Tournament")!=-1):
@@ -1011,6 +1021,20 @@ def recogniseGametypeID(cursor, topline, site_id, category, isTourney):#todo: th
return result[0]
#end def recogniseGametypeID
def recogniseTourneyTypeId(cursor, siteId, buyin, fee, knockout, rebuyOrAddon):
cursor.execute ("SELECT id FROM TourneyTypes WHERE siteId=%s AND buyin=%s AND fee=%s AND knockout=%s AND rebuyOrAddon=%s", (siteId, buyin, fee, knockout, rebuyOrAddon))
result=cursor.fetchone()
#print "tried SELECTing gametypes.id, result:",result
try:
len(result)
except TypeError:#this means we need to create a new entry
cursor.execute("""INSERT INTO TourneyTypes (siteId, buyin, fee, knockout, rebuyOrAddon) VALUES (%s, %s, %s, %s, %s)""", (siteId, buyin, fee, knockout, rebuyOrAddon))
cursor.execute("SELECT id FROM TourneyTypes WHERE siteId=%s AND buyin=%s AND fee=%s AND knockout=%s AND rebuyOrAddon=%s", (siteId, buyin, fee, knockout, rebuyOrAddon))
result=cursor.fetchone()
return result[0]
#end def recogniseTourneyTypeId
#returns the SQL ids of the names given in an array
def recognisePlayerIDs(cursor, names, site_id):
result = []
@@ -1807,7 +1831,7 @@ def storeHudCache(cursor, category, gametypeId, playerIds, hudImportData):
if doInsert:
#print "playerid before insert:",row[2]
cursor.execute("""INSERT INTO HudCache
(gametypeId, playerId, activeSeats, position, tourneysGametypeId,
(gametypeId, playerId, activeSeats, position, tourneyTypeId,
HDs, street0VPI, street0Aggr, street0_3B4BChance, street0_3B4BDone,
street1Seen, street2Seen, street3Seen, street4Seen, sawShowdown,
street1Aggr, street2Aggr, street3Aggr, street4Aggr, otherRaisedStreet1,
@@ -1845,7 +1869,7 @@ def storeHudCache(cursor, category, gametypeId, playerIds, hudImportData):
foldToStreet2CBChance=%s, foldToStreet2CBDone=%s, foldToStreet3CBChance=%s, foldToStreet3CBDone=%s, foldToStreet4CBChance=%s,
foldToStreet4CBDone=%s, totalProfit=%s, street1CheckCallRaiseChance=%s, street1CheckCallRaiseDone=%s, street2CheckCallRaiseChance=%s,
street2CheckCallRaiseDone=%s, street3CheckCallRaiseChance=%s, street3CheckCallRaiseDone=%s, street4CheckCallRaiseChance=%s, street4CheckCallRaiseDone=%s
WHERE gametypeId=%s AND playerId=%s AND activeSeats=%s AND position=%s AND tourneysGametypeId=%s""", (row[6], row[7], row[8], row[9], row[10],
WHERE gametypeId=%s AND playerId=%s AND activeSeats=%s AND position=%s AND tourneyTypeId=%s""", (row[6], row[7], row[8], row[9], row[10],
row[11], row[12], row[13], row[14], row[15],
row[16], row[17], row[18], row[19], row[20],
row[21], row[22], row[23], row[24], row[25],
@@ -1900,3 +1924,4 @@ def store_tourneys_players(cursor, tourney_id, player_ids, payin_amounts, ranks,
#print "created new tourneys_players.id:",tmp
result.append(tmp[0])
return result
#end def store_tourneys_players