From 4ada389f869e1bc8e4cfd24e413013c47bc407e3 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Thu, 21 Jan 2010 21:14:49 +0100 Subject: [PATCH 1/4] Changed the card positions and mucked card positions to relative positions. --- pyfpdb/Hud.py | 20 +++++++++++++++----- pyfpdb/Mucked.py | 21 +++++++++++++-------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 1a27b682..ada7b316 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -457,7 +457,9 @@ class Hud: # TODO: is stat_windows getting converted somewhere from a list to a dict, for no good reason? for i, w in enumerate(self.stat_windows.itervalues()): (x, y) = loc[adj[i+1]] - w.relocate(x, y) + px = int(x * self.table.width / 1000) + py = int(y * self.table.height / 1000) + w.relocate(px, py) # While we're at it, fix the positions of mucked cards too for aux in self.aux_windows: @@ -507,9 +509,11 @@ class Hud: def save_layout(self, *args): new_layout = [(0, 0)] * self.max + width = self.table.width + height = self.table.height for sw in self.stat_windows: - loc = self.stat_windows[sw].window.get_position() - new_loc = (loc[0] - self.table.x, loc[1] - self.table.y) + (x,y) = self.stat_windows[sw].window.get_position() + new_loc = (int((x - self.table.x)*1000/width), int((y - self.table.y)*1000/height)) new_layout[self.stat_windows[sw].adj - 1] = new_loc self.config.edit_layout(self.table.site, self.max, locations = new_layout) # ask each aux to save its layout back to the config object @@ -571,16 +575,22 @@ class Hud: loc = self.config.get_locations(self.table.site, 9) # create the stat windows +# get the width and height of the client window +# The x and Y positions are now made relative. + for i in xrange(1, self.max + 1): (x, y) = loc[adj[i]] + px = int(x * self.table.width / 1000) + py = int(y * self.table.height / 1000) if i in self.stat_windows: self.stat_windows[i].relocate(x, y) + self.stat_windows[i].relocate(px, py) else: self.stat_windows[i] = Stat_Window(game = config.supported_games[self.poker_game], parent = self, table = self.table, - x = x, - y = y, + x = px, + y = py, seat = i, adj = adj[i], player_id = 'fake', diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index dd424e63..d4c7d688 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -357,21 +357,24 @@ class Aux_Seats(Aux_Window): except AttributeError: return loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max)) + width = self.hud.table.width + height = self.hud.table.height + for i in (range(1, self.hud.max + 1) + ['common']): if i == 'common': (x, y) = self.params['layout'][self.hud.max].common else: (x, y) = loc[adj[i]] - self.positions[i] = self.card_positions(x, self.hud.table.x, y, self.hud.table.y) + self.positions[i] = self.card_positions((x * width) / 1000, self.hud.table.x, (y * height) /1000, self.hud.table.y) self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) - def create(self): self.adj = self.hud.adj_seats(0, self.config) # move adj_seats to aux and get rid of it in Hud.py loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max)) self.m_windows = {} # windows to put the card images in - + width = self.hud.table.width + height = self.hud.table.height for i in (range(1, self.hud.max + 1) + ['common']): if i == 'common': (x, y) = self.params['layout'][self.hud.max].common @@ -383,7 +386,7 @@ class Aux_Seats(Aux_Window): self.m_windows[i].set_transient_for(self.hud.main_window) self.m_windows[i].set_focus_on_map(False) self.m_windows[i].connect("configure_event", self.configure_event_cb, i) - self.positions[i] = self.card_positions(x, self.hud.table.x, y, self.hud.table.y) + self.positions[i] = self.card_positions((x * width) / 1000, self.hud.table.x, (y * height) /1000, self.hud.table.y) self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) if self.params.has_key('opacity'): self.m_windows[i].set_opacity(float(self.params['opacity'])) @@ -425,11 +428,13 @@ class Aux_Seats(Aux_Window): """Save new layout back to the aux element in the config file.""" new_locs = {} # print "adj =", self.adj + witdh = self.hud.table.width + height = self.hud.table.height for (i, pos) in self.positions.iteritems(): - if i != 'common': - new_locs[self.adj[int(i)]] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y) - else: - new_locs[i] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y) + if i != 'common': + new_locs[self.adj[int(i)]] = ((pos[0] - self.hud.table.x) * 1000 / witdh, (pos[1] - self.hud.table.y) * 1000 / height) + else: + new_locs[i] = ((pos[0] - self.hud.table.x) * 1000 / witdh, (pos[1] - self.hud.table.y) * 1000 / height) self.config.edit_aux_layout(self.params['name'], self.hud.max, locations = new_locs) def configure_event_cb(self, widget, event, i, *args): From fdc5a0a635f5ba31a257b830d6b06e023c6e5989 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Fri, 22 Jan 2010 15:38:33 +0100 Subject: [PATCH 2/4] Added close on double click for a stat window Just in case you don't have a mouse with middle button --- pyfpdb/Hud.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index ada7b316..ec2e4ac3 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -575,15 +575,14 @@ class Hud: loc = self.config.get_locations(self.table.site, 9) # create the stat windows -# get the width and height of the client window -# The x and Y positions are now made relative. + # get the width and height of the client window + # The x and Y positions are now made relative. for i in xrange(1, self.max + 1): (x, y) = loc[adj[i]] px = int(x * self.table.width / 1000) py = int(y * self.table.height / 1000) if i in self.stat_windows: - self.stat_windows[i].relocate(x, y) self.stat_windows[i].relocate(px, py) else: self.stat_windows[i] = Stat_Window(game = config.supported_games[self.poker_game], @@ -686,6 +685,9 @@ class Stat_Window: return True if event.button == 1: # left button event + if event.type == gtk.gdk._2BUTTON_PRESS: + self.window.hide() + return True # TODO: make position saving save sizes as well? if event.state & gtk.gdk.SHIFT_MASK: self.window.begin_resize_drag(gtk.gdk.WINDOW_EDGE_SOUTH_EAST, event.button, int(event.x_root), int(event.y_root), event.time) From 261daf600391617e66ea7201faa594d3f39c0a63 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Fri, 22 Jan 2010 18:36:21 +0100 Subject: [PATCH 3/4] game selector for graphs added. exception caught for games selector for player stats --- pyfpdb/GuiGraphViewer.py | 22 ++++++++++++++++++++-- pyfpdb/GuiPlayerStats.py | 13 ++++++++----- pyfpdb/SQL.py | 1 + 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py index 9daa940f..0b2d20cd 100644 --- a/pyfpdb/GuiGraphViewer.py +++ b/pyfpdb/GuiGraphViewer.py @@ -137,6 +137,8 @@ class GuiGraphViewer (threading.Thread): heroes = self.filters.getHeroes() siteids = self.filters.getSiteIds() limits = self.filters.getLimits() + games = self.filters.getGames() + for i in ('show', 'none'): if i in limits: limits.remove(i) @@ -171,7 +173,7 @@ class GuiGraphViewer (threading.Thread): #Get graph data from DB starttime = time() - (green, blue, red) = self.getRingProfitGraph(playerids, sitenos, limits) + (green, blue, red) = self.getRingProfitGraph(playerids, sitenos, limits, games) print "Graph generated in: %s" %(time() - starttime) self.ax.set_title("Profit graph for ring games") @@ -212,7 +214,7 @@ class GuiGraphViewer (threading.Thread): #end of def showClicked - def getRingProfitGraph(self, names, sites, limits): + def getRingProfitGraph(self, names, sites, limits, games): tmp = self.sql.query['getRingProfitAllHandsPlayerIdSite'] # print "DEBUG: getRingProfitGraph" start_date, end_date = self.filters.getDates() @@ -224,6 +226,22 @@ class GuiGraphViewer (threading.Thread): sitetest = str(tuple(sites)) #nametest = nametest.replace("L", "") + q = [] + for m in self.filters.display.items(): + if m[0] == 'Games' and m[1]: + for n in games: + if games[n]: + q.append(n) + if len(q) > 0: + gametest = str(tuple(q)) + gametest = gametest.replace("L", "") + gametest = gametest.replace(",)",")") + gametest = gametest.replace("u'","'") + gametest = "and gt.category in %s" % gametest + else: + gametest = "and gt.category IS NULL" + tmp = tmp.replace("", gametest) + lims = [int(x) for x in limits if x.isdigit()] potlims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'pl'] nolims = [int(x[0:-2]) for x in limits if len(x) > 2 and x[-2:] == 'nl'] diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index 1da08fbc..e842b301 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -474,11 +474,14 @@ class GuiPlayerStats (threading.Thread): for n in games: if games[n]: q.append(n) - gametest = str(tuple(q)) - gametest = gametest.replace("L", "") - gametest = gametest.replace(",)",")") - gametest = gametest.replace("u'","'") - gametest = "and gt.category in %s" % gametest + if len(q) > 0: + gametest = str(tuple(q)) + gametest = gametest.replace("L", "") + gametest = gametest.replace(",)",")") + gametest = gametest.replace("u'","'") + gametest = "and gt.category in %s" % gametest + else: + gametest = "and gt.category IS NULL" query = query.replace("", gametest) if seats: diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index c377c7b6..5913c624 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -2576,6 +2576,7 @@ class Sql: AND h.handStart > '' AND h.handStart < '' + AND hp.tourneysPlayersId IS NULL GROUP BY h.handStart, hp.handId, hp.sawShowdown, hp.totalProfit ORDER BY h.handStart""" From 3cd51ca99010d70010ae1e2b8fc11c9e78464165 Mon Sep 17 00:00:00 2001 From: Gerko de Roo Date: Fri, 22 Jan 2010 23:42:44 +0100 Subject: [PATCH 4/4] Added freeroll support for Pokerstars --- pyfpdb/PokerStarsToFpdb.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 09bd0390..03c70845 100755 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -46,9 +46,9 @@ class PokerStars(HandHistoryConverter): PokerStars\sGame\s\#(?P[0-9]+):\s+ (Tournament\s\# # open paren of tournament info (?P\d+),\s - (?P[%(LS)s\+\d\.]+ # here's how I plan to use LS - \s?(?P%(LEGAL_ISO)s)? - )\s)? # close paren of tournament info + # here's how I plan to use LS + (?P([%(LS)s\+\d\.]+\s?(?P%(LEGAL_ISO)s)?)|Freeroll)\s+)? + # close paren of tournament info (?PHORSE|8\-Game|HOSE)?\s?\(? (?PHold\'em|Razz|7\sCard\sStud|7\sCard\sStud\sHi/Lo|Omaha|Omaha\sHi/Lo|Badugi|Triple\sDraw\s2\-7\sLowball|5\sCard\sDraw)\s (?PNo\sLimit|Limit|Pot\sLimit)\)?,?\s @@ -205,9 +205,12 @@ class PokerStars(HandHistoryConverter): if key == 'TOURNO': hand.tourNo = info[key] if key == 'BUYIN': - #FIXME: The key looks like: '€0.82+€0.18 EUR' - # This should be parsed properly and used - hand.buyin = info[key] + if info[key] == 'Freeroll': + hand.buyin = '$0+$0' + else: + #FIXME: The key looks like: '€0.82+€0.18 EUR' + # This should be parsed properly and used + hand.buyin = info[key] if key == 'LEVEL': hand.level = info[key]