2008-08-04 05:44:28 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
#Copyright 2008 Steffen Jobbagy-Felso
|
|
|
|
#This program is free software: you can redistribute it and/or modify
|
|
|
|
#it under the terms of the GNU Affero General Public License as published by
|
|
|
|
#the Free Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
#This program is distributed in the hope that it will be useful,
|
|
|
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
#GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
#You should have received a copy of the GNU Affero General Public License
|
|
|
|
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#In the "official" distribution you can find the license in
|
|
|
|
#agpl-3.0.txt in the docs folder of the package.
|
|
|
|
|
|
|
|
#This file contains methods to store hands into the db. decides to move this
|
|
|
|
#into a seperate file since its ugly, fairly long and just generally in the way.
|
|
|
|
|
2008-12-09 01:29:39 +01:00
|
|
|
from time import time
|
|
|
|
|
2008-08-04 05:44:28 +02:00
|
|
|
import fpdb_simple
|
|
|
|
|
2009-03-18 22:15:21 +01:00
|
|
|
MYSQL_INNODB = 2
|
|
|
|
PGSQL = 3
|
|
|
|
SQLITE = 4
|
2009-01-03 20:55:54 +01:00
|
|
|
|
2009-06-06 17:20:11 +02:00
|
|
|
#fastStoreHudCache = False # set this to True to test the new storeHudCache routine
|
|
|
|
#
|
|
|
|
#saveActions = True # set this to False to avoid storing action data
|
|
|
|
# # Pros: speeds up imports
|
|
|
|
# # Cons: no action data is saved, so you need to keep the hand histories
|
|
|
|
# # variance not available on stats page
|
|
|
|
# # no graphs
|
2008-12-14 03:38:09 +01:00
|
|
|
|
2008-08-04 05:44:28 +02:00
|
|
|
#stores a stud/razz hand into the database
|
2009-03-15 22:40:01 +01:00
|
|
|
def ring_stud(config, backend, db, cursor, base, category, site_hand_no, gametype_id, hand_start_time
|
2008-12-09 01:29:39 +01:00
|
|
|
,names, player_ids, start_cashes, antes, card_values, card_suits, winnings, rakes
|
|
|
|
,action_types, allIns, action_amounts, actionNos, hudImportData, maxSeats, tableName
|
|
|
|
,seatNos):
|
2009-03-15 22:40:01 +01:00
|
|
|
|
|
|
|
import_options = config.get_import_parameters()
|
2009-03-18 22:15:21 +01:00
|
|
|
|
2009-03-29 15:47:09 +02:00
|
|
|
saveActions = False if import_options['saveActions'] == False else True
|
|
|
|
fastStoreHudCache = True if import_options['fastStoreHudCache'] == True else False
|
2009-03-15 22:40:01 +01:00
|
|
|
|
2008-12-09 01:29:39 +01:00
|
|
|
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
|
|
|
|
2009-03-18 22:15:21 +01:00
|
|
|
hands_id = fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
2008-12-09 01:29:39 +01:00
|
|
|
,hand_start_time, names, tableName, maxSeats)
|
|
|
|
|
|
|
|
#print "before calling store_hands_players_stud, antes:", antes
|
2009-03-18 22:15:21 +01:00
|
|
|
hands_players_ids = fpdb_simple.store_hands_players_stud(backend, db, cursor, hands_id, player_ids
|
2008-12-09 01:29:39 +01:00
|
|
|
,start_cashes, antes, card_values
|
|
|
|
,card_suits, winnings, rakes, seatNos)
|
|
|
|
|
|
|
|
fpdb_simple.storeHudCache(cursor, base, category, gametype_id, player_ids, hudImportData)
|
|
|
|
|
2008-12-14 03:38:09 +01:00
|
|
|
if saveActions:
|
|
|
|
fpdb_simple.storeActions(cursor, hands_players_ids, action_types
|
|
|
|
,allIns, action_amounts, actionNos)
|
2008-12-09 01:29:39 +01:00
|
|
|
return hands_id
|
2008-08-04 05:44:28 +02:00
|
|
|
#end def ring_stud
|
|
|
|
|
2009-03-15 22:40:01 +01:00
|
|
|
def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no, gametype_id
|
2008-12-09 01:29:39 +01:00
|
|
|
,hand_start_time, names, player_ids, start_cashes, positions, card_values
|
|
|
|
,card_suits, board_values, board_suits, winnings, rakes, action_types, allIns
|
|
|
|
,action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos):
|
|
|
|
"""stores a holdem/omaha hand into the database"""
|
2009-03-15 22:40:01 +01:00
|
|
|
|
|
|
|
import_options = config.get_import_parameters()
|
2009-03-29 15:47:09 +02:00
|
|
|
saveActions = False if import_options['saveActions'] == False else True
|
|
|
|
fastStoreHudCache = True if import_options['fastStoreHudCache'] == True else False
|
2009-03-21 18:52:41 +01:00
|
|
|
|
2009-03-29 17:18:00 +02:00
|
|
|
# print "DEBUG: saveActions = '%s' fastStoreHudCache = '%s'"%(saveActions, fastStoreHudCache)
|
|
|
|
# print "DEBUG: import_options = ", import_options
|
2009-03-15 22:40:01 +01:00
|
|
|
|
2008-12-09 01:29:39 +01:00
|
|
|
t0 = time()
|
|
|
|
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
|
|
|
t1 = time()
|
|
|
|
fpdb_simple.fill_board_cards(board_values, board_suits)
|
|
|
|
t2 = time()
|
2008-08-04 05:44:28 +02:00
|
|
|
|
2009-03-18 22:15:21 +01:00
|
|
|
hands_id = fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
2008-12-09 01:29:39 +01:00
|
|
|
,hand_start_time, names, tableName, maxSeats)
|
|
|
|
t3 = time()
|
2009-03-18 22:15:21 +01:00
|
|
|
hands_players_ids = fpdb_simple.store_hands_players_holdem_omaha(
|
2008-12-09 01:29:39 +01:00
|
|
|
backend, db, cursor, category, hands_id, player_ids, start_cashes
|
|
|
|
, positions, card_values, card_suits, winnings, rakes, seatNos)
|
|
|
|
t4 = time()
|
2009-01-03 20:55:54 +01:00
|
|
|
#print "ring holdem, backend=%d" % backend
|
|
|
|
if fastStoreHudCache:
|
|
|
|
fpdb_simple.storeHudCache2(backend, cursor, base, category, gametype_id, player_ids, hudImportData)
|
|
|
|
else:
|
|
|
|
fpdb_simple.storeHudCache(cursor, base, category, gametype_id, player_ids, hudImportData)
|
2008-12-09 01:29:39 +01:00
|
|
|
t5 = time()
|
|
|
|
fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits)
|
|
|
|
t6 = time()
|
2008-12-14 03:38:09 +01:00
|
|
|
if saveActions:
|
|
|
|
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, allIns, action_amounts, actionNos)
|
2008-12-09 01:29:39 +01:00
|
|
|
t7 = time()
|
2008-12-14 03:38:09 +01:00
|
|
|
#print "fills=(%4.3f) saves=(%4.3f,%4.3f,%4.3f,%4.3f)" % (t2-t0, t3-t2, t4-t3, t5-t4, t6-t5)
|
2008-12-09 01:29:39 +01:00
|
|
|
return hands_id
|
2008-08-04 05:44:28 +02:00
|
|
|
#end def ring_holdem_omaha
|
|
|
|
|
2009-03-15 22:40:01 +01:00
|
|
|
def tourney_holdem_omaha(config, backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout
|
2008-12-09 01:29:39 +01:00
|
|
|
,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, allIns, action_amounts
|
|
|
|
,actionNos, hudImportData, maxSeats, tableName, seatNos):
|
|
|
|
"""stores a tourney holdem/omaha hand into the database"""
|
2009-03-15 22:40:01 +01:00
|
|
|
|
|
|
|
import_options = config.get_import_parameters()
|
2009-03-29 16:08:33 +02:00
|
|
|
saveActions = True if import_options['saveActions'] == True else False
|
|
|
|
fastStoreHudCache = True if import_options['fastStoreHudCache'] == True else False
|
2009-03-15 22:40:01 +01:00
|
|
|
|
2008-12-09 01:29:39 +01:00
|
|
|
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
|
|
|
fpdb_simple.fill_board_cards(board_values, board_suits)
|
|
|
|
|
2009-03-18 22:15:21 +01:00
|
|
|
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)
|
2008-12-09 01:29:39 +01:00
|
|
|
|
2009-03-18 22:15:21 +01:00
|
|
|
hands_id = fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
2008-12-09 01:29:39 +01:00
|
|
|
,hand_start_time, names, tableName, maxSeats)
|
|
|
|
|
2009-03-18 22:15:21 +01:00
|
|
|
hands_players_ids = fpdb_simple.store_hands_players_holdem_omaha_tourney(
|
2008-12-09 01:29:39 +01:00
|
|
|
backend, db, cursor, category, hands_id, player_ids, start_cashes, positions
|
|
|
|
, card_values, card_suits, winnings, rakes, seatNos, tourneys_players_ids)
|
|
|
|
|
2009-01-03 20:55:54 +01:00
|
|
|
#print "tourney holdem, backend=%d" % backend
|
|
|
|
if fastStoreHudCache:
|
|
|
|
fpdb_simple.storeHudCache2(backend, cursor, base, category, gametype_id, player_ids, hudImportData)
|
|
|
|
else:
|
|
|
|
fpdb_simple.storeHudCache(cursor, base, category, gametype_id, player_ids, hudImportData)
|
2008-12-09 01:29:39 +01:00
|
|
|
|
|
|
|
fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits)
|
|
|
|
|
2008-12-14 03:38:09 +01:00
|
|
|
if saveActions:
|
|
|
|
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, allIns, action_amounts, actionNos)
|
2008-12-09 01:29:39 +01:00
|
|
|
return hands_id
|
2008-08-04 05:44:28 +02:00
|
|
|
#end def tourney_holdem_omaha
|
|
|
|
|
2009-03-15 22:40:01 +01:00
|
|
|
def tourney_stud(config, backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries
|
2008-12-09 01:29:39 +01:00
|
|
|
,prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteId
|
|
|
|
,siteHandNo, gametypeId, handStartTime, names, playerIds, startCashes, antes
|
|
|
|
,cardValues, cardSuits, winnings, rakes, actionTypes, allIns, actionAmounts
|
|
|
|
,actionNos, hudImportData, maxSeats, tableName, seatNos):
|
2008-08-04 05:44:28 +02:00
|
|
|
#stores a tourney stud/razz hand into the database
|
2009-03-15 22:40:01 +01:00
|
|
|
|
|
|
|
import_options = config.get_import_parameters()
|
2009-03-29 16:08:33 +02:00
|
|
|
saveActions = True if import_options['saveActions'] == True else False
|
|
|
|
fastStoreHudCache = True if import_options['fastStoreHudCache'] == True else False
|
2009-03-15 22:40:01 +01:00
|
|
|
|
2008-12-09 01:29:39 +01:00
|
|
|
fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits)
|
|
|
|
|
2009-03-18 22:15:21 +01:00
|
|
|
tourney_id = fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourneyStartTime)
|
2008-12-09 01:29:39 +01:00
|
|
|
|
2009-03-18 22:15:21 +01:00
|
|
|
tourneys_players_ids = fpdb_simple.store_tourneys_players(cursor, tourney_id, playerIds, payin_amounts, ranks, winnings)
|
2008-12-09 01:29:39 +01:00
|
|
|
|
2009-03-18 22:15:21 +01:00
|
|
|
hands_id = fpdb_simple.storeHands(backend, db, cursor, siteHandNo, gametypeId, handStartTime, names, tableName, maxSeats)
|
2008-12-09 01:29:39 +01:00
|
|
|
|
2009-03-18 22:15:21 +01:00
|
|
|
hands_players_ids = fpdb_simple.store_hands_players_stud_tourney(backend, db, cursor, hands_id
|
2008-12-09 01:29:39 +01:00
|
|
|
, playerIds, startCashes, antes, cardValues, cardSuits
|
|
|
|
, winnings, rakes, seatNos, tourneys_players_ids)
|
|
|
|
|
|
|
|
fpdb_simple.storeHudCache(cursor, base, category, gametypeId, playerIds, hudImportData)
|
|
|
|
|
2008-12-14 03:38:09 +01:00
|
|
|
if saveActions:
|
|
|
|
fpdb_simple.storeActions(cursor, hands_players_ids, actionTypes, allIns, actionAmounts, actionNos)
|
2008-12-09 01:29:39 +01:00
|
|
|
return hands_id
|
2008-08-04 05:44:28 +02:00
|
|
|
#end def tourney_stud
|