From b35e6c55709804d5a9c54630c8eea15cd67ff1ff Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 12 Nov 2008 10:28:48 -0500 Subject: [PATCH 1/4] fix bug in saving layouts when fav_seat != 0 --- pyfpdb/Hud.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 9a5ea7f1..39f30eea 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -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 ;) From ca960cad96652bafee71656eee3c1b96b5691295 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 12 Nov 2008 22:45:09 -0500 Subject: [PATCH 2/4] Support for the mucked cards window. Still a bug in the card storing. --- pyfpdb/Database.py | 10 ++++++++++ pyfpdb/Mucked.py | 47 +++++++++++++++++++++++++++++++--------------- pyfpdb/SQL.py | 18 +++++++++--------- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index dbe36622..95abdd71 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -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() diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index 0af06c65..efb99e81 100644 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -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')) -# action in tool tips for 3rd street cards - tip = "%s" % hh.BETTING.rounds[0] + 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 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() diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 927a5214..45b0c60f 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -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') From 7aa0cff8d875e4917ff5ed5b0733acdc4746ab4c Mon Sep 17 00:00:00 2001 From: Worros Date: Sun, 16 Nov 2008 13:43:24 +0900 Subject: [PATCH 3/4] Make ftp kinda work --- pyfpdb/GuiGraphViewer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py index b61a9264..c05cb84d 100644 --- a/pyfpdb/GuiGraphViewer.py +++ b/pyfpdb/GuiGraphViewer.py @@ -58,7 +58,7 @@ class GuiGraphViewer (threading.Thread): if self.sites == "PokerStars": site=2 sitename="PokerStars: " - elif site=="FTP": + elif self.sites=="Full Tilt": site=1 sitename="Full Tilt: " else: From 55332d4983125051927d912fe80e3d277ca2c1eb Mon Sep 17 00:00:00 2001 From: Worros Date: Sun, 16 Nov 2008 13:44:16 +0900 Subject: [PATCH 4/4] More Everleaf updates, may have a functional regex for action in NLHE --- pyfpdb/EverleafToFpdb.py | 20 ++++++++++++++++++-- pyfpdb/HandHistoryConverter.py | 13 +++++++++++-- pyfpdb/RegressionTest.py | 1 + 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index e198ddbd..ed13d235 100644 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -74,6 +74,7 @@ class Everleaf(HandHistoryConverter): self.rexx.setPostSbRegex('.*\n(?P.*): posts small blind \[') self.rexx.setPostBbRegex('.*\n(?P.*): posts big blind \[') self.rexx.setHeroCardsRegex('.*\nDealt\sto\s(?P.*)\s\[ (?P.*) \]') + self.rexx.setActionStepRegex('^(?P.*) (?Pbets|checks|raises|calls|folds)((\s\$([.\d]+))?(\sto\s\$([.\d]+))?)?') self.rexx.compileRegexes() def readSupportedGames(self): @@ -118,6 +119,19 @@ class Everleaf(HandHistoryConverter): hand.players = players + def markStreets(self, hands): + # PREFLOP = ** Dealing down cards ** +# m = re.search('(\*\* Dealing down cards \*\*)(?P.*)(\*\* Dealing Flop \*\*)?(?P.*)?(\*\* Dealing Turn \*\*)?(?P.*)', hands.string,re.DOTALL) + m = re.search('(\*\* Dealing down cards \*\*\n)(?P.*?\n\*\*)?( Dealing Flop \*\*)?(?P.*?\*\*)?( Dealing Turn \*\*)?(?P.*?\*\*)?( Dealing River \*\*)?(?P.*)', hands.string,re.DOTALL) + print "DEBUG: Group 1 = %s - %s - %s" %(m.group(1), m.start(1), len(hands.string)) + print "DEBUG: Group 2 = %s - %s - %s" %(m.group(2), m.start(2), len(hands.string)) + print "DEBUG: Group 3 = %s - %s - %s" %(m.group(3), m.start(3), len(hands.string)) + print "DEBUG: Group 4 = %s - %s - %s" %(m.group(4), m.start(4), len(hands.string)) + print "DEBUG: Group 5 = %s - %s - %s" %(m.group(5), m.start(5), len(hands.string)) + print "DEBUG: Group 6 = %s - %s - %s" %(m.group(6), m.start(6), len(hands.string)) + print "DEBUG: Group 7 = %s - %s - %s" %(m.group(7), m.start(7), len(hands.string)) + print "DEBUG: Group 8 = %s - %s - %s" %(m.group(8), m.start(8), len(hands.string)) + def readBlinds(self, hand): try: m = self.rexx.small_blind_re.search(hand.string) @@ -144,8 +158,10 @@ class Everleaf(HandHistoryConverter): hand.holecards = hand.holecards.replace('j','J') hand.holecards = hand.holecards.replace('t','T') - def readAction(self): - pass + def readAction(self, hand, street): + m = self.rexx.rexx.action_re.search(hand.obs) + print m.groups() + if __name__ == "__main__": c = Configuration.Config() diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 35f5d419..13feef90 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -64,6 +64,7 @@ class HandHistoryConverter: for hand in self.hands: self.readHandInfo(hand) self.readPlayerStacks(hand) + self.markStreets(hand) self.readBlinds(hand) self.readHeroCards(hand) if(hand.involved == True): @@ -87,12 +88,14 @@ class HandHistoryConverter: # [['seat#', 'player1name', 'stacksize'] ['seat#', 'player2name', 'stacksize'] [...]] def readPlayerStacks(self, hand): abstract + def markStreets(hand): abstract + #Needs to return a list in the format # ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb, # addtional players are assumed to post a bb oop def readBlinds(self, hand): abstract def readHeroCards(self, hand): abstract - def readAction(self): abstract + def readAction(self, hand, street): abstract def sanityCheck(self): sane = False @@ -167,7 +170,7 @@ class HandHistoryConverter: ## ACTION STUFF # print "*** SUMMARY ***" -# print "Total pot $" + totalpot + " | Rake $" + rake +# print "Total pot $%s | Rake $%s)" %(hand.totalpot $" + hand.rake) # print "Board [" + boardcards + "]" # ## SUMMARY STUFF @@ -195,6 +198,9 @@ class Hand: self.gametype = gametype self.string = string + self.streets = {} # Index into string for where street starts { 'RIVER': 49 } + # Value in characters. + self.handid = 0 self.sb = gametype[3] self.bb = gametype[4] @@ -209,6 +215,8 @@ class Hand: self.hero = "Hiro" self.holecards = "Xx Xx" self.action = [] + self.totalpot = 0 + self.rake = 0 def printHand(self): print self.sitename @@ -226,3 +234,4 @@ class Hand: print self.posted print self.action print self.involved + print self.hero diff --git a/pyfpdb/RegressionTest.py b/pyfpdb/RegressionTest.py index 26bec1e9..26588ba0 100644 --- a/pyfpdb/RegressionTest.py +++ b/pyfpdb/RegressionTest.py @@ -49,6 +49,7 @@ class TestSequenceFunctions(unittest.TestCase): self.mysql_settings['db-password']) self.mysqldict = FpdbSQLQueries.FpdbSQLQueries('MySQL InnoDB') self.mysqlimporter = fpdb_import.Importer(self, self.mysql_settings, self.c) + self.mysqlimporter.setCallHud(False) # """Configure Postgres settings/database and establish connection""" # self.pg_settings={ 'db-host':"localhost", 'db-backend':3, 'db-databaseName':"fpdbtest", 'db-user':"fpdb", 'db-password':"fpdb"}