Merge branch 'master' of git://git.assembla.com/fpdboz
This commit is contained in:
commit
50938c4912
|
@ -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()
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@ class Everleaf(HandHistoryConverter):
|
||||||
self.rexx.setPostSbRegex('.*\n(?P<PNAME>.*): posts small blind \[')
|
self.rexx.setPostSbRegex('.*\n(?P<PNAME>.*): posts small blind \[')
|
||||||
self.rexx.setPostBbRegex('.*\n(?P<PNAME>.*): posts big blind \[')
|
self.rexx.setPostBbRegex('.*\n(?P<PNAME>.*): posts big blind \[')
|
||||||
self.rexx.setHeroCardsRegex('.*\nDealt\sto\s(?P<PNAME>.*)\s\[ (?P<HOLECARDS>.*) \]')
|
self.rexx.setHeroCardsRegex('.*\nDealt\sto\s(?P<PNAME>.*)\s\[ (?P<HOLECARDS>.*) \]')
|
||||||
|
self.rexx.setActionStepRegex('^(?P<PNAME>.*) (?P<ATYPE>bets|checks|raises|calls|folds)((\s\$([.\d]+))?(\sto\s\$([.\d]+))?)?')
|
||||||
self.rexx.compileRegexes()
|
self.rexx.compileRegexes()
|
||||||
|
|
||||||
def readSupportedGames(self):
|
def readSupportedGames(self):
|
||||||
|
@ -118,6 +119,19 @@ class Everleaf(HandHistoryConverter):
|
||||||
|
|
||||||
hand.players = players
|
hand.players = players
|
||||||
|
|
||||||
|
def markStreets(self, hands):
|
||||||
|
# PREFLOP = ** Dealing down cards **
|
||||||
|
# m = re.search('(\*\* Dealing down cards \*\*)(?P<PREFLOP>.*)(\*\* Dealing Flop \*\*)?(?P<FLOP>.*)?(\*\* Dealing Turn \*\*)?(?P<TURN>.*)', hands.string,re.DOTALL)
|
||||||
|
m = re.search('(\*\* Dealing down cards \*\*\n)(?P<PREFLOP>.*?\n\*\*)?( Dealing Flop \*\*)?(?P<FLOP>.*?\*\*)?( Dealing Turn \*\*)?(?P<TURN>.*?\*\*)?( Dealing River \*\*)?(?P<RIVER>.*)', 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):
|
def readBlinds(self, hand):
|
||||||
try:
|
try:
|
||||||
m = self.rexx.small_blind_re.search(hand.string)
|
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('j','J')
|
||||||
hand.holecards = hand.holecards.replace('t','T')
|
hand.holecards = hand.holecards.replace('t','T')
|
||||||
|
|
||||||
def readAction(self):
|
def readAction(self, hand, street):
|
||||||
pass
|
m = self.rexx.rexx.action_re.search(hand.obs)
|
||||||
|
print m.groups()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
c = Configuration.Config()
|
c = Configuration.Config()
|
||||||
|
|
|
@ -60,7 +60,7 @@ class GuiGraphViewer (threading.Thread):
|
||||||
if self.sites == "PokerStars":
|
if self.sites == "PokerStars":
|
||||||
site=2
|
site=2
|
||||||
sitename="PokerStars: "
|
sitename="PokerStars: "
|
||||||
elif site=="FTP":
|
elif self.sites=="Full Tilt":
|
||||||
site=1
|
site=1
|
||||||
sitename="Full Tilt: "
|
sitename="Full Tilt: "
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -64,6 +64,7 @@ class HandHistoryConverter:
|
||||||
for hand in self.hands:
|
for hand in self.hands:
|
||||||
self.readHandInfo(hand)
|
self.readHandInfo(hand)
|
||||||
self.readPlayerStacks(hand)
|
self.readPlayerStacks(hand)
|
||||||
|
self.markStreets(hand)
|
||||||
self.readBlinds(hand)
|
self.readBlinds(hand)
|
||||||
self.readHeroCards(hand)
|
self.readHeroCards(hand)
|
||||||
if(hand.involved == True):
|
if(hand.involved == True):
|
||||||
|
@ -87,12 +88,14 @@ class HandHistoryConverter:
|
||||||
# [['seat#', 'player1name', 'stacksize'] ['seat#', 'player2name', 'stacksize'] [...]]
|
# [['seat#', 'player1name', 'stacksize'] ['seat#', 'player2name', 'stacksize'] [...]]
|
||||||
def readPlayerStacks(self, hand): abstract
|
def readPlayerStacks(self, hand): abstract
|
||||||
|
|
||||||
|
def markStreets(hand): abstract
|
||||||
|
|
||||||
#Needs to return a list in the format
|
#Needs to return a list in the format
|
||||||
# ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb,
|
# ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb,
|
||||||
# addtional players are assumed to post a bb oop
|
# addtional players are assumed to post a bb oop
|
||||||
def readBlinds(self, hand): abstract
|
def readBlinds(self, hand): abstract
|
||||||
def readHeroCards(self, hand): abstract
|
def readHeroCards(self, hand): abstract
|
||||||
def readAction(self): abstract
|
def readAction(self, hand, street): abstract
|
||||||
|
|
||||||
def sanityCheck(self):
|
def sanityCheck(self):
|
||||||
sane = False
|
sane = False
|
||||||
|
@ -167,7 +170,7 @@ class HandHistoryConverter:
|
||||||
## ACTION STUFF
|
## ACTION STUFF
|
||||||
#
|
#
|
||||||
print "*** SUMMARY ***"
|
print "*** SUMMARY ***"
|
||||||
# print "Total pot $" + totalpot + " | Rake $" + rake
|
# print "Total pot $%s | Rake $%s)" %(hand.totalpot $" + hand.rake)
|
||||||
# print "Board [" + boardcards + "]"
|
# print "Board [" + boardcards + "]"
|
||||||
#
|
#
|
||||||
## SUMMARY STUFF
|
## SUMMARY STUFF
|
||||||
|
@ -195,6 +198,9 @@ class Hand:
|
||||||
self.gametype = gametype
|
self.gametype = gametype
|
||||||
self.string = string
|
self.string = string
|
||||||
|
|
||||||
|
self.streets = {} # Index into string for where street starts { 'RIVER': 49 }
|
||||||
|
# Value in characters.
|
||||||
|
|
||||||
self.handid = 0
|
self.handid = 0
|
||||||
self.sb = gametype[3]
|
self.sb = gametype[3]
|
||||||
self.bb = gametype[4]
|
self.bb = gametype[4]
|
||||||
|
@ -209,6 +215,8 @@ class Hand:
|
||||||
self.hero = "Hiro"
|
self.hero = "Hiro"
|
||||||
self.holecards = "Xx Xx"
|
self.holecards = "Xx Xx"
|
||||||
self.action = []
|
self.action = []
|
||||||
|
self.totalpot = 0
|
||||||
|
self.rake = 0
|
||||||
|
|
||||||
def printHand(self):
|
def printHand(self):
|
||||||
print self.sitename
|
print self.sitename
|
||||||
|
@ -226,3 +234,4 @@ class Hand:
|
||||||
print self.posted
|
print self.posted
|
||||||
print self.action
|
print self.action
|
||||||
print self.involved
|
print self.involved
|
||||||
|
print self.hero
|
||||||
|
|
|
@ -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 ;)
|
||||||
|
|
|
@ -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)
|
tips = []
|
||||||
hh = HandHistory.HandHistory(xml_text, ('BETTING'))
|
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
|
## action in tool tips for 3rd street cards
|
||||||
tip = "%s" % hh.BETTING.rounds[0]
|
|
||||||
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()
|
||||||
|
|
|
@ -49,6 +49,7 @@ class TestSequenceFunctions(unittest.TestCase):
|
||||||
self.mysql_settings['db-password'])
|
self.mysql_settings['db-password'])
|
||||||
self.mysqldict = FpdbSQLQueries.FpdbSQLQueries('MySQL InnoDB')
|
self.mysqldict = FpdbSQLQueries.FpdbSQLQueries('MySQL InnoDB')
|
||||||
self.mysqlimporter = fpdb_import.Importer(self, self.mysql_settings, self.c)
|
self.mysqlimporter = fpdb_import.Importer(self, self.mysql_settings, self.c)
|
||||||
|
self.mysqlimporter.setCallHud(False)
|
||||||
|
|
||||||
# """Configure Postgres settings/database and establish connection"""
|
# """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"}
|
# self.pg_settings={ 'db-host':"localhost", 'db-backend':3, 'db-databaseName':"fpdbtest", 'db-user':"fpdb", 'db-password':"fpdb"}
|
||||||
|
|
|
@ -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')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user