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

This commit is contained in:
Worros 2008-11-16 11:49:37 +09:00
commit dfbcf8efc7
4 changed files with 58 additions and 28 deletions

View File

@ -142,6 +142,16 @@ class Database:
cards[s_dict['seat_number']] = s_dict cards[s_dict['seat_number']] = s_dict
return (cards) return (cards)
def get_action_from_hand(self, hand_no):
action = [ [], [], [], [], [] ]
c = self.connection.cursor()
c.execute(self.sql.query['get_action_from_hand'], (hand_no))
for row in c.fetchall():
street = row[0]
act = row[1:]
action[street].append(act)
return action
def get_stats_from_hand(self, hand, aggregate = False): def get_stats_from_hand(self, hand, aggregate = False):
c = self.connection.cursor() c = self.connection.cursor()

View File

@ -132,13 +132,12 @@ class Hud:
self.stat_windows[w].window.move(self.stat_windows[w].x, self.stat_windows[w].window.move(self.stat_windows[w].x,
self.stat_windows[w].y) self.stat_windows[w].y)
def save_layout(self, *args): def save_layout(self, *args):
new_layout = [] new_layout = [(0, 0)] * self.max
# todo: have the hud track the poker table's window position regularly, don't forget to update table.x and table.y. # todo: have the hud track the poker table's window position regularly, don't forget to update table.x and table.y.
for sw in self.stat_windows: for sw in self.stat_windows:
loc = self.stat_windows[sw].window.get_position() loc = self.stat_windows[sw].window.get_position()
new_loc = (loc[0] - self.table.x, loc[1] - self.table.y) new_loc = (loc[0] - self.table.x, loc[1] - self.table.y)
new_layout.append(new_loc) new_layout[self.stat_windows[sw].adj - 1] = new_loc
# print new_layout
self.config.edit_layout(self.table.site, self.max, locations = new_layout) self.config.edit_layout(self.table.site, self.max, locations = new_layout)
self.config.save() self.config.save()
@ -169,6 +168,7 @@ class Hud:
adj = self.adj_seats(hand, config) adj = self.adj_seats(hand, config)
loc = self.config.get_locations(self.table.site, self.max) loc = self.config.get_locations(self.table.site, self.max)
print "adj = ", adj
# create the stat windows # create the stat windows
for i in range(1, self.max + 1): for i in range(1, self.max + 1):
@ -182,6 +182,7 @@ class Hud:
x = x, x = x,
y = y, y = y,
seat = i, seat = i,
adj = adj[i],
player_id = 'fake', player_id = 'fake',
font = self.font) font = self.font)
@ -313,10 +314,12 @@ class Stat_Window:
self.y = y + self.table.y self.y = y + self.table.y
self.window.move(self.x, self.y) self.window.move(self.x, self.y)
def __init__(self, parent, game, table, seat, x, y, player_id, font): def __init__(self, parent, game, table, seat, adj, x, y, player_id, font):
self.parent = parent # Hud object that this stat window belongs to self.parent = parent # Hud object that this stat window belongs to
self.game = game # Configuration object for the curren self.game = game # Configuration object for the curren
self.table = table # Table object where this is going self.table = table # Table object where this is going
self.seat = seat # seat number of his player
self.adj = adj # the adjusted seat number for this player
self.x = x + table.x # table.x and y are the location of the table self.x = x + table.x # table.x and y are the location of the table
self.y = y + table.y # x and y are the location relative to table.x & y self.y = y + table.y # x and y are the location relative to table.x & y
self.player_id = player_id # looks like this isn't used ;) self.player_id = player_id # looks like this isn't used ;)

View File

@ -159,37 +159,56 @@ class MuckedCards:
self.parent.add(self.grid) self.parent.add(self.grid)
def translate_cards(self, old_cards): def translate_cards(self, old_cards):
pass ranks = ('', '', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A')
for c in old_cards.keys():
for i in range(1, 8):
rank = 'card' + str(i) + 'Value'
suit = 'card' + str(i) + 'Suit'
key = 'hole_card_' + str(i)
if old_cards[c][rank] == 0:
old_cards[c][key] = 'xx'
else:
old_cards[c][key] = ranks[old_cards[c][rank]] + old_cards[c][suit]
return old_cards
def update(self, new_hand_id): def update(self, new_hand_id):
cards = self.db_connection.get_cards(new_hand_id) cards = self.db_connection.get_cards(new_hand_id)
self.clear() self.clear()
cards = self.translate_cards(cards) cards = self.translate_cards(cards)
for c in cards.keys(): for c in cards.keys():
self.grid_contents[(1, cards[c]['seat_number'] - 1)].set_text(cards[c]['screen_name']) self.grid_contents[(1, cards[c]['seat_number'] - 1)].set_text(cards[c]['screen_name'])
for i in ((0, 'hole_card_1'), (1, 'hole_card_2'), (2, 'hole_card_3'), (3, 'hole_card_4'), for i in ((0, 'hole_card_1'), (1, 'hole_card_2'), (2, 'hole_card_3'), (3, 'hole_card_4'),
(4, 'hole_card_5'), (5, 'hole_card_6'), (6, 'hole_card_7')): (4, 'hole_card_5'), (5, 'hole_card_6'), (6, 'hole_card_7')):
if not cards[c][i[1]] == "": if not cards[c][i[1]] == "xx":
self.seen_cards[(i[0], cards[c]['seat_number'] - 1)]. \ self.seen_cards[(i[0], cards[c]['seat_number'] - 1)]. \
set_from_pixbuf(self.card_images[self.split_cards(cards[c][i[1]])]) set_from_pixbuf(self.card_images[self.split_cards(cards[c][i[1]])])
xml_text = self.db_connection.get_xml(new_hand_id)
hh = HandHistory.HandHistory(xml_text, ('BETTING'))
# action in tool tips for 3rd street cards tips = []
tip = "%s" % hh.BETTING.rounds[0] action = self.db_connection.get_action_from_hand(new_hand_id)
for street in action:
temp = ''
for act in street:
temp = temp + act[0] + " " + act[1] + "s "
if act[2] > 0:
if act[2]%100 > 0:
temp = temp + "%4.2f\n" % (float(act[2])/100)
else:
temp = temp + "%d\n" % (act[2]/100)
else:
temp = temp + "\n"
tips.append(temp)
## action in tool tips for 3rd street cards
for c in (0, 1, 2): for c in (0, 1, 2):
for r in range(0, self.rows): for r in range(0, self.rows):
self.eb[(c, r)].set_tooltip_text(tip) self.eb[(c, r)].set_tooltip_text(tips[0])
# action in tools tips for later streets # action in tools tips for later streets
round_to_col = (0, 3, 4, 5, 6) round_to_col = (0, 3, 4, 5, 6)
for round in range(1, len(hh.BETTING.rounds)): for round in range(1, len(tips)):
tip = "%s" % hh.BETTING.rounds[round]
for r in range(0, self.rows): for r in range(0, self.rows):
self.eb[(round_to_col[round], r)].set_tooltip_text(tip) self.eb[(round_to_col[round], r)].set_tooltip_text(tips[round])
def split_cards(self, card): def split_cards(self, card):
return (card[0], card[1].upper()) return (card[0], card[1].upper())
@ -230,7 +249,6 @@ if __name__== "__main__":
config = Configuration.Config() config = Configuration.Config()
db_connection = Database.Database(config, 'fpdb', '') db_connection = Database.Database(config, 'fpdb', '')
main_window = gtk.Window() main_window = gtk.Window()
main_window.set_keep_above(True) main_window.set_keep_above(True)
main_window.connect("destroy", destroy) main_window.connect("destroy", destroy)
@ -239,5 +257,4 @@ if __name__== "__main__":
main_window.show_all() main_window.show_all()
s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, process_new_hand) s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, process_new_hand)
gtk.main() gtk.main()

View File

@ -351,15 +351,15 @@ class Sql:
order by seatNo order by seatNo
""" """
# self.query['get_hand_info'] = """ self.query['get_action_from_hand'] = """
# SELECT SELECT street, Players.name, HandsActions.action, HandsActions.amount, actionno
# game_id, FROM Players, HandsActions, HandsPlayers
# CONCAT(hole_card_1, hole_card_2, hole_card_3, hole_card_4, hole_card_5, hole_card_6, hole_card_7) AS hand, WHERE HandsActions.action != 'blind'
# total_won-total_bet AS net AND HandsPlayers.handid = %s
# FROM game_players AND HandsPlayers.playerid = Players.id
# WHERE game_id = %s AND player_id = 3 AND HandsActions.handPlayerId = HandsPlayers.id
# """ ORDER BY street, actionno
"""
if __name__== "__main__": if __name__== "__main__":
# just print the default queries and exit # just print the default queries and exit
s = Sql(game = 'razz', type = 'ptracks') s = Sql(game = 'razz', type = 'ptracks')