From a10d6d6286990d2efa6997bed891cbf9d245c826 Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Mon, 6 Dec 2010 17:31:50 +0200 Subject: [PATCH 01/14] Update changelog to 0.21-rc1 --- packaging/debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packaging/debian/changelog b/packaging/debian/changelog index c09713a3..8ebf2bcd 100644 --- a/packaging/debian/changelog +++ b/packaging/debian/changelog @@ -1,3 +1,9 @@ +free-poker-tools (0.21~rc1) unstable; urgency=low + + * First 0.21 release candidate + + -- Mika Bostrom Mon, 06 Dec 2010 17:30:54 +0200 + free-poker-tools (0.20.906-1) unstable; urgency=low * New snapshot From 6d3e21756db88ecf73f86cda918130f7fcb2ce07 Mon Sep 17 00:00:00 2001 From: "chaz@pokeit.co" Date: Mon, 20 Dec 2010 07:02:00 -0500 Subject: [PATCH 02/14] * Commented out BB won in sessionsCache for the time being. Will add it back in once I resolve the errors. --- pyfpdb/Database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 89d3d630..ac33cfc9 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -2094,7 +2094,7 @@ class Database: if (game['type']=='ring'): line[0] = 1 # count ring hands if (game['type']=='tour'): line[1] = 1 # count tour hands if (game['type']=='ring'): line[2] = pdata[p]['totalProfit'] #sum of profit - if (game['type']=='ring'): line[3] = float(Decimal(pdata[p]['totalProfit'])/Decimal(bigBet)) #sum of big bets won + if (game['type']=='ring'): line[3] = 0 #float(Decimal(pdata[p]['totalProfit'])/Decimal(bigBet)) #sum of big bets won line[4] = startTime inserts.append(line) From 797c126318b0658aa936343cb312ae93392f1a17 Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 22 Dec 2010 11:26:58 +0800 Subject: [PATCH 03/14] Database: Disable alchemy pools Want to use DBAPIs connection.row_factory so we can select() directly into a dict --- pyfpdb/Database.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index 89d3d630..ec6b299e 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -60,11 +60,14 @@ import Configuration # Other library modules try: import sqlalchemy.pool as pool - use_pool = True + #use_pool = True + # Forcing to False so we can use connection.row_factory + use_pool = False except ImportError: log.info(_("Not using sqlalchemy connection pool.")) use_pool = False + try: from numpy import var use_numpy = True @@ -446,7 +449,8 @@ class Database: self.db_path = database log.info(_("Connecting to SQLite: %(database)s") % {'database':self.db_path}) if os.path.exists(database) or create: - self.connection = sqlite3.connect(self.db_path, detect_types=sqlite3.PARSE_DECLTYPES ) + self.connection = sqlite3.connect(self.db_path, detect_types=sqlite3.PARSE_DECLTYPES) + self.connection.row_factory = sqlite3.Row self.__connected = True sqlite3.register_converter("bool", lambda x: bool(int(x))) sqlite3.register_adapter(bool, lambda x: "1" if x else "0") From a9c0593eb56f97b7aa7d4c8a75b7c4646cfe2adc Mon Sep 17 00:00:00 2001 From: Mika Bostrom Date: Wed, 22 Dec 2010 06:02:02 +0200 Subject: [PATCH 04/14] Demote postgres/mysql to suggestions For most users we only need to depend on sqlite bindings anyway. --- packaging/debian/control | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packaging/debian/control b/packaging/debian/control index c510e1c8..945b741e 100644 --- a/packaging/debian/control +++ b/packaging/debian/control @@ -11,9 +11,8 @@ Section: games Priority: extra Depends: ${python:Depends}, python-gtk2, python-matplotlib, python-support, python-xlib, - mysql-server | postgresql | python-pysqlite2, - python-psycopg2 | python-mysqldb -Suggests: wine + python-pysqlite2 +Suggests: wine, postgresql | mysql-server, python-psycopg2 | python-mysqldb Description: free poker database with HUD FPDB is a statistics tool for online poker. It supports most sites and several games. Most prominent feature is its heads-up display From 10fc52e96fc99ed70fd16db6f2133ecab02157d8 Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 22 Dec 2010 12:13:58 +0800 Subject: [PATCH 05/14] Hand: First pass at select() for Hand --- pyfpdb/Hand.py | 164 ++++++++++++++++++++++++++----------------------- 1 file changed, 87 insertions(+), 77 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 10f15f57..28dc6bc5 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -289,99 +289,109 @@ db: a connected Database object""" hp.seatno, round(hp.winnings / 100.0,2) as winnings, p.name, - round(hp.startcash / 100.0,2) as chips, - hp.card1,hp.card2, + round(hp.startCash / 100.0,2) as chips, + hp.card1,hp.card2,hp.card3,hp.card4, hp.position FROM HandsPlayers as hp, Players as p WHERE hp.handId = %s - and p.id = hp.playerid + and p.id = hp.playerId """ q = q.replace('%s', db.sql.query['placeholder']) # PlayerStacks c.execute(q, (handId,)) - for (seat, winnings, name, chips, card1,card2, position) in c.fetchall(): - print "DEBUG: seat: '%s'\tname: '%s'\tchips: '%s'" % (seat, name, chips) + for (seat, winnings, name, chips, card1, card2, card3, card4, position) in c.fetchall(): self.addPlayer(seat,name,str(chips)) - #if card1 and card2: - # self.addHoleCards(map(Card.valueSuitFromCard, (card1,card2)), name, dealt=True) - #if winnings > 0: - # self.addCollectPot(name, winnings) - #if position == 'B': - # self.buttonpos = seat + cardlist = map(Card.valueSuitFromCard, [card1, card2, card3, card4]) + cardlist = [card1, card2, card3, card4] + self.addHoleCards('PREFLOP', name, closed=cardlist, shown=False, mucked=False, dealt=True) + if winnings > 0: + self.addCollectPot(name, str(winnings)) + if position == 'B': + self.buttonpos = seat - # HandInfo : HID, TABLE - # BUTTON - why is this treated specially in Hand? - # answer: it is written out in hand histories - # still, I think we should record all the active seat positions in a seat_order array - #c.execute("""SELECT - # h.sitehandno as hid, - # h.tablename as table, - # h.startTime as startTime - # FROM - # Hands as h - # WHERE h.id = %(handid)s - # """, {'handid':handid}) - #res = c.fetchone() - #h.handid = res[0] - #h.tablename = res[1] - #h.startTime = res[2] # automatically a datetime + # HandInfo + q = """SELECT * + FROM Hands + WHERE id = %s + """ + q = q.replace('%s', db.sql.query['placeholder']) + c.execute(q, (handId,)) + + # NOTE: This relies on row_factory = sqlite3.Row (set in connect() params) + # Need to find MySQL and Postgres equivalents + # MySQL maybe: cursorclass=MySQLdb.cursors.DictCursor + res = c.fetchone() + self.tablename = res['tableName'] + self.startTime = res['startTime'] # automatically a datetime + #res['tourneyId'] + #gametypeId + #res['importTime'] # Don't really care about this + #res['seats'] + self.maxseats = res['maxSeats'] + #res['rush'] + cards = map(Card.valueSuitFromCard, [res['boardcard1'], res['boardcard2'], res['boardcard3'], res['boardcard4'], res['boardcard5']]) + if cards[0]: + self.setCommunityCards('FLOP', cards[0:3]) + if cards[3]: + self.setCommunityCards('TURN', [cards[3]]) + if cards[4]: + self.setCommunityCards('RIVER', [cards[4]]) + # playersVpi | playersAtStreet1 | playersAtStreet2 | playersAtStreet3 | + # playersAtStreet4 | playersAtShowdown | street0Raises | street1Raises | + # street2Raises | street3Raises | street4Raises | street1Pot | street2Pot | + # street3Pot | street4Pot | showdownPot | comment | commentTs | texture - #cards = map(Card.valueSuitFromCard, res[11:16] ) - #if cards[0]: - # h.setCommunityCards('FLOP', cards[0:3]) - #if cards[3]: - # h.setCommunityCards('TURN', [cards[3]]) - #if cards[4]: - # h.setCommunityCards('RIVER', [cards[4]]) - #[Card.valueSuitFromCard(x) for x in cards] - - - # actions - #c.execute("""SELECT - # (ha.street,ha.actionno) as actnum, - # p.name, - # ha.street, - # ha.action, - # ha.allin, - # round(ha.amount / 100.0,2) - # FROM - # handsplayers as hp, - # handsactions as ha, - # players as p - # WHERE - # hp.handid = %(handid)s - # and ha.handsplayerid = hp.id - # and p.id = hp.playerid - # ORDER BY - # ha.street,ha.actionno - # """, {'handid':handid}) - #res = c.fetchall() - #for (actnum,player, streetnum, act, allin, amount) in res: - # act=act.strip() - # street = h.allStreets[streetnum+1] - # if act==u'blind': - # h.addBlind(player, 'big blind', amount) - # # TODO: The type of blind is not recorded in the DB. - # # TODO: preflop street name anomalies in Hand - # elif act==u'fold': - # h.addFold(street,player) - # elif act==u'call': - # h.addCall(street,player,amount) - # elif act==u'bet': - # h.addBet(street,player,amount) - # elif act==u'check': - # h.addCheck(street,player) - # elif act==u'unbet': - # pass - # else: - # print act, player, streetnum, allin, amount - # # TODO : other actions + # Actions + q = """SELECT + ha.actionNo, + p.name, + ha.street, + ha.actionId, + ha.allIn, + round(ha.amount / 100.0,2) as bet + FROM + HandsActions as ha, + HandsPlayers as hp, + Players as p, + Hands as h + WHERE + h.id = %s + and ha.handsPlayerId = hp.id + and hp.playerId = p.id + AND h.id = hp.handId + ORDER BY + ha.id ASC +; """ + q = q.replace('%s', db.sql.query['placeholder']) + c.execute(q, (handId,)) + for row in c.fetchall(): + name = row['name'] + street = row['street'] + act = row['actionId'] + # allin True/False if row['allIn'] == 0 + bet = row['bet'] + print "DEBUG: name: '%s' street: '%s' act: '%s' bet: '%s'" %(name, street, act, bet) + street = self.allStreets[int(street)+1] + if act == 2: # Small Blind + self.addBlind(name, 'small blind', str(bet)) + elif act == 4: # Big Blind + self.addBlind(name, 'big blind', str(bet)) + elif act == 6: # Call + self.addCall(street, name, str(bet)) + elif act == 8: # Bet + self.addBet(street, name, str(bet)) + elif act == 10: # Fold + self.addFold(street, name) + elif act == 11: # Check + self.addCheck(street, name) + else: + print "DEBUG: unknown action: '%s'" % act #hhc.readShowdownActions(self) #hc.readShownCards(self) From f31d0cbfc8f9d11e45e564b8d840dc0a10b2296c Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 22 Dec 2010 13:03:45 +0800 Subject: [PATCH 06/14] Replayer: Switch over to Hand.select() --- pyfpdb/GuiReplayer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyfpdb/GuiReplayer.py b/pyfpdb/GuiReplayer.py index ba5a985e..c91d0410 100644 --- a/pyfpdb/GuiReplayer.py +++ b/pyfpdb/GuiReplayer.py @@ -249,7 +249,7 @@ class GuiReplayer: be replaced by a function to select a hand from the db in the not so distant future. This code has been shamelessly stolen from Carl """ - if True: + if False: settings = {} settings.update(self.conf.get_db_parameters()) settings.update(self.conf.get_import_parameters()) @@ -276,7 +276,7 @@ class GuiReplayer: # for the Hand.__init__ ####### Shift this section in Database.py for all to use ###### - handid = 40 + handid = 2 q = self.sql.query['get_gameinfo_from_hid'] q = q.replace('%s', self.sql.query['placeholder']) @@ -295,6 +295,7 @@ class GuiReplayer: print "DEBUG: Create stud hand here" elif gametype['base'] == 'draw': print "DEBUG: Create draw hand here" + return h def temp(self): pass From 9cff165c3c0ad7fc64049bcb3d44c3995ebcb49f Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 22 Dec 2010 13:04:20 +0800 Subject: [PATCH 07/14] Hand: select() updates Fix SQL for seat order Fix startTime formating Add lots of commented out debug --- pyfpdb/Hand.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 28dc6bc5..28b67416 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -298,15 +298,20 @@ db: a connected Database object""" WHERE hp.handId = %s and p.id = hp.playerId + ORDER BY + hp.seatno """ q = q.replace('%s', db.sql.query['placeholder']) # PlayerStacks c.execute(q, (handId,)) for (seat, winnings, name, chips, card1, card2, card3, card4, position) in c.fetchall(): + #print "DEBUG: addPlayer(%s, %s, %s)" %(seat,name,str(chips)) self.addPlayer(seat,name,str(chips)) + #print "DEBUG: card1: %s" % card1 cardlist = map(Card.valueSuitFromCard, [card1, card2, card3, card4]) cardlist = [card1, card2, card3, card4] + #print "DEUBG: cardlist: '%s'" % cardlist self.addHoleCards('PREFLOP', name, closed=cardlist, shown=False, mucked=False, dealt=True) if winnings > 0: self.addCollectPot(name, str(winnings)) @@ -327,7 +332,8 @@ db: a connected Database object""" # MySQL maybe: cursorclass=MySQLdb.cursors.DictCursor res = c.fetchone() self.tablename = res['tableName'] - self.startTime = res['startTime'] # automatically a datetime + self.handid = res['siteHandNo'] + self.startTime = datetime.datetime.strptime(res['startTime'], "%Y-%m-%d %H:%M:%S+00:00") #res['tourneyId'] #gametypeId #res['importTime'] # Don't really care about this @@ -335,6 +341,8 @@ db: a connected Database object""" self.maxseats = res['maxSeats'] #res['rush'] cards = map(Card.valueSuitFromCard, [res['boardcard1'], res['boardcard2'], res['boardcard3'], res['boardcard4'], res['boardcard5']]) + #print "DEBUG: res['boardcard1']: %s" % res['boardcard1'] + #print "DEBUG: cards: %s" % cards if cards[0]: self.setCommunityCards('FLOP', cards[0:3]) if cards[3]: @@ -376,9 +384,10 @@ db: a connected Database object""" act = row['actionId'] # allin True/False if row['allIn'] == 0 bet = row['bet'] - print "DEBUG: name: '%s' street: '%s' act: '%s' bet: '%s'" %(name, street, act, bet) street = self.allStreets[int(street)+1] + #print "DEBUG: name: '%s' street: '%s' act: '%s' bet: '%s'" %(name, street, act, bet) if act == 2: # Small Blind + print "DEBUG: addBlind(%s, 'small blind', %s" %(name, str(bet)) self.addBlind(name, 'small blind', str(bet)) elif act == 4: # Big Blind self.addBlind(name, 'big blind', str(bet)) @@ -393,6 +402,9 @@ db: a connected Database object""" else: print "DEBUG: unknown action: '%s'" % act + #print self + #self.writeHand() + #hhc.readShowdownActions(self) #hc.readShownCards(self) #h.totalPot() From d94f7a68a231abc13af1e34de6cd147dbef7bf71 Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 22 Dec 2010 13:08:41 +0800 Subject: [PATCH 08/14] Hand: Fix for stack print in writeHand --- pyfpdb/Hand.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 28b67416..68c87425 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -403,7 +403,7 @@ db: a connected Database object""" print "DEBUG: unknown action: '%s'" % act #print self - #self.writeHand() + self.writeHand() #hhc.readShowdownActions(self) #hc.readShownCards(self) @@ -1002,7 +1002,7 @@ class HoldemOmahaHand(Hand): log.debug(self.actions['PREFLOP']) for player in [x for x in self.players if x[1] in players_who_act_preflop]: #Only print stacks of players who do something preflop - print >>fh, ("Seat %s: %s ($%s in chips) " %(player[0], player[1], player[2])) + print >>fh, ("Seat %s: %s ($%.2f in chips) " %(player[0], player[1], float(player[2]))) if self.actions['BLINDSANTES']: for act in self.actions['BLINDSANTES']: From 2382152cb83c589b5f288cf855aec8a564aa7f8f Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 22 Dec 2010 13:20:43 +0800 Subject: [PATCH 09/14] Hand: select() update - Fix holecards for holdem --- pyfpdb/Hand.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index 68c87425..f61f0765 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -309,10 +309,16 @@ db: a connected Database object""" #print "DEBUG: addPlayer(%s, %s, %s)" %(seat,name,str(chips)) self.addPlayer(seat,name,str(chips)) #print "DEBUG: card1: %s" % card1 - cardlist = map(Card.valueSuitFromCard, [card1, card2, card3, card4]) - cardlist = [card1, card2, card3, card4] + # map() should work, but is returning integers... FIXME later + #cardlist = map(Card.valueSuitFromCard, [card1, card2, card3, card4]) + cardlist = [Card.valueSuitFromCard(card1), Card.valueSuitFromCard(card2), Card.valueSuitFromCard(card3), Card.valueSuitFromCard(card4)] #print "DEUBG: cardlist: '%s'" % cardlist - self.addHoleCards('PREFLOP', name, closed=cardlist, shown=False, mucked=False, dealt=True) + if cardlist[0] == '': + pass + elif self.gametype['category'] == 'holdem': + self.addHoleCards('PREFLOP', name, closed=cardlist[0:2], shown=False, mucked=False, dealt=True) + elif self.gametype['category'] == 'omaha': + self.addHoleCards('PREFLOP', name, closed=cardlist, shown=False, mucked=False, dealt=True) if winnings > 0: self.addCollectPot(name, str(winnings)) if position == 'B': From 6487691b695ba127e41e98137e451b4cded0c8e4 Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 22 Dec 2010 13:26:41 +0800 Subject: [PATCH 10/14] Hand: Add pot calculations to select() --- pyfpdb/Hand.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py index f61f0765..405a56e5 100644 --- a/pyfpdb/Hand.py +++ b/pyfpdb/Hand.py @@ -408,13 +408,12 @@ db: a connected Database object""" else: print "DEBUG: unknown action: '%s'" % act - #print self + self.totalPot() + self.rake = self.totalpot - self.totalcollected self.writeHand() #hhc.readShowdownActions(self) #hc.readShownCards(self) - #h.totalPot() - #h.rake = h.totalpot - h.totalcollected def addPlayer(self, seat, name, chips): From e3f0e971e65c2d8779b7a1c9ffc36ec980ca594e Mon Sep 17 00:00:00 2001 From: gimick Date: Wed, 22 Dec 2010 15:07:58 +0000 Subject: [PATCH 11/14] GuiRingPlayerStats: Fix > 100% CB stat, and clarify helptext for CB --- pyfpdb/GuiRingPlayerStats.py | 2 +- pyfpdb/SQL.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyfpdb/GuiRingPlayerStats.py b/pyfpdb/GuiRingPlayerStats.py index 0d40fd59..e32317a2 100644 --- a/pyfpdb/GuiRingPlayerStats.py +++ b/pyfpdb/GuiRingPlayerStats.py @@ -52,7 +52,7 @@ onlinehelp = {'Game':_('Type of Game'), 'PF3':_('% Pre Flop Re-Raise / 3Bet'), 'AggFac':_('Aggression Factor\n'), 'AggFreq':_('Aggression Frequency\nBet or Raise vs Fold'), - 'ContBet':_('Continuation Bet on the flop'), + 'ContBet':_('Continuation Bet post-flop'), 'RFI':_('% Raise First In\% Raise when first to bet'), 'Steals':_('% First to raise pre-flop\nand steal blinds'), 'Saw_F':_('% Saw Flop vs hands dealt'), diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index d45ccd38..31856b51 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -2183,7 +2183,7 @@ class Sql: (sum(cast(hp.street1Calls as integer))+ sum(cast(hp.street2Calls as integer))+ sum(cast(hp.street3Calls as integer))+ sum(cast(hp.street4Calls as integer))) + (sum(cast(hp.street1Aggr as integer)) + sum(cast(hp.street2Aggr as integer)) + sum(cast(hp.street3Aggr as integer)) + sum(cast(hp.street4Aggr as integer))) ) AS aggfrq - ,100.0*(sum(cast(hp.street1CBDone as integer)) + sum(cast(hp.street2CBDone as integer)) + sum(cast(hp.street2CBDone as integer)) + sum(cast(hp.street4CBDone as integer))) + ,100.0*(sum(cast(hp.street1CBDone as integer)) + sum(cast(hp.street2CBDone as integer)) + sum(cast(hp.street3CBDone as integer)) + sum(cast(hp.street4CBDone as integer))) / (sum(cast(hp.street1CBChance as integer))+ sum(cast(hp.street2CBChance as integer))+ sum(cast(hp.street3CBChance as integer))+ sum(cast(hp.street4CBChance as integer))) AS conbet ,sum(hp.totalProfit)/100.0 AS net @@ -2304,7 +2304,7 @@ class Sql: (sum(cast(hp.street1Calls as integer))+ sum(cast(hp.street2Calls as integer))+ sum(cast(hp.street3Calls as integer))+ sum(cast(hp.street4Calls as integer))) + (sum(cast(hp.street1Aggr as integer)) + sum(cast(hp.street2Aggr as integer)) + sum(cast(hp.street3Aggr as integer)) + sum(cast(hp.street4Aggr as integer))) ) AS aggfrq - ,100.0*(sum(cast(hp.street1CBDone as integer)) + sum(cast(hp.street2CBDone as integer)) + sum(cast(hp.street2CBDone as integer)) + sum(cast(hp.street4CBDone as integer))) + ,100.0*(sum(cast(hp.street1CBDone as integer)) + sum(cast(hp.street2CBDone as integer)) + sum(cast(hp.street3CBDone as integer)) + sum(cast(hp.street4CBDone as integer))) / (sum(cast(hp.street1CBChance as integer))+ sum(cast(hp.street2CBChance as integer))+ sum(cast(hp.street3CBChance as integer))+ sum(cast(hp.street4CBChance as integer))) AS conbet ,sum(hp.totalProfit)/100.0 AS net @@ -2426,7 +2426,7 @@ class Sql: (sum(cast(hp.street1Calls as integer))+ sum(cast(hp.street2Calls as integer))+ sum(cast(hp.street3Calls as integer))+ sum(cast(hp.street4Calls as integer))) + (sum(cast(hp.street1Aggr as integer)) + sum(cast(hp.street2Aggr as integer)) + sum(cast(hp.street3Aggr as integer)) + sum(cast(hp.street4Aggr as integer))) ) AS aggfrq - ,100.0*(sum(cast(hp.street1CBDone as integer)) + sum(cast(hp.street2CBDone as integer)) + sum(cast(hp.street2CBDone as integer)) + sum(cast(hp.street4CBDone as integer))) + ,100.0*(sum(cast(hp.street1CBDone as integer)) + sum(cast(hp.street2CBDone as integer)) + sum(cast(hp.street3CBDone as integer)) + sum(cast(hp.street4CBDone as integer))) / (sum(cast(hp.street1CBChance as integer))+ sum(cast(hp.street2CBChance as integer))+ sum(cast(hp.street3CBChance as integer))+ sum(cast(hp.street4CBChance as integer))) AS conbet ,sum(hp.totalProfit)/100.0 AS net From fc836ea9022cdbb5edfb1318e3b83fbd58a1f706 Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 23 Dec 2010 12:40:22 +0800 Subject: [PATCH 12/14] Replayer: Move table hash creation into a class Add several other classes too --- pyfpdb/GuiReplayer.py | 77 +++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 17 deletions(-) diff --git a/pyfpdb/GuiReplayer.py b/pyfpdb/GuiReplayer.py index c91d0410..86646cf2 100644 --- a/pyfpdb/GuiReplayer.py +++ b/pyfpdb/GuiReplayer.py @@ -100,7 +100,10 @@ class GuiReplayer: self.replayBox.pack_start(self.area) + gobject.timeout_add(1000,self.draw_action) + self.MyHand = self.importhand() + self.table = Table(self.area, self.MyHand).table self.maxseats=self.MyHand.maxseats @@ -109,21 +112,6 @@ class GuiReplayer: elif self.MyHand.gametype['currency']=="EUR": self.currency="€" - - self.table={} #create table with positions, player names, status (live/folded), stacks and chips on table - for i in range(0,self.maxseats): # radius: 200, center: 250,250 - x= int (round(250+200*math.cos(2*i*math.pi/self.maxseats))) - y= int (round(250+200*math.sin(2*i*math.pi/self.maxseats))) - try: - self.table[i]={"name":self.MyHand.players[i][1],"stack":Decimal(self.MyHand.players[i][2]),"x":x,"y":y,"chips":0,"status":"live"} #save coordinates of each player - try: - self.table[i]['holecards']=self.MyHand.holecards["PREFLOP"][self.MyHand.players[i][1]][1]+' '+self.MyHand.holecards["PREFLOP"][self.MyHand.players[i][1]][2] - print "holecards: ",self.table[i]['holecards'] - except: - self.table[i]['holecards']='' - except IndexError: #if seat is empty - print "seat ",i+1," out of ",self.maxseats," empty" - self.actions=[] #create list with all actions if isinstance(self.MyHand, HoldemOmahaHand): @@ -133,7 +121,6 @@ class GuiReplayer: self.action_number=0 self.action_level=0 self.pot=0 - gobject.timeout_add(1000,self.draw_action) def area_expose(self, area, event): @@ -276,7 +263,7 @@ class GuiReplayer: # for the Hand.__init__ ####### Shift this section in Database.py for all to use ###### - handid = 2 + handid = 1 q = self.sql.query['get_gameinfo_from_hid'] q = q.replace('%s', self.sql.query['placeholder']) @@ -300,6 +287,62 @@ class GuiReplayer: def temp(self): pass +class Table: + def __init__(self, darea, hand): + self.darea = darea + self.hand = hand + #self.pixmap = gtk.gdk.Pixmap(darea, width, height, depth=-1) + + self.table = {} + for i in range(0, hand.maxseats): # radius: 200, center: 250,250 + x= int (round(250+200*math.cos(2*i*math.pi/hand.maxseats))) + y= int (round(250+200*math.sin(2*i*math.pi/hand.maxseats))) + try: + self.table[i]={"name":self.hand.players[i][1],"stack":Decimal(self.hand.players[i][2]),"x":x,"y":y,"chips":0,"status":"live"} #save coordinates of each player + try: + self.table[i]['holecards']=self.hand.holecards["PREFLOP"][self.hand.players[i][1]][1]+' '+self.hand.holecards["PREFLOP"][self.hand.players[i][1]][2] + print "holecards: ",self.table[i]['holecards'] + except: + self.table[i]['holecards']='' + except IndexError: #if seat is empty + print "seat ",i+1," out of ", hand.maxseats," empty" + + print "DEBUG: table: %s" % self.table + + def draw(self): + draw_players() + draw_pot() + draw_community_cards() + +class Player: + def __init__(self, name, stack, position): + self.active = True + self.stack = stack + self.position = position + self.name = name + x = 0 + y = 0 + + def draw(self): + draw_name() + draw_stack() + draw_cards() + +class Pot: + def __init__(self, hand): + self.total = 0.0 + + def draw(self): + pass + +class CommunityCards: + def __init__(self, hand): + self.pixbuf = self.gen_pixbuf_from_file(PATH_TO_THE_FILE) + + def draw(self): + pass + + def main(argv=None): """main can also be called in the python interpreter, by supplying the command line as the argument.""" if argv is None: From 18ccea9a6751dffda914bf5dbc7b2bc67231796d Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 23 Dec 2010 14:18:27 +0800 Subject: [PATCH 13/14] fpdb_import: Correct mainline print --- pyfpdb/fpdb_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 15043503..ba1251ac 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -624,4 +624,4 @@ class ProgressBar: if __name__ == "__main__": - print _("CLI for fpdb_import is now available as CliFpdb.py") + print _("CLI for importing hands is GuiBulkImport.py") From 54264bb2631bd4bff73909c2054fe646458f50b7 Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 23 Dec 2010 15:26:28 +0800 Subject: [PATCH 14/14] Replayer: Refactor player code into its own class --- pyfpdb/GuiReplayer.py | 52 +++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/pyfpdb/GuiReplayer.py b/pyfpdb/GuiReplayer.py index 86646cf2..720a17c4 100644 --- a/pyfpdb/GuiReplayer.py +++ b/pyfpdb/GuiReplayer.py @@ -31,6 +31,9 @@ import gtk import math import gobject +import pprint +pp = pprint.PrettyPrinter(indent=4) + class GuiReplayer: def __init__(self, config, querylist, mainwin, options = None, debug=True): @@ -105,8 +108,6 @@ class GuiReplayer: self.MyHand = self.importhand() self.table = Table(self.area, self.MyHand).table - self.maxseats=self.MyHand.maxseats - if self.MyHand.gametype['currency']=="USD": #TODO: check if there are others .. self.currency="$" elif self.MyHand.gametype['currency']=="EUR": @@ -291,23 +292,18 @@ class Table: def __init__(self, darea, hand): self.darea = darea self.hand = hand + self.players = [] #self.pixmap = gtk.gdk.Pixmap(darea, width, height, depth=-1) + # tmp var while refactoring self.table = {} - for i in range(0, hand.maxseats): # radius: 200, center: 250,250 - x= int (round(250+200*math.cos(2*i*math.pi/hand.maxseats))) - y= int (round(250+200*math.sin(2*i*math.pi/hand.maxseats))) - try: - self.table[i]={"name":self.hand.players[i][1],"stack":Decimal(self.hand.players[i][2]),"x":x,"y":y,"chips":0,"status":"live"} #save coordinates of each player - try: - self.table[i]['holecards']=self.hand.holecards["PREFLOP"][self.hand.players[i][1]][1]+' '+self.hand.holecards["PREFLOP"][self.hand.players[i][1]][2] - print "holecards: ",self.table[i]['holecards'] - except: - self.table[i]['holecards']='' - except IndexError: #if seat is empty - print "seat ",i+1," out of ", hand.maxseats," empty" + i = 0 + for seat, name, chips in hand.players: + self.players.append(Player(hand, name, chips, seat)) + self.table[i] = self.players[i].get_hash() + i += 1 - print "DEBUG: table: %s" % self.table + pp.pprint(self.table) def draw(self): draw_players() @@ -315,13 +311,25 @@ class Table: draw_community_cards() class Player: - def __init__(self, name, stack, position): - self.active = True - self.stack = stack - self.position = position - self.name = name - x = 0 - y = 0 + def __init__(self, hand, name, stack, seat): + self.status = 'live' + self.stack = Decimal(stack) + self.chips = 0 + self.seat = seat + self.name = name + self.holecards = hand.join_holecards(name) + self.x = int (round(250+200*math.cos(2*self.seat*math.pi/hand.maxseats))) + self.y = int (round(250+200*math.sin(2*self.seat*math.pi/hand.maxseats))) + + def get_hash(self): + return { 'chips': 0, + 'holecards': self.holecards, + 'name': self.name, + 'stack': self.stack, + 'status': self.status, + 'x': self.x, + 'y': self.y, + } def draw(self): draw_name()