p53 - more progress on tourneys

This commit is contained in:
steffen123 2008-08-18 06:27:37 +01:00
parent 8fb57d3729
commit de845d4e90
4 changed files with 23 additions and 26 deletions

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+, p52")
self.window.set_title("Free Poker DB - version: alpha1+, p53")
self.window.set_border_width(1)
self.window.set_size_request(1020,400)
self.window.set_resizable(True)

View File

@ -47,7 +47,7 @@ class fpdb_db:
try:
self.cursor.execute("SELECT * FROM Settings")
settings=self.cursor.fetchone()
if settings[0]!=52:
if settings[0]!=53:
print "outdated or too new database version - please recreate tables"
except:# _mysql_exceptions.ProgrammingError:
print "failed to read settings table - please recreate tables"
@ -353,7 +353,7 @@ class fpdb_db:
street4CheckCallRaiseChance INT,
street4CheckCallRaiseDone INT)""")
self.cursor.execute("INSERT INTO Settings VALUES (52);")
self.cursor.execute("INSERT INTO Settings VALUES (53);")
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 TourneyTypes (id) VALUES (DEFAULT);")

View File

@ -54,25 +54,24 @@ 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, tourneyTypeId, siteId, #end of tourney specific params
def tourney_holdem_omaha(cursor, category, siteTourneyNo, 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"""
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, siteId, site_tourney_no, buyin, fee, knockout, entries, prizepool, tourney_start)
tourney_id=fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, 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)
hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats)
hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha_tourney(cursor, hands_id, player_ids,
start_cashes, positions, card_values, card_suits, winnings, rakes, tourneys_players_ids)
hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha_tourney(cursor, category, hands_id, player_ids, start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos, tourneys_players_ids)
fpdb_simple.storeHudData(cursor, category, player_ids, hudImportData)
fpdb_simple.storeHudCache(cursor, category, gametype_id, player_ids, hudImportData)
fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits)
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts)
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts, actionNos)
return site_hand_no
#end def tourney_holdem_omaha

View File

@ -1155,8 +1155,7 @@ def storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableN
return cursor.fetchall()[0][0]
#end def storeHands
def store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids,
start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos):
def store_hands_players_holdem_omaha(cursor, category, hands_id, player_ids, start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos):
result=[]
if (category=="holdem"):
for i in range (len(player_ids)):
@ -1211,8 +1210,7 @@ def store_hands_players_stud(cursor, hands_id, player_ids, start_cashes, antes,
return result
#end def store_hands_players_stud
def store_hands_players_holdem_omaha_tourney(cursor, hands_id, player_ids, start_cashes,
positions, card_values, card_suits, winnings, rakes, tourneys_players_ids):
def store_hands_players_holdem_omaha_tourney(cursor, category, hands_id, player_ids, start_cashes, positions, card_values, card_suits, winnings, rakes, seatNos, tourneys_players_ids):
#stores hands_players for tourney holdem/omaha hands
result=[]
for i in range (len(player_ids)):
@ -1220,22 +1218,22 @@ def store_hands_players_holdem_omaha_tourney(cursor, hands_id, player_ids, start
cursor.execute ("""INSERT INTO HandsPlayers
(handId, playerId, startCash, position,
card1Value, card1Suit, card2Value, card2Suit,
winnings, rake, tourneysPlayersId)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
winnings, rake, tourneysPlayersId, seatNo)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
(hands_id, player_ids[i], start_cashes[i], positions[i],
card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1],
winnings[i], rakes[i], tourneys_players_ids[i]))
winnings[i], rakes[i], tourneys_players_ids[i], seatNos[i]))
elif len(card_values[0])==4:
cursor.execute ("""INSERT INTO HandsPlayers
(handId, playerId, startCash, position,
card1Value, card1Suit, card2Value, card2Suit,
card3Value, card3Suit, card4Value, card4Suit,
winnings, rake, tourneysPlayersId)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
winnings, rake, tourneysPlayersId, seatNo)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
(hands_id, player_ids[i], start_cashes[i], positions[i],
card_values[i][0], card_suits[i][0], card_values[i][1], card_suits[i][1],
card_values[i][2], card_suits[i][2], card_values[i][3], card_suits[i][3],
winnings[i], rakes[i], tourneys_players_ids[i]))
winnings[i], rakes[i], tourneys_players_ids[i], seatNos[i]))
else:
raise FpdbError ("invalid card_values length:"+str(len(card_values[0])))
cursor.execute("SELECT id FROM HandsPlayers WHERE handId=%s AND playerId=%s", (hands_id, player_ids[i]))
@ -1882,18 +1880,18 @@ def storeHudCache(cursor, category, gametypeId, playerIds, hudImportData):
raise FpdbError("todo")
#end def storeHudCache
def store_tourneys(cursor, site_id, site_tourney_no, buyin, fee, knockout, entries, prizepool, start_time):
cursor.execute("SELECT id FROM Tourneys WHERE siteTourneyNo=%s AND siteId=%s", (site_tourney_no, site_id))
def store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, startTime):
cursor.execute("SELECT id FROM Tourneys WHERE siteTourneyNo=%s AND tourneyTypeId=%s", (siteTourneyNo, tourneyTypeId))
tmp=cursor.fetchone()
#print "tried SELECTing tourneys.id, result:",tmp
try:
len(tmp)
except TypeError:
except TypeError:#means we have to create new one
cursor.execute("""INSERT INTO Tourneys
(siteId, siteTourneyNo, buyin, fee, knockout, entries, prizepool, startTime)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)""", (site_id, site_tourney_no, buyin, fee, knockout, entries, prizepool, start_time))
cursor.execute("SELECT id FROM Tourneys WHERE siteTourneyNo=%s AND siteId=%s", (site_tourney_no, site_id))
(tourneyTypeId, siteTourneyNo, entries, prizepool, startTime)
VALUES (%s, %s, %s, %s, %s)""", (tourneyTypeId, siteTourneyNo, entries, prizepool, startTime))
cursor.execute("SELECT id FROM Tourneys WHERE siteTourneyNo=%s AND tourneyTypeId=%s", (siteTourneyNo, tourneyTypeId))
tmp=cursor.fetchone()
#print "created new tourneys.id:",tmp
return tmp[0]