Merge branch 'master' of git://git.assembla.com/fpdboz
This commit is contained in:
commit
a324dc4c7e
|
@ -165,19 +165,11 @@ class Database:
|
||||||
c = self.connection.cursor()
|
c = self.connection.cursor()
|
||||||
|
|
||||||
if aggregate:
|
if aggregate:
|
||||||
query = 'get_stats_from_hand'
|
|
||||||
subs = (hand, hand)
|
|
||||||
else:
|
|
||||||
query = 'get_stats_from_hand_aggregated'
|
query = 'get_stats_from_hand_aggregated'
|
||||||
subs = (hand, hand, hand)
|
subs = (hand, hand, hand)
|
||||||
|
else:
|
||||||
# get the players in the hand and their seats
|
query = 'get_stats_from_hand'
|
||||||
c.execute(self.sql.query['get_players_from_hand'], (hand, ))
|
subs = (hand, hand)
|
||||||
names = {}
|
|
||||||
seats = {}
|
|
||||||
for row in c.fetchall():
|
|
||||||
names[row[0]] = row[2]
|
|
||||||
seats[row[0]] = row[1]
|
|
||||||
|
|
||||||
# now get the stats
|
# now get the stats
|
||||||
c.execute(self.sql.query[query], subs)
|
c.execute(self.sql.query[query], subs)
|
||||||
|
@ -187,9 +179,6 @@ class Database:
|
||||||
t_dict = {}
|
t_dict = {}
|
||||||
for name, val in zip(colnames, row):
|
for name, val in zip(colnames, row):
|
||||||
t_dict[name] = val
|
t_dict[name] = val
|
||||||
# print t_dict
|
|
||||||
t_dict['screen_name'] = names[t_dict['player_id']]
|
|
||||||
t_dict['seat'] = seats[t_dict['player_id']]
|
|
||||||
stat_dict[t_dict['player_id']] = t_dict
|
stat_dict[t_dict['player_id']] = t_dict
|
||||||
return stat_dict
|
return stat_dict
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class FullTilt(HandHistoryConverter):
|
||||||
self.re_PostBB = re.compile('.*\n(?P<PNAME>.*) posts (the big blind of )?\$?(?P<BB>[.0-9]+)')
|
self.re_PostBB = re.compile('.*\n(?P<PNAME>.*) posts (the big blind of )?\$?(?P<BB>[.0-9]+)')
|
||||||
self.re_BringIn = re.compile('.*\n(?P<PNAME>.*) brings in for \$?(?P<BRINGIN>[.0-9]+)')
|
self.re_BringIn = re.compile('.*\n(?P<PNAME>.*) brings in for \$?(?P<BRINGIN>[.0-9]+)')
|
||||||
self.re_PostBoth = re.compile('.*\n(?P<PNAME>.*) posts small \& big blinds \[\$? (?P<SBBB>[.0-9]+)')
|
self.re_PostBoth = re.compile('.*\n(?P<PNAME>.*) posts small \& big blinds \[\$? (?P<SBBB>[.0-9]+)')
|
||||||
self.re_HeroCards = re.compile('.*\nDealt\sto\s(?P<PNAME>.*)\s\[(?P<CARDS>.*)\]')
|
self.re_HeroCards = re.compile('.*\nDealt\sto\s(?P<PNAME>.*)\s\[(?P<CARDS>.*)\]( [(?P<NEWCARD>.*])?')
|
||||||
self.re_Action = re.compile('.*\n(?P<PNAME>.*)(?P<ATYPE> bets| checks| raises to| calls| folds)(\s\$(?P<BET>[.\d]+))?')
|
self.re_Action = re.compile('.*\n(?P<PNAME>.*)(?P<ATYPE> bets| checks| raises to| calls| folds)(\s\$(?P<BET>[.\d]+))?')
|
||||||
self.re_ShowdownAction = re.compile('.*\n(?P<PNAME>.*) shows \[(?P<CARDS>.*)\]')
|
self.re_ShowdownAction = re.compile('.*\n(?P<PNAME>.*) shows \[(?P<CARDS>.*)\]')
|
||||||
self.re_CollectPot = re.compile(r"Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*?) (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$(?P<POT>[.\d]+)\)(, mucked| with.*)")
|
self.re_CollectPot = re.compile(r"Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*?) (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$(?P<POT>[.\d]+)\)(, mucked| with.*)")
|
||||||
|
@ -174,6 +174,21 @@ class FullTilt(HandHistoryConverter):
|
||||||
cards = set(cards.split(' '))
|
cards = set(cards.split(' '))
|
||||||
hand.addHoleCards(cards, m.group('PNAME'))
|
hand.addHoleCards(cards, m.group('PNAME'))
|
||||||
|
|
||||||
|
def readPlayerCards(self, hand, street):
|
||||||
|
#Used for stud hands - borrows the HeroCards regex for now.
|
||||||
|
m = self.re_HeroCards.finditer(hand.streets.group(street))
|
||||||
|
print "DEBUG: razz/stud readPlayerCards"
|
||||||
|
print "DEBUG: STREET: %s", street
|
||||||
|
for player in m:
|
||||||
|
print player.groups()
|
||||||
|
#hand.hero = m.group('PNAME')
|
||||||
|
# "2c, qh" -> set(["2c","qc"])
|
||||||
|
# Also works with Omaha hands.
|
||||||
|
cards = player.group('CARDS')
|
||||||
|
print "DEBUG: PNAME: %s CARDS: %s" %(player.group('PNAME'), player.group('CARDS'))
|
||||||
|
cards = set(cards.split(' '))
|
||||||
|
# hand.addHoleCards(cards, m.group('PNAME'))
|
||||||
|
|
||||||
def readAction(self, hand, street):
|
def readAction(self, hand, street):
|
||||||
m = self.re_Action.finditer(hand.streets.group(street))
|
m = self.re_Action.finditer(hand.streets.group(street))
|
||||||
for action in m:
|
for action in m:
|
||||||
|
|
|
@ -106,7 +106,8 @@ class GuiAutoImport (threading.Thread):
|
||||||
"""Callback for timer to do an import iteration."""
|
"""Callback for timer to do an import iteration."""
|
||||||
if self.doAutoImportBool:
|
if self.doAutoImportBool:
|
||||||
self.importer.runUpdated()
|
self.importer.runUpdated()
|
||||||
print "GuiAutoImport.import_dir done"
|
sys.stdout.write(".")
|
||||||
|
sys.stdout.flush()
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
@ -128,12 +129,12 @@ class GuiAutoImport (threading.Thread):
|
||||||
widget.set_label(u'Stop Autoimport')
|
widget.set_label(u'Stop Autoimport')
|
||||||
if self.pipe_to_hud is None:
|
if self.pipe_to_hud is None:
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
command = "python HUD_run_me.py" + " %s" % (self.database)
|
command = "python HUD_main.py" + " %s" % (self.database)
|
||||||
bs = 0 # windows is not happy with line buffing here
|
bs = 0 # windows is not happy with line buffing here
|
||||||
self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE,
|
self.pipe_to_hud = subprocess.Popen(command, bufsize = bs, stdin = subprocess.PIPE,
|
||||||
universal_newlines=True)
|
universal_newlines=True)
|
||||||
else:
|
else:
|
||||||
command = self.config.execution_path('HUD_run_me.py')
|
command = self.config.execution_path('HUD_main.py')
|
||||||
bs = 1
|
bs = 1
|
||||||
self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE,
|
self.pipe_to_hud = subprocess.Popen((command, self.database), bufsize = bs, stdin = subprocess.PIPE,
|
||||||
universal_newlines=True)
|
universal_newlines=True)
|
||||||
|
|
|
@ -26,7 +26,6 @@ Main for FreePokerTools HUD.
|
||||||
# to do hud to echo, but ignore non numbers
|
# to do hud to echo, but ignore non numbers
|
||||||
# to do no stat window for hero
|
# to do no stat window for hero
|
||||||
# to do things to add to config.xml
|
# to do things to add to config.xml
|
||||||
# to do font and size
|
|
||||||
|
|
||||||
# Standard Library modules
|
# Standard Library modules
|
||||||
import sys
|
import sys
|
||||||
|
@ -47,141 +46,153 @@ import Database
|
||||||
import Tables
|
import Tables
|
||||||
import Hud
|
import Hud
|
||||||
|
|
||||||
# global dict for keeping the huds
|
class HUD_main(object):
|
||||||
hud_dict = {}
|
"""A main() object to own both the read_stdin thread and the gui."""
|
||||||
eb = 0 # our former event-box
|
# This class mainly provides state for controlling the multiple HUDs.
|
||||||
|
|
||||||
db_connection = 0;
|
def __init__(self, db_name = 'fpdb'):
|
||||||
config = 0;
|
self.db_name = db_name
|
||||||
|
self.config = Configuration.Config()
|
||||||
|
self.hud_dict = {}
|
||||||
|
|
||||||
def destroy(*args): # call back for terminating the main eventloop
|
# a thread to read stdin
|
||||||
|
gobject.threads_init() # this is required
|
||||||
|
thread.start_new_thread(self.read_stdin, ()) # starts the thread
|
||||||
|
|
||||||
|
# a main window
|
||||||
|
self.main_window = gtk.Window()
|
||||||
|
self.main_window.connect("destroy", self.destroy)
|
||||||
|
self.vb = gtk.VBox()
|
||||||
|
self.label = gtk.Label('Closing this window will exit from the HUD.')
|
||||||
|
self.vb.add(self.label)
|
||||||
|
self.main_window.add(self.vb)
|
||||||
|
self.main_window.set_title("HUD Main Window")
|
||||||
|
self.main_window.show_all()
|
||||||
|
|
||||||
|
def destroy(*args): # call back for terminating the main eventloop
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
|
||||||
def create_HUD(new_hand_id, table, db_name, table_name, max, poker_game, db_connection, config, stat_dict):
|
def create_HUD(self, new_hand_id, table, table_name, max, poker_game, is_tournament, stat_dict):
|
||||||
global hud_dict, eb
|
|
||||||
|
|
||||||
def idle_func():
|
def idle_func():
|
||||||
global hud_dict, eb
|
|
||||||
|
|
||||||
gtk.gdk.threads_enter()
|
gtk.gdk.threads_enter()
|
||||||
try:
|
try:
|
||||||
newlabel = gtk.Label(table.site + " - " + table_name)
|
newlabel = gtk.Label(table.site + " - " + table_name)
|
||||||
eb.add(newlabel)
|
self.vb.add(newlabel)
|
||||||
newlabel.show()
|
newlabel.show()
|
||||||
|
|
||||||
hud_dict[table_name] = Hud.Hud(table, max, poker_game, config, db_connection)
|
self.hud_dict[table_name] = Hud.Hud(self, table, max, poker_game, self.config, self.db_connection)
|
||||||
hud_dict[table_name].tablehudlabel = newlabel
|
self.hud_dict[table_name].tablehudlabel = newlabel
|
||||||
hud_dict[table_name].create(new_hand_id, config)
|
self.hud_dict[table_name].create(new_hand_id, self.config, stat_dict)
|
||||||
for m in hud_dict[table_name].aux_windows:
|
for m in self.hud_dict[table_name].aux_windows:
|
||||||
m.update_data(new_hand_id, db_connection)
|
m.update_data(new_hand_id, self.db_connection)
|
||||||
m.update_gui(new_hand_id)
|
m.update_gui(new_hand_id)
|
||||||
hud_dict[table_name].update(new_hand_id, config, stat_dict)
|
self.hud_dict[table_name].update(new_hand_id, self.config, stat_dict)
|
||||||
hud_dict[table_name].reposition_windows()
|
self.hud_dict[table_name].reposition_windows()
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
gtk.gdk.threads_leave()
|
gtk.gdk.threads_leave()
|
||||||
gobject.idle_add(idle_func)
|
gobject.idle_add(idle_func)
|
||||||
|
|
||||||
def update_HUD(new_hand_id, table_name, config, stat_dict):
|
def update_HUD(self, new_hand_id, table_name, config, stat_dict):
|
||||||
global hud_dict
|
"""Update a HUD gui from inside the non-gui read_stdin thread."""
|
||||||
|
# This is written so that only 1 thread can touch the gui--mainly
|
||||||
|
# for compatibility with Windows. This method dispatches the
|
||||||
|
# function idle_func() to be run by the gui thread, at its leisure.
|
||||||
def idle_func():
|
def idle_func():
|
||||||
gtk.gdk.threads_enter()
|
gtk.gdk.threads_enter()
|
||||||
try:
|
try:
|
||||||
hud_dict[table_name].update(new_hand_id, config, stat_dict)
|
self.hud_dict[table_name].update(new_hand_id, config, stat_dict)
|
||||||
for m in hud_dict[table_name].aux_windows:
|
for m in self.hud_dict[table_name].aux_windows:
|
||||||
m.update_gui(new_hand_id)
|
m.update_gui(new_hand_id)
|
||||||
return False
|
return False
|
||||||
finally:
|
finally:
|
||||||
gtk.gdk.threads_leave()
|
gtk.gdk.threads_leave()
|
||||||
gobject.idle_add(idle_func)
|
gobject.idle_add(idle_func)
|
||||||
|
|
||||||
def HUD_removed(tablename):
|
def HUD_removed(self, tablename):
|
||||||
global hud_dict, eb
|
|
||||||
|
|
||||||
tablename = Tables.clean_title(tablename)
|
tablename = Tables.clean_title(tablename)
|
||||||
# TODO: There's a potential problem here somewhere, that this hacks around .. the table_name as being passed to HUD_create is cleaned,
|
# TODO: There's a potential problem here somewhere, that this hacks around .. the table_name as being passed to HUD_create is cleaned,
|
||||||
# but the table.name as being passed here is not cleaned. I don't know why. -eric
|
# but the table.name as being passed here is not cleaned. I don't know why. -eric
|
||||||
if tablename in hud_dict and hud_dict[tablename].deleted:
|
if tablename in self.hud_dict and self.hud_dict[tablename].deleted:
|
||||||
eb.remove(hud_dict[tablename].tablehudlabel)
|
self.vb.remove(self.hud_dict[tablename].tablehudlabel)
|
||||||
del hud_dict[tablename]
|
del self.hud_dict[tablename]
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def read_stdin(): # This is the thread function
|
def read_stdin(self): # This is the thread function
|
||||||
global hud_dict, eb
|
"""Do all the non-gui heavy lifting for the HUD program."""
|
||||||
|
|
||||||
db_connection = Database.Database(config, db_name, 'temp')
|
# This db connection is for the read_stdin thread only. It should not
|
||||||
|
# be passed to HUDs for use in the gui thread. HUD objects should not
|
||||||
|
# need their own access to the database, but should open their own
|
||||||
|
# if it is required.
|
||||||
|
self.db_connection = Database.Database(self.config, self.db_name, 'temp')
|
||||||
tourny_finder = re.compile('(\d+) (\d+)')
|
tourny_finder = re.compile('(\d+) (\d+)')
|
||||||
|
|
||||||
while True: # wait for a new hand number on stdin
|
while True: # wait for a new hand number on stdin
|
||||||
new_hand_id = sys.stdin.readline()
|
new_hand_id = sys.stdin.readline()
|
||||||
new_hand_id = string.rstrip(new_hand_id)
|
new_hand_id = string.rstrip(new_hand_id)
|
||||||
if new_hand_id == "": # blank line means quit
|
if new_hand_id == "": # blank line means quit
|
||||||
destroy()
|
self.destroy()
|
||||||
break # this thread is not always killed immediately with gtk.main_quit()
|
break # this thread is not always killed immediately with gtk.main_quit()
|
||||||
|
|
||||||
# get basic info about the new hand from the db
|
# get basic info about the new hand from the db
|
||||||
(table_name, max, poker_game) = db_connection.get_table_name(new_hand_id)
|
# if there is a db error, complain, skip hand, and proceed
|
||||||
|
try:
|
||||||
|
(table_name, max, poker_game) = self.db_connection.get_table_name(new_hand_id)
|
||||||
|
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id)
|
||||||
|
except:
|
||||||
|
print "skipping ", new_hand_id
|
||||||
|
sys.stderr.write("Database error in hand %d. Skipping.\n" % int(new_hand_id))
|
||||||
|
continue
|
||||||
|
|
||||||
# find out if this hand is from a tournament
|
# find out if this hand is from a tournament
|
||||||
is_tournament = False
|
|
||||||
(tour_number, tab_number) = (0, 0)
|
|
||||||
mat_obj = tourny_finder.search(table_name)
|
mat_obj = tourny_finder.search(table_name)
|
||||||
if mat_obj:
|
if mat_obj:
|
||||||
is_tournament = True
|
is_tournament = True
|
||||||
(tour_number, tab_number) = mat_obj.group(1, 2)
|
(tour_number, tab_number) = mat_obj.group(1, 2)
|
||||||
|
temp_key = tour_number
|
||||||
|
else:
|
||||||
|
is_tournament = False
|
||||||
|
(tour_number, tab_number) = (0, 0)
|
||||||
|
temp_key = table_name
|
||||||
|
|
||||||
stat_dict = db_connection.get_stats_from_hand(new_hand_id)
|
# Update an existing HUD
|
||||||
|
if temp_key in self.hud_dict:
|
||||||
|
for aw in self.hud_dict[temp_key].aux_windows:
|
||||||
|
aw.update_data(new_hand_id, self.db_connection)
|
||||||
|
self.update_HUD(new_hand_id, temp_key, self.config, stat_dict)
|
||||||
|
|
||||||
# if a hud for this CASH table exists, just update it
|
# Or create a new HUD
|
||||||
if table_name in hud_dict:
|
|
||||||
# update the data for the aux_windows
|
|
||||||
for aw in hud_dict[table_name].aux_windows:
|
|
||||||
aw.update_data(new_hand_id, db_connection)
|
|
||||||
update_HUD(new_hand_id, table_name, config, stat_dict)
|
|
||||||
|
|
||||||
# if a hud for this TOURNAMENT table exists, just update it
|
|
||||||
elif tour_number in hud_dict:
|
|
||||||
update_HUD(new_hand_id, tour_number, config, stat_dict)
|
|
||||||
|
|
||||||
# otherwise create a new hud
|
|
||||||
else:
|
else:
|
||||||
if is_tournament:
|
if is_tournament:
|
||||||
tablewindow = Tables.discover_tournament_table(config, tour_number, tab_number)
|
tablewindow = Tables.discover_tournament_table(self.config, tour_number, tab_number)
|
||||||
|
else:
|
||||||
|
tablewindow = Tables.discover_table_by_name(self.config, table_name)
|
||||||
|
|
||||||
if tablewindow == None:
|
if tablewindow == None:
|
||||||
sys.stderr.write("tournament %s, table %s not found\n" % (tour_number, tab_number))
|
if is_tournament:
|
||||||
|
table_name = tour_number + " " + tab_number
|
||||||
|
sys.stderr.write("table name "+table_name+" not found, skipping.\n")
|
||||||
else:
|
else:
|
||||||
create_HUD(new_hand_id, tablewindow, db_name, tour_number, max, poker_game, db_connection, config, stat_dict)
|
self.create_HUD(new_hand_id, tablewindow, temp_key, max, poker_game, is_tournament, stat_dict)
|
||||||
else:
|
|
||||||
tablewindow = Tables.discover_table_by_name(config, table_name)
|
|
||||||
if tablewindow == None:
|
|
||||||
sys.stderr.write("table name "+table_name+" not found\n")
|
|
||||||
else:
|
|
||||||
create_HUD(new_hand_id, tablewindow, db_name, table_name, max, poker_game, db_connection, config, stat_dict)
|
|
||||||
|
|
||||||
if __name__== "__main__":
|
if __name__== "__main__":
|
||||||
sys.stderr.write("HUD_main starting\n")
|
sys.stderr.write("HUD_main starting\n")
|
||||||
|
|
||||||
|
# database name can be passed on command line
|
||||||
try:
|
try:
|
||||||
db_name = sys.argv[1]
|
db_name = sys.argv[1]
|
||||||
except:
|
except:
|
||||||
db_name = 'fpdb'
|
db_name = 'fpdb'
|
||||||
sys.stderr.write("Using db name = %s\n" % (db_name))
|
sys.stderr.write("Using db name = %s\n" % (db_name))
|
||||||
|
|
||||||
config = Configuration.Config()
|
# start the HUD_main object
|
||||||
|
hm = HUD_main(db_name = db_name)
|
||||||
gobject.threads_init() # this is required
|
|
||||||
thread.start_new_thread(read_stdin, ()) # starts the thread
|
|
||||||
|
|
||||||
main_window = gtk.Window()
|
|
||||||
main_window.connect("destroy", destroy)
|
|
||||||
eb = gtk.VBox()
|
|
||||||
label = gtk.Label('Closing this window will exit from the HUD.')
|
|
||||||
eb.add(label)
|
|
||||||
main_window.add(eb)
|
|
||||||
|
|
||||||
main_window.set_title("HUD Main Window")
|
|
||||||
main_window.show_all()
|
|
||||||
|
|
||||||
|
# start the event loop
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Hand:
|
||||||
if gametype[1] == "hold" or self.gametype[1] == "omaha":
|
if gametype[1] == "hold" or self.gametype[1] == "omaha":
|
||||||
self.streetList = ['PREFLOP','FLOP','TURN','RIVER'] # a list of the observed street names in order
|
self.streetList = ['PREFLOP','FLOP','TURN','RIVER'] # a list of the observed street names in order
|
||||||
elif self.gametype[1] == "razz" or self.gametype[1] == "stud" or self.gametype[1] == "stud8":
|
elif self.gametype[1] == "razz" or self.gametype[1] == "stud" or self.gametype[1] == "stud8":
|
||||||
self.streetList = ['ANTES','THIRD','FORTH','FIFTH','SIXTH','SEVENTH'] # a list of the observed street names in order
|
self.streetList = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH'] # a list of the observed street names in order
|
||||||
|
|
||||||
self.handid = 0
|
self.handid = 0
|
||||||
self.sb = gametype[3]
|
self.sb = gametype[3]
|
||||||
|
|
|
@ -136,14 +136,13 @@ class HandHistoryConverter:
|
||||||
self.players = playersThisHand
|
self.players = playersThisHand
|
||||||
self.compile_player_regexs()
|
self.compile_player_regexs()
|
||||||
|
|
||||||
|
self.markStreets(hand)
|
||||||
# Different calls if stud or holdem like
|
# Different calls if stud or holdem like
|
||||||
if self.gametype[1] == "hold" or self.gametype[1] == "omaha":
|
if self.gametype[1] == "hold" or self.gametype[1] == "omaha":
|
||||||
self.markStreets(hand)
|
|
||||||
self.readBlinds(hand)
|
self.readBlinds(hand)
|
||||||
self.readButton(hand)
|
self.readButton(hand)
|
||||||
self.readHeroCards(hand) # want to generalise to draw games
|
self.readHeroCards(hand) # want to generalise to draw games
|
||||||
elif self.gametype[1] == "razz" or self.gametype[1] == "stud" or self.gametype[1] == "stud8":
|
elif self.gametype[1] == "razz" or self.gametype[1] == "stud" or self.gametype[1] == "stud8":
|
||||||
self.markStreets(hand) # <--- Different streets
|
|
||||||
self.readAntes(hand)
|
self.readAntes(hand)
|
||||||
self.readBringIn(hand)
|
self.readBringIn(hand)
|
||||||
|
|
||||||
|
@ -151,6 +150,7 @@ class HandHistoryConverter:
|
||||||
|
|
||||||
# Read actions in street order
|
# Read actions in street order
|
||||||
for street in hand.streetList: # go through them in order
|
for street in hand.streetList: # go through them in order
|
||||||
|
print "DEBUG: ", street
|
||||||
if hand.streets.group(street) is not None:
|
if hand.streets.group(street) is not None:
|
||||||
if self.gametype[1] == "hold" or self.gametype[1] == "omaha":
|
if self.gametype[1] == "hold" or self.gametype[1] == "omaha":
|
||||||
self.readCommunityCards(hand, street) # read community cards
|
self.readCommunityCards(hand, street) # read community cards
|
||||||
|
@ -223,6 +223,7 @@ class HandHistoryConverter:
|
||||||
def readBringIn(self, hand): abstract
|
def readBringIn(self, hand): abstract
|
||||||
def readButton(self, hand): abstract
|
def readButton(self, hand): abstract
|
||||||
def readHeroCards(self, hand): abstract
|
def readHeroCards(self, hand): abstract
|
||||||
|
def readPlayerCards(self, hand, street): abstract
|
||||||
def readAction(self, hand, street): abstract
|
def readAction(self, hand, street): abstract
|
||||||
def readCollectPot(self, hand): abstract
|
def readCollectPot(self, hand): abstract
|
||||||
def readShownCards(self, hand): abstract
|
def readShownCards(self, hand): abstract
|
||||||
|
|
|
@ -47,7 +47,8 @@ import HUD_main
|
||||||
|
|
||||||
class Hud:
|
class Hud:
|
||||||
|
|
||||||
def __init__(self, table, max, poker_game, config, db_connection):
|
def __init__(self, parent, table, max, poker_game, config, db_connection):
|
||||||
|
self.parent = parent
|
||||||
self.table = table
|
self.table = table
|
||||||
self.config = config
|
self.config = config
|
||||||
self.poker_game = poker_game
|
self.poker_game = poker_game
|
||||||
|
@ -175,7 +176,7 @@ class Hud:
|
||||||
self.deleted = True
|
self.deleted = True
|
||||||
self.main_window.disconnect(self.main_window.destroyhandler) # so we don't potentially infiniteloop in here, right
|
self.main_window.disconnect(self.main_window.destroyhandler) # so we don't potentially infiniteloop in here, right
|
||||||
self.main_window.destroy()
|
self.main_window.destroy()
|
||||||
HUD_main.HUD_removed(self.table.name)
|
self.parent.HUD_removed(self.table.name)
|
||||||
|
|
||||||
def kill_hud_menu(self, *args):
|
def kill_hud_menu(self, *args):
|
||||||
self.main_window.destroy()
|
self.main_window.destroy()
|
||||||
|
@ -200,31 +201,43 @@ class Hud:
|
||||||
self.config.save()
|
self.config.save()
|
||||||
|
|
||||||
def adj_seats(self, hand, config):
|
def adj_seats(self, hand, config):
|
||||||
|
|
||||||
adj = range(0, self.max + 1) # default seat adjustments = no adjustment
|
adj = range(0, self.max + 1) # default seat adjustments = no adjustment
|
||||||
# does the user have a fav_seat?
|
# does the user have a fav_seat?
|
||||||
try:
|
try:
|
||||||
|
sys.stderr.write("site = %s, max = %d, fav seat = %d\n" % (self.table.site, self.max, config.supported_sites[self.table.site].layout[self.max].fav_seat))
|
||||||
if int(config.supported_sites[self.table.site].layout[self.max].fav_seat) > 0:
|
if int(config.supported_sites[self.table.site].layout[self.max].fav_seat) > 0:
|
||||||
fav_seat = config.supported_sites[self.table.site].layout[self.max].fav_seat
|
fav_seat = config.supported_sites[self.table.site].layout[self.max].fav_seat
|
||||||
# db_connection = Database.Database(config, self.db_name, 'temp')
|
sys.stderr.write("found fav seat = %d\n" % fav_seat)
|
||||||
actual_seat = self.db_connection.get_actual_seat(hand, config.supported_sites[self.table.site].screen_name)
|
# actual_seat = self.db_connection.get_actual_seat(hand, config.supported_sites[self.table.site].screen_name)
|
||||||
# db_connection.close_connection()
|
actual_seat = self.get_actual_seat(config.supported_sites[self.table.site].screen_name)
|
||||||
|
sys.stderr.write("found actual seat = %d\n" % actual_seat)
|
||||||
for i in range(0, self.max + 1):
|
for i in range(0, self.max + 1):
|
||||||
j = actual_seat + i
|
j = actual_seat + i
|
||||||
if j > self.max: j = j - self.max
|
if j > self.max: j = j - self.max
|
||||||
adj[j] = fav_seat + i
|
adj[j] = fav_seat + i
|
||||||
if adj[j] > self.max: adj[j] = adj[j] - self.max
|
if adj[j] > self.max: adj[j] = adj[j] - self.max
|
||||||
except:
|
except Exception, inst:
|
||||||
pass
|
sys.stderr.write("exception in adj!!!\n\n")
|
||||||
|
sys.stderr.write("error is %s" % inst) # __str__ allows args to printed directly
|
||||||
return adj
|
return adj
|
||||||
|
|
||||||
def create(self, hand, config):
|
def get_actual_seat(self, name):
|
||||||
|
for key in self.stat_dict.keys():
|
||||||
|
if self.stat_dict[key]['screen_name'] == name:
|
||||||
|
return self.stat_dict[key]['seat']
|
||||||
|
sys.stderr.write("Error finding actual seat.\n")
|
||||||
|
|
||||||
|
def create(self, hand, config, stat_dict):
|
||||||
# update this hud, to the stats and players as of "hand"
|
# update this hud, to the stats and players as of "hand"
|
||||||
# hand is the hand id of the most recent hand played at this table
|
# hand is the hand id of the most recent hand played at this table
|
||||||
#
|
#
|
||||||
# this method also manages the creating and destruction of stat
|
# this method also manages the creating and destruction of stat
|
||||||
# windows via calls to the Stat_Window class
|
# windows via calls to the Stat_Window class
|
||||||
|
self.stat_dict = stat_dict
|
||||||
|
sys.stderr.write("------------------------------------------------------------\nCreating hud from hand %s\n" % hand)
|
||||||
adj = self.adj_seats(hand, config)
|
adj = self.adj_seats(hand, config)
|
||||||
|
sys.stderr.write("adj = %s\n" % adj)
|
||||||
loc = self.config.get_locations(self.table.site, self.max)
|
loc = self.config.get_locations(self.table.site, self.max)
|
||||||
|
|
||||||
# create the stat windows
|
# create the stat windows
|
||||||
|
@ -233,6 +246,7 @@ class Hud:
|
||||||
if i in self.stat_windows:
|
if i in self.stat_windows:
|
||||||
self.stat_windows[i].relocate(x, y)
|
self.stat_windows[i].relocate(x, y)
|
||||||
else:
|
else:
|
||||||
|
sys.stderr.write("actual seat = %d, x = %d, y= %d\n" % (i, x, y))
|
||||||
self.stat_windows[i] = Stat_Window(game = config.supported_games[self.poker_game],
|
self.stat_windows[i] = Stat_Window(game = config.supported_games[self.poker_game],
|
||||||
parent = self,
|
parent = self,
|
||||||
table = self.table,
|
table = self.table,
|
||||||
|
@ -291,9 +305,6 @@ class Hud:
|
||||||
tip = stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \
|
tip = stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \
|
||||||
number[3] + ", " + number[4]
|
number[3] + ", " + number[4]
|
||||||
Stats.do_tip(self.stat_windows[stat_dict[s]['seat']].e_box[r][c], tip)
|
Stats.do_tip(self.stat_windows[stat_dict[s]['seat']].e_box[r][c], tip)
|
||||||
# for m in self.aux_windows:
|
|
||||||
# m.update_data(hand)
|
|
||||||
# m.update_gui(hand)
|
|
||||||
|
|
||||||
def topify_window(self, window):
|
def topify_window(self, window):
|
||||||
"""Set the specified gtk window to stayontop in MS Windows."""
|
"""Set the specified gtk window to stayontop in MS Windows."""
|
||||||
|
|
|
@ -173,6 +173,8 @@ class Sql:
|
||||||
|
|
||||||
self.query['get_stats_from_hand'] = """
|
self.query['get_stats_from_hand'] = """
|
||||||
SELECT HudCache.playerId AS player_id,
|
SELECT HudCache.playerId AS player_id,
|
||||||
|
seatNo AS seat,
|
||||||
|
name AS screen_name,
|
||||||
sum(HDs) AS n,
|
sum(HDs) AS n,
|
||||||
sum(street0VPI) AS vpip,
|
sum(street0VPI) AS vpip,
|
||||||
sum(street0Aggr) AS pfr,
|
sum(street0Aggr) AS pfr,
|
||||||
|
@ -233,6 +235,7 @@ class Sql:
|
||||||
INNER JOIN HandsPlayers ON (HandsPlayers.handId = %s)
|
INNER JOIN HandsPlayers ON (HandsPlayers.handId = %s)
|
||||||
INNER JOIN HudCache ON ( HudCache.PlayerId = HandsPlayers.PlayerId+0
|
INNER JOIN HudCache ON ( HudCache.PlayerId = HandsPlayers.PlayerId+0
|
||||||
AND HudCache.gametypeId+0 = Hands.gametypeId+0)
|
AND HudCache.gametypeId+0 = Hands.gametypeId+0)
|
||||||
|
INNER JOIN Players ON (Players.id = HandsPlayers.PlayerId+0)
|
||||||
WHERE Hands.id = %s
|
WHERE Hands.id = %s
|
||||||
GROUP BY HudCache.PlayerId
|
GROUP BY HudCache.PlayerId
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -360,7 +360,7 @@ class Importer:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
startpos=endpos
|
startpos=endpos
|
||||||
ttime = time() - starttime
|
ttime = time() - starttime
|
||||||
print "Total stored:", stored, "duplicates:", duplicates, "partial:", partial, "errors:", errors, " time:", ttime
|
print "\rTotal stored:", stored, "duplicates:", duplicates, "partial:", partial, "errors:", errors, " time:", ttime
|
||||||
|
|
||||||
if stored==0:
|
if stored==0:
|
||||||
if duplicates>0:
|
if duplicates>0:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user