Merge git://trac-git.assembla.com/fpdb
Conflicts: pyfpdb/Database.py --fixed conflict = we both fixed same problem differnt ways
This commit is contained in:
Regular → Executable
@@ -29,7 +29,8 @@ try:
|
||||
from numpy import arange, cumsum
|
||||
from pylab import *
|
||||
except:
|
||||
print "Failed to load libs for graphing, graphing will not function. Please install numpy and matplotlib."
|
||||
print "Failed to load libs for graphing, graphing will not function. Please install numpy and matplotlib if you want to use graphs."
|
||||
print "This is of no consequence for other parts of the program, e.g. import and HUD are NOT affected by this problem."
|
||||
|
||||
import fpdb_import
|
||||
import fpdb_db
|
||||
|
||||
@@ -20,6 +20,7 @@ import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
import os
|
||||
import fpdb_simple
|
||||
|
||||
try:
|
||||
import MySQLdb
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ import os
|
||||
import thread
|
||||
import Queue
|
||||
|
||||
errorfile = open('HUD-error.txt', 'w')
|
||||
errorfile = open('HUD-error.txt', 'w', 0)
|
||||
sys.stderr = errorfile
|
||||
|
||||
# pyGTK modules
|
||||
|
||||
+7
-6
@@ -18,8 +18,9 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
errorfile = open('fpdb-error.log', 'w')
|
||||
sys.stderr = errorfile
|
||||
print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_."
|
||||
errorFile = open('fpdb-error-log.txt', 'w', 0)
|
||||
sys.stderr = errorFile
|
||||
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
@@ -346,11 +347,11 @@ class fpdb:
|
||||
#end def load_profile
|
||||
|
||||
def not_implemented(self):
|
||||
print "todo: called unimplemented menu entry"#remove this once more entries are implemented
|
||||
print "todo: called unimplemented menu entry (users: pls ignore this)"#remove this once more entries are implemented
|
||||
#end def not_implemented
|
||||
|
||||
def obtain_global_lock(self):
|
||||
print "todo: implement obtain_global_lock"
|
||||
print "todo: implement obtain_global_lock (users: pls ignore this)"
|
||||
#end def obtain_global_lock
|
||||
|
||||
def quit(self, widget, data):
|
||||
@@ -420,7 +421,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: alpha4+, p102 or higher")
|
||||
self.window.set_title("Free Poker DB - version: alpha6+, p118 or higher")
|
||||
self.window.set_border_width(1)
|
||||
self.window.set_size_request(1020,400)
|
||||
self.window.set_resizable(True)
|
||||
@@ -444,7 +445,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
|
||||
("/Viewers/_Player Stats (tabulated view) (todo)", None, self.not_implemented, 0, None ),
|
||||
("/Viewers/Starting _Hands (todo)", None, self.not_implemented, 0, None ),
|
||||
("/Viewers/_Session Replayer (todo)", None, self.not_implemented, 0, None ),
|
||||
("/Viewers/Poker_table Viewer", "<control>T", self.tab_table_viewer, 0, None ),
|
||||
("/Viewers/Poker_table Viewer (obselete)", "<control>T", self.tab_table_viewer, 0, None ),
|
||||
#( "/Viewers/Tourney Replayer
|
||||
( "/_Database", None, None, 0, "<Branch>" ),
|
||||
( "/Database/Create or Delete _Database (todo)", None, self.dia_create_del_database, 0, None ),
|
||||
|
||||
+3
-2
@@ -48,7 +48,7 @@ class fpdb_db:
|
||||
try:
|
||||
self.cursor.execute("SELECT * FROM Settings")
|
||||
settings=self.cursor.fetchone()
|
||||
if settings[0]!=76:
|
||||
if settings[0]!=118:
|
||||
print "outdated or too new database version - please recreate tables"
|
||||
self.wrongDbVersion=True
|
||||
except:# _mysql_exceptions.ProgrammingError:
|
||||
@@ -152,7 +152,7 @@ class fpdb_db:
|
||||
#end def get_db_info
|
||||
|
||||
def fillDefaultData(self):
|
||||
self.cursor.execute("INSERT INTO Settings VALUES (76);")
|
||||
self.cursor.execute("INSERT INTO Settings VALUES (118);")
|
||||
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 VALUES (DEFAULT, 1, 0, 0, 0, False);")
|
||||
@@ -311,6 +311,7 @@ class fpdb_db:
|
||||
street SMALLINT NOT NULL,
|
||||
actionNo SMALLINT NOT NULL,
|
||||
action CHAR(5) NOT NULL,
|
||||
allIn BOOLEAN NOT NULL,
|
||||
amount INT NOT NULL,
|
||||
comment TEXT,
|
||||
commentTs DATETIME)""")
|
||||
|
||||
@@ -56,17 +56,17 @@ def import_file_dict(options, settings, callHud=False):
|
||||
inputFile=open(options.inputFile, "rU")
|
||||
|
||||
#connect to DB
|
||||
if options.settings['db-backend'] == 2:
|
||||
if settings['db-backend'] == 2:
|
||||
if not mysqlLibFound:
|
||||
raise fpdb_simple.FpdbError("interface library MySQLdb not found but MySQL selected as backend - please install the library or change the config file")
|
||||
db = MySQLdb.connect(host = options.server, user = options.user,
|
||||
passwd = options.password, db = options.database)
|
||||
elif options.settings['db-backend'] == 3:
|
||||
elif settings['db-backend'] == 3:
|
||||
if not pgsqlLibFound:
|
||||
raise fpdb_simple.FpdbError("interface library psycopg2 not found but PostgreSQL selected as backend - please install the library or change the config file")
|
||||
db = psycopg2.connect(host = options.server, user = options.user,
|
||||
password = options.password, database = options.database)
|
||||
elif options.settings['db-backend'] == 4:
|
||||
elif settings['db-backend'] == 4:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
@@ -224,5 +224,5 @@ if __name__ == "__main__":
|
||||
|
||||
(options, sys.argv) = parser.parse_args()
|
||||
|
||||
settings={'imp-callFpdbHud':False}
|
||||
settings={'imp-callFpdbHud':False, 'db-backend':2}
|
||||
import_file_dict(options, settings, False)
|
||||
|
||||
+10
-10
@@ -30,7 +30,7 @@ def mainParser(db, cursor, site, category, hand):
|
||||
lineTypes=[] #char, valid values: header, name, cards, action, win, rake, ignore
|
||||
lineStreets=[] #char, valid values: (predeal, preflop, flop, turn, river)
|
||||
|
||||
cardValues, cardSuits, boardValues, boardSuits, antes, actionTypes, actionAmounts, actionNos, actionTypeByNo, seatLines, winnings, rakes=[], [],[],[],[],[],[],[],[],[],[],[]
|
||||
cardValues, cardSuits, boardValues, boardSuits, antes, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo, seatLines, winnings, rakes=[],[],[],[],[],[],[],[],[],[],[],[],[]
|
||||
|
||||
#part 1: read hand no and check for duplicate
|
||||
siteHandNo=fpdb_simple.parseSiteHandNo(hand[0])
|
||||
@@ -76,7 +76,7 @@ def mainParser(db, cursor, site, category, hand):
|
||||
startCashes=tmp['startCashes']
|
||||
seatNos=tmp['seatNos']
|
||||
|
||||
fpdb_simple.createArrays(category, len(names), cardValues, cardSuits, antes, winnings, rakes, actionTypes, actionAmounts, actionNos, actionTypeByNo)
|
||||
fpdb_simple.createArrays(category, len(names), cardValues, cardSuits, antes, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
||||
|
||||
#3b read positions
|
||||
if base=="hold":
|
||||
@@ -87,7 +87,7 @@ def mainParser(db, cursor, site, category, hand):
|
||||
if (lineTypes[i]=="cards"):
|
||||
fpdb_simple.parseCardLine (site, category, lineStreets[i], hand[i], names, cardValues, cardSuits, boardValues, boardSuits)
|
||||
elif (lineTypes[i]=="action"):
|
||||
fpdb_simple.parseActionLine (site, base, hand[i], lineStreets[i], playerIDs, names, actionTypes, actionAmounts, actionNos, actionTypeByNo)
|
||||
fpdb_simple.parseActionLine (site, base, isTourney, hand[i], lineStreets[i], playerIDs, names, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
||||
elif (lineTypes[i]=="win"):
|
||||
fpdb_simple.parseWinLine (hand[i], site, names, winnings, isTourney)
|
||||
elif (lineTypes[i]=="rake"):
|
||||
@@ -99,7 +99,7 @@ def mainParser(db, cursor, site, category, hand):
|
||||
elif (lineTypes[i]=="header" or lineTypes[i]=="rake" or lineTypes[i]=="name" or lineTypes[i]=="ignore"):
|
||||
pass
|
||||
elif (lineTypes[i]=="ante"):
|
||||
fpdb_simple.parseAnteLine(hand[i], site, names, antes)
|
||||
fpdb_simple.parseAnteLine(hand[i], site, isTourney, names, antes)
|
||||
elif (lineTypes[i]=="table"):
|
||||
tableResult=fpdb_simple.parseTableLine(site, base, hand[i])
|
||||
else:
|
||||
@@ -126,9 +126,9 @@ def mainParser(db, cursor, site, category, hand):
|
||||
totalWinnings+=winnings[i]
|
||||
|
||||
if base=="hold":
|
||||
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes, actionTypeByNo, winnings, totalWinnings, positions)
|
||||
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes, allIns, actionTypeByNo, winnings, totalWinnings, positions)
|
||||
else:
|
||||
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes, actionTypeByNo, winnings, totalWinnings, None)
|
||||
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes, allIns, actionTypeByNo, winnings, totalWinnings, None)
|
||||
|
||||
if isTourney:
|
||||
ranks=[]
|
||||
@@ -138,22 +138,22 @@ def mainParser(db, cursor, site, category, hand):
|
||||
|
||||
if base=="hold":
|
||||
result = fpdb_save_to_db.tourney_holdem_omaha(cursor, base, 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)
|
||||
siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
||||
elif base=="stud":
|
||||
result = fpdb_save_to_db.tourney_stud(cursor, base, category, siteTourneyNo, buyin, fee,
|
||||
knockout, entries, prizepool, tourneyStartTime, payin_amounts, ranks,
|
||||
siteHandNo, siteID, gametypeID, handStartTime, names, playerIDs,
|
||||
startCashes, antes, cardValues, cardSuits, winnings, rakes,
|
||||
actionTypes, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
||||
actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
||||
else:
|
||||
raise fpdb_simple.FpdbError ("unrecognised category")
|
||||
else:
|
||||
if base=="hold":
|
||||
result = fpdb_save_to_db.ring_holdem_omaha(cursor, base, category, siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
||||
result = fpdb_save_to_db.ring_holdem_omaha(cursor, base, category, siteHandNo, gametypeID, handStartTime, names, playerIDs, startCashes, positions, cardValues, cardSuits, boardValues, boardSuits, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
||||
elif base=="stud":
|
||||
result = fpdb_save_to_db.ring_stud(cursor, base, category, siteHandNo, gametypeID,
|
||||
handStartTime, names, playerIDs, startCashes, antes, cardValues,
|
||||
cardSuits, winnings, rakes, actionTypes, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
||||
cardSuits, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
||||
else:
|
||||
raise fpdb_simple.FpdbError ("unrecognised category")
|
||||
db.commit()
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
import fpdb_simple
|
||||
|
||||
#stores a stud/razz hand into the database
|
||||
def ring_stud(cursor, base, category, site_hand_no, gametype_id, hand_start_time, names, player_ids, start_cashes, antes, card_values, card_suits, winnings, rakes, action_types, action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos):
|
||||
def ring_stud(cursor, base, category, site_hand_no, gametype_id, hand_start_time, names, player_ids, start_cashes, antes, card_values, card_suits, winnings, rakes, action_types, allIns, action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos):
|
||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||
|
||||
hands_id=fpdb_simple.storeHands(cursor, site_hand_no, gametype_id, hand_start_time, names, tableName, maxSeats)
|
||||
@@ -31,11 +31,11 @@ def ring_stud(cursor, base, category, site_hand_no, gametype_id, hand_start_time
|
||||
|
||||
fpdb_simple.storeHudCache(cursor, base, category, gametype_id, player_ids, hudImportData)
|
||||
|
||||
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts, actionNos)
|
||||
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, allIns, action_amounts, actionNos)
|
||||
return hands_id
|
||||
#end def ring_stud
|
||||
|
||||
def ring_holdem_omaha(cursor, base, 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):
|
||||
def ring_holdem_omaha(cursor, base, 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, allIns, action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos):
|
||||
"""stores a holdem/omaha hand into the database"""
|
||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||
fpdb_simple.fill_board_cards(board_values, board_suits)
|
||||
@@ -48,12 +48,12 @@ def ring_holdem_omaha(cursor, base, category, site_hand_no, gametype_id, hand_st
|
||||
|
||||
fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits)
|
||||
|
||||
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts, actionNos)
|
||||
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, allIns, action_amounts, actionNos)
|
||||
return hands_id
|
||||
#end def ring_holdem_omaha
|
||||
|
||||
def tourney_holdem_omaha(cursor, base, 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):
|
||||
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"""
|
||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||
fpdb_simple.fill_board_cards(board_values, board_suits)
|
||||
@@ -69,7 +69,7 @@ def tourney_holdem_omaha(cursor, base, category, siteTourneyNo, buyin, fee, knoc
|
||||
|
||||
fpdb_simple.store_board_cards(cursor, hands_id, board_values, board_suits)
|
||||
|
||||
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts, actionNos)
|
||||
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, allIns, action_amounts, actionNos)
|
||||
return hands_id
|
||||
#end def tourney_holdem_omaha
|
||||
|
||||
@@ -77,7 +77,7 @@ def tourney_stud(cursor, base, category, site_tourney_no, buyin, fee, knockout,
|
||||
tourney_start, payin_amounts, ranks, #end of tourney specific params
|
||||
site_hand_no, site_id, gametype_id, hand_start_time, names, player_ids,
|
||||
start_cashes, antes, card_values, card_suits, winnings, rakes,
|
||||
action_types, action_amounts, hudImportData):
|
||||
action_types, allIns, action_amounts, hudImportData):
|
||||
#stores a tourney stud/razz hand into the database
|
||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||
|
||||
@@ -92,6 +92,6 @@ def tourney_stud(cursor, base, category, site_tourney_no, buyin, fee, knockout,
|
||||
|
||||
fpdb_simple.storeHudData(cursor, base, category, player_ids, hudImportData)
|
||||
|
||||
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, action_amounts)
|
||||
fpdb_simple.storeActions(cursor, hands_players_ids, action_types, allIns, action_amounts)
|
||||
return hands_id
|
||||
#end def tourney_stud
|
||||
|
||||
+65
-27
@@ -204,7 +204,7 @@ def convertCardValuesBoard(arr):
|
||||
#end def convertCardValuesBoard
|
||||
|
||||
#this creates the 2D/3D arrays. manipulates the passed arrays instead of returning.
|
||||
def createArrays(category, seats, card_values, card_suits, antes, winnings, rakes, action_types, action_amounts, actionNos, actionTypeByNo):
|
||||
def createArrays(category, seats, card_values, card_suits, antes, winnings, rakes, action_types, allIns, action_amounts, actionNos, actionTypeByNo):
|
||||
for i in range(seats):#create second dimension arrays
|
||||
tmp=[]
|
||||
card_values.append(tmp)
|
||||
@@ -223,6 +223,8 @@ def createArrays(category, seats, card_values, card_suits, antes, winnings, rake
|
||||
tmp=[]
|
||||
action_types.append(tmp)
|
||||
tmp=[]
|
||||
allIns.append(tmp)
|
||||
tmp=[]
|
||||
action_amounts.append(tmp)
|
||||
tmp=[]
|
||||
actionNos.append(tmp)
|
||||
@@ -232,6 +234,8 @@ def createArrays(category, seats, card_values, card_suits, antes, winnings, rake
|
||||
tmp=[]
|
||||
action_types[i].append(tmp)
|
||||
tmp=[]
|
||||
allIns[i].append(tmp)
|
||||
tmp=[]
|
||||
action_amounts[i].append(tmp)
|
||||
tmp=[]
|
||||
actionNos[i].append(tmp)
|
||||
@@ -542,11 +546,11 @@ def isWinLine(line):
|
||||
#end def isWinLine
|
||||
|
||||
#returns the amount of cash/chips put into the put in the given action line
|
||||
def parseActionAmount(line, atype, site):
|
||||
if (line.endswith(" and is all-in")):
|
||||
line=line[:-14]
|
||||
elif (line.endswith(", and is all in")):
|
||||
line=line[:-15]
|
||||
def parseActionAmount(line, atype, site, isTourney):
|
||||
#if (line.endswith(" and is all-in")):
|
||||
# line=line[:-14]
|
||||
#elif (line.endswith(", and is all in")):
|
||||
# line=line[:-15]
|
||||
|
||||
if line.endswith(", and is capped"):#ideally we should recognise this as an all-in if category is capXl
|
||||
line=line[:-15]
|
||||
@@ -573,8 +577,8 @@ def parseActionAmount(line, atype, site):
|
||||
pos=line.find("to $")+4
|
||||
amount=float2int(line[pos:])
|
||||
else:
|
||||
pos=line.rfind("$")+1
|
||||
if pos!=0:
|
||||
if not isTourney:
|
||||
pos=line.rfind("$")+1
|
||||
amount=float2int(line[pos:])
|
||||
else:
|
||||
#print "line:"+line+"EOL"
|
||||
@@ -591,7 +595,7 @@ def parseActionAmount(line, atype, site):
|
||||
#doesnt return anything, simply changes the passed arrays action_types and
|
||||
# action_amounts. For stud this expects numeric streets (3-7), for
|
||||
# holdem/omaha it expects predeal, preflop, flop, turn or river
|
||||
def parseActionLine(site, base, line, street, playerIDs, names, action_types, action_amounts, actionNos, actionTypeByNo):
|
||||
def parseActionLine(site, base, isTourney, line, street, playerIDs, names, action_types, allIns, action_amounts, actionNos, actionTypeByNo):
|
||||
if (street=="predeal" or street=="preflop"):
|
||||
street=0
|
||||
elif (street=="flop"):
|
||||
@@ -606,18 +610,32 @@ def parseActionLine(site, base, line, street, playerIDs, names, action_types, ac
|
||||
for count in range(len(actionNos[street][player])):
|
||||
if actionNos[street][player][count]>=nextActionNo:
|
||||
nextActionNo=actionNos[street][player][count]+1
|
||||
|
||||
|
||||
line, allIn=goesAllInOnThisLine(line)
|
||||
atype=parseActionType(line)
|
||||
playerno=recognisePlayerNo(line, names, atype)
|
||||
amount=parseActionAmount(line, atype, site)
|
||||
amount=parseActionAmount(line, atype, site, isTourney)
|
||||
|
||||
action_types[street][playerno].append(atype)
|
||||
allIns[street][playerno].append(allIn)
|
||||
action_amounts[street][playerno].append(amount)
|
||||
actionNos[street][playerno].append(nextActionNo)
|
||||
tmp=(playerIDs[playerno], atype)
|
||||
actionTypeByNo[street].append(tmp)
|
||||
#end def parseActionLine
|
||||
|
||||
def goesAllInOnThisLine(line):
|
||||
"""returns whether the player went all-in on this line and removes the all-in text from the line."""
|
||||
isAllIn=False
|
||||
if (line.endswith(" and is all-in")):
|
||||
line=line[:-14]
|
||||
isAllIn=True
|
||||
elif (line.endswith(", and is all in")):
|
||||
line=line[:-15]
|
||||
isAllIn=True
|
||||
return (line, isAllIn)
|
||||
#end def goesAllInOnThisLine
|
||||
|
||||
#returns the action type code (see table design) of the given action line
|
||||
def parseActionType(line):
|
||||
if (line.startswith("Uncalled bet")):
|
||||
@@ -657,15 +675,21 @@ def parseActionType(line):
|
||||
#end def parseActionType
|
||||
|
||||
#parses the ante out of the given line and checks which player paid it, updates antes accordingly.
|
||||
def parseAnteLine(line, site, names, antes):
|
||||
def parseAnteLine(line, site, isTourney, names, antes):
|
||||
#print "parseAnteLine line: ",line
|
||||
for i in range(len(names)):
|
||||
if (line.startswith(names[i].encode("latin-1"))): #found the ante'er
|
||||
pos=line.rfind("$")+1
|
||||
if pos!=0: #found $, so must be ring
|
||||
if not isTourney:
|
||||
antes[i]+=float2int(line[pos:])
|
||||
else:
|
||||
pos=line.rfind(" ")+1
|
||||
antes[i]+=int(line[pos:])
|
||||
if line.find("all-in")==-1:
|
||||
pos=line.rfind(" ")+1
|
||||
antes[i]+=int(line[pos:])
|
||||
else:
|
||||
pos1=line.rfind("ante")+5
|
||||
pos2=line.find(" ",pos1)
|
||||
antes[i]+=int(line[pos1:pos2])
|
||||
#end def parseAntes
|
||||
|
||||
#returns the buyin of a tourney in cents
|
||||
@@ -938,7 +962,7 @@ def parseWinLine(line, site, names, winnings, isTourney):
|
||||
for i in range(len(names)):
|
||||
if (line.startswith(names[i].encode("latin-1"))): #found a winner
|
||||
if isTourney:
|
||||
pos1=line.rfind("collected ")+11
|
||||
pos1=line.rfind("collected ")+10
|
||||
if (site=="ftp"):
|
||||
pos2=line.find(")", pos1)
|
||||
elif (site=="ps"):
|
||||
@@ -1179,14 +1203,14 @@ def splitRake(winnings, rakes, totalRake):
|
||||
rakes[i]=totalRake*winPortion
|
||||
#end def splitRake
|
||||
|
||||
def storeActions(cursor, hands_players_ids, action_types, action_amounts, actionNos):
|
||||
def storeActions(cursor, handsPlayersIds, actionTypes, allIns, actionAmounts, actionNos):
|
||||
#stores into table hands_actions
|
||||
#print "start of storeActions, actionNos:",actionNos
|
||||
#print " action_amounts:",action_amounts
|
||||
for i in range (len(action_types)): #iterate through streets
|
||||
for j in range (len(action_types[i])): #iterate through names
|
||||
for k in range (len(action_types[i][j])): #iterate through individual actions of that player on that street
|
||||
cursor.execute ("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, amount) VALUES (%s, %s, %s, %s, %s)", (hands_players_ids[j], i, actionNos[i][j][k], action_types[i][j][k], action_amounts[i][j][k]))
|
||||
for i in range (len(actionTypes)): #iterate through streets
|
||||
for j in range (len(actionTypes[i])): #iterate through names
|
||||
for k in range (len(actionTypes[i][j])): #iterate through individual actions of that player on that street
|
||||
cursor.execute ("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, allIn, amount) VALUES (%s, %s, %s, %s, %s, %s)", (handsPlayersIds[j], i, actionNos[i][j][k], actionTypes[i][j][k], allIns[i][j][k], actionAmounts[i][j][k]))
|
||||
#end def storeActions
|
||||
|
||||
def store_board_cards(cursor, hands_id, board_values, board_suits):
|
||||
@@ -1317,7 +1341,7 @@ def store_hands_players_stud_tourney(cursor, hands_id, player_ids, start_cashes,
|
||||
return result
|
||||
#end def store_hands_players_stud_tourney
|
||||
|
||||
def generateHudCacheData(player_ids, base, category, action_types, actionTypeByNo, winnings, totalWinnings, positions):
|
||||
def generateHudCacheData(player_ids, base, category, action_types, allIns, actionTypeByNo, winnings, totalWinnings, positions):
|
||||
"""calculates data for the HUD during import. IMPORTANT: if you change this method make sure to also change the following storage method and table_viewer.prepare_data if necessary"""
|
||||
#setup subarrays of the result dictionary.
|
||||
street0VPI=[]
|
||||
@@ -1465,14 +1489,28 @@ def generateHudCacheData(player_ids, base, category, action_types, actionTypeByN
|
||||
|
||||
if myStealAttempted:
|
||||
someoneStole=True
|
||||
|
||||
|
||||
|
||||
#calculate saw* values
|
||||
if (len(action_types[1][player])>0):
|
||||
isAllIn=False
|
||||
for i in range(len(allIns[0][player])):
|
||||
if allIns[0][player][i]:
|
||||
isAllIn=True
|
||||
if (len(action_types[1][player])>0 or isAllIn):
|
||||
myStreet1Seen=True
|
||||
if (len(action_types[2][player])>0):
|
||||
|
||||
for i in range(len(allIns[1][player])):
|
||||
if allIns[1][player][i]:
|
||||
isAllIn=True
|
||||
if (len(action_types[2][player])>0 or isAllIn):
|
||||
myStreet2Seen=True
|
||||
if (len(action_types[3][player])>0):
|
||||
|
||||
for i in range(len(allIns[2][player])):
|
||||
if allIns[2][player][i]:
|
||||
isAllIn=True
|
||||
if (len(action_types[3][player])>0 or isAllIn):
|
||||
myStreet3Seen=True
|
||||
|
||||
mySawShowdown=True
|
||||
for count in range (len(action_types[3][player])):
|
||||
if action_types[3][player][count]=="fold":
|
||||
@@ -1577,7 +1615,7 @@ def generateHudCacheData(player_ids, base, category, action_types, actionTypeByN
|
||||
elif pos>=2 and pos<=4:
|
||||
hudDataPositions.append('M')
|
||||
elif pos>=5 and pos<=7:
|
||||
hudDataPositions.append('L')
|
||||
hudDataPositions.append('E')
|
||||
### RHH Added this elif to handle being a dead hand before the BB (pos==9)
|
||||
elif pos==9:
|
||||
hudDataPositions.append('X')
|
||||
|
||||
@@ -137,6 +137,7 @@ CREATE TABLE HandsActions (
|
||||
street SMALLINT,
|
||||
actionNo SMALLINT,
|
||||
action CHAR(5),
|
||||
allIn BOOLEAN,
|
||||
amount INT,
|
||||
comment TEXT,
|
||||
commentTs timestamp without time zone);
|
||||
@@ -211,7 +212,7 @@ CREATE TABLE HudCache (
|
||||
street4CheckCallRaiseChance INT,
|
||||
street4CheckCallRaiseDone INT);
|
||||
|
||||
INSERT INTO Settings VALUES (76);
|
||||
INSERT INTO Settings VALUES (118);
|
||||
INSERT INTO Sites ("name", currency) VALUES ('Full Tilt Poker', 'USD');
|
||||
INSERT INTO Sites ("name", currency) VALUES ('PokerStars', 'USD');
|
||||
INSERT INTO TourneyTypes (buyin, fee, knockout, rebuyOrAddon) VALUES (0, 0, 0, FALSE);
|
||||
|
||||
Reference in New Issue
Block a user