Merge branch 'master' of git://git.assembla.com/free_poker_tools.git

Conflicts:
	pyfpdb/Database.py
This commit is contained in:
eblade 2009-03-10 19:31:42 -04:00
commit 388525ed30
4 changed files with 62 additions and 16 deletions

13
pyfpdb/Database.py Executable file → Normal file
View File

@ -129,6 +129,19 @@ class Database:
cards[s_dict['seat_number']] = (self.convert_cards(s_dict)) cards[s_dict['seat_number']] = (self.convert_cards(s_dict))
return cards return cards
def get_common_cards(self, hand):
"""Get and return the community cards for the specified hand."""
cards = {}
c = self.connection.cursor()
c.execute(self.sql.query['get_common_cards'], hand)
colnames = [desc[0] for desc in c.description]
for row in c.fetchall():
s_dict = {}
for name, val in zip(colnames, row):
s_dict[name] = val
cards['common'] = (self.convert_cards(s_dict))
return cards
def convert_cards(self, d): def convert_cards(self, d):
ranks = ('', '', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A') ranks = ('', '', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
cards = "" cards = ""

View File

@ -107,6 +107,7 @@ class GuiGraphViewer (threading.Thread):
self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
self.graphBox.add(self.canvas) self.graphBox.add(self.canvas)
self.canvas.show() self.canvas.show()
self.exportButton.set_sensitive(True)
#end of def showClicked #end of def showClicked
def getRingProfitGraph(self, names, sites): def getRingProfitGraph(self, names, sites):
@ -361,6 +362,7 @@ class GuiGraphViewer (threading.Thread):
self.exportButton=gtk.Button("Export to File") self.exportButton=gtk.Button("Export to File")
self.exportButton.connect("clicked", self.exportGraph, "show clicked") self.exportButton.connect("clicked", self.exportGraph, "show clicked")
self.exportButton.set_sensitive(False)
self.exportButton.show() self.exportButton.show()
self.leftPanelBox.add(playerFrame) self.leftPanelBox.add(playerFrame)

View File

@ -320,22 +320,22 @@ class Flop_Mucked(Aux_Window):
adj = self.hud.adj_seats(0, self.config) adj = self.hud.adj_seats(0, self.config)
loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max)) loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max))
# make a scratch pixbuf 7 cards wide for creating our images self.m_windows = {} # windows to put the card images in
self.scratch = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8,
7* int(self.params['card_wd']), int(self.params['card_ht']))
# create the stat windows
self.m_windows = {} # windows to put the card images
self.eb = {} # event boxes so we can interact with the mucked cards self.eb = {} # event boxes so we can interact with the mucked cards
self.seen_cards = {} # pixbufs to stash the cards in self.seen_cards = {} # image objects to stash the cards in
for i in range(1, self.hud.max + 1): for i in (range(1, self.hud.max + 1) + ['common']):
(x, y) = loc[adj[i]] if i == 'common':
(x, y) = self.params['layout'][self.hud.max].common
else:
(x, y) = loc[adj[i]]
self.m_windows[i] = gtk.Window() self.m_windows[i] = gtk.Window()
self.m_windows[i].set_decorated(0) self.m_windows[i].set_decorated(False)
self.m_windows[i].set_property("skip-taskbar-hint", True) self.m_windows[i].set_property("skip-taskbar-hint", True)
self.m_windows[i].set_transient_for(self.hud.main_window) self.m_windows[i].set_transient_for(self.hud.main_window)
self.m_windows[i].set_focus_on_map(False)
self.eb[i] = gtk.EventBox() self.eb[i] = gtk.EventBox()
self.eb[i].connect("button_press_event", self.button_press_cb)
self.m_windows[i].add(self.eb[i]) self.m_windows[i].add(self.eb[i])
self.seen_cards[i] = gtk.image_new_from_pixbuf(self.card_images[('B', 'H')]) self.seen_cards[i] = gtk.image_new_from_pixbuf(self.card_images[('B', 'H')])
self.eb[i].add(self.seen_cards[i]) self.eb[i].add(self.seen_cards[i])
@ -345,12 +345,17 @@ class Flop_Mucked(Aux_Window):
self.m_windows[i].hide() self.m_windows[i].hide()
def update_data(self, new_hand_id, db_connection): def update_data(self, new_hand_id, db_connection):
pass cards = db_connection.get_common_cards(new_hand_id)
self.hud.cards['common'] = cards['common']
def update_gui(self, new_hand_id): def update_gui(self, new_hand_id):
"""Prepare and show the mucked cards.""" """Prepare and show the mucked cards."""
pos = {}
for i, w in self.m_windows.iteritems():
pos[i] = w.get_position() # I hate this. I don't know why I have to save position and then move back
self.hide_mucked_cards()
displayed_cards = False
for (i, cards) in self.hud.cards.iteritems(): for (i, cards) in self.hud.cards.iteritems():
pos = self.m_windows[i].get_position() # need this to reposition later
if self.has_cards(cards): if self.has_cards(cards):
# scratch is a working pixbuf, used to assemble the image # scratch is a working pixbuf, used to assemble the image
scratch = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, scratch = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8,
@ -364,16 +369,19 @@ class Flop_Mucked(Aux_Window):
scratch, x, 0) scratch, x, 0)
x = x + int(self.params['card_wd']) x = x + int(self.params['card_wd'])
self.seen_cards[i].set_from_pixbuf(scratch) self.seen_cards[i].set_from_pixbuf(scratch)
self.m_windows[i].move(pos[0], pos[1]) # I don't know why I need this # self.m_windows[i].show_all()
self.m_windows[i].show_all() self.m_windows[i].move(pos[i][0], pos[i][1]) # here is where I move back
gobject.timeout_add(int(1000*float(self.params['timeout'])), self.hide_mucked_cards) self.m_windows[i].present()
displayed_cards = True
if displayed_cards and float(self.params['timeout']) > 0:
gobject.timeout_add(int(1000*float(self.params['timeout'])), self.hide_mucked_cards)
def destroy(self): def destroy(self):
"""Destroy all of the mucked windows.""" """Destroy all of the mucked windows."""
for w in self.m_windows.values(): for w in self.m_windows.values():
w.destroy() w.destroy()
def hide_mucked_cards(self): def hide_mucked_cards(self):
"""Hide the mucked card windows.""" """Hide the mucked card windows."""
# this is the callback from the timeout # this is the callback from the timeout
@ -381,6 +389,18 @@ class Flop_Mucked(Aux_Window):
w.hide() w.hide()
return False # this tells the system to NOT run this timeout again return False # this tells the system to NOT run this timeout again
def button_press_cb(self, widget, event, *args):
"""Handle button clicks in the event boxes."""
if event.button == 3: # right button event
pass
elif event.button == 2: # middle button event
self.hide_mucked_cards()
elif event.button == 1: # left button event
window = widget.get_parent()
window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)
if __name__== "__main__": if __name__== "__main__":
def destroy(*args): # call back for terminating the main eventloop def destroy(*args): # call back for terminating the main eventloop

View File

@ -361,6 +361,17 @@ class Sql:
order by seatNo order by seatNo
""" """
self.query['get_common_cards'] = """
select
card1Value, card1Suit,
card2Value, card2Suit,
card3Value, card3Suit,
card4Value, card4Suit,
card5Value, card5Suit
from BoardCards
where handId = %s
"""
self.query['get_action_from_hand'] = """ self.query['get_action_from_hand'] = """
SELECT street, Players.name, HandsActions.action, HandsActions.amount, actionno SELECT street, Players.name, HandsActions.action, HandsActions.amount, actionno
FROM Players, HandsActions, HandsPlayers FROM Players, HandsActions, HandsPlayers