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
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):
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].y)
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.
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)
new_layout.append(new_loc)
# print new_layout
new_layout[self.stat_windows[sw].adj - 1] = new_loc
self.config.edit_layout(self.table.site, self.max, locations = new_layout)
self.config.save()
@ -169,6 +168,7 @@ class Hud:
adj = self.adj_seats(hand, config)
loc = self.config.get_locations(self.table.site, self.max)
print "adj = ", adj
# create the stat windows
for i in range(1, self.max + 1):
@ -182,6 +182,7 @@ class Hud:
x = x,
y = y,
seat = i,
adj = adj[i],
player_id = 'fake',
font = self.font)
@ -313,10 +314,12 @@ class Stat_Window:
self.y = y + self.table.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.game = game # Configuration object for the curren
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.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 ;)

View File

@ -159,37 +159,56 @@ class MuckedCards:
self.parent.add(self.grid)
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):
cards = self.db_connection.get_cards(new_hand_id)
self.clear()
cards = self.translate_cards(cards)
for c in cards.keys():
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'),
(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)]. \
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'))
tips = []
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
tip = "%s" % hh.BETTING.rounds[0]
## action in tool tips for 3rd street cards
for c in (0, 1, 2):
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
round_to_col = (0, 3, 4, 5, 6)
for round in range(1, len(hh.BETTING.rounds)):
tip = "%s" % hh.BETTING.rounds[round]
for round in range(1, len(tips)):
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):
return (card[0], card[1].upper())
@ -230,7 +249,6 @@ if __name__== "__main__":
config = Configuration.Config()
db_connection = Database.Database(config, 'fpdb', '')
main_window = gtk.Window()
main_window.set_keep_above(True)
main_window.connect("destroy", destroy)
@ -239,5 +257,4 @@ if __name__== "__main__":
main_window.show_all()
s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, process_new_hand)
gtk.main()

View File

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