diff --git a/pyfpdb/HUD_config.xml.example b/pyfpdb/HUD_config.xml.example
index de699e2a..e6816f27 100644
--- a/pyfpdb/HUD_config.xml.example
+++ b/pyfpdb/HUD_config.xml.example
@@ -673,6 +673,37 @@ Left-Drag to Move"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py
index 73505129..d658344f 100644
--- a/pyfpdb/SQL.py
+++ b/pyfpdb/SQL.py
@@ -1397,6 +1397,7 @@ class Sql:
sum(hc.foldToStreet4CBChance) AS f_cb_opp_4,
sum(hc.foldToStreet4CBDone) AS f_cb_4,
sum(hc.totalProfit) AS net,
+ sum(gt.bigblind) AS bigblind,
sum(hc.street1CheckCallRaiseChance) AS ccr_opp_1,
sum(hc.street1CheckCallRaiseDone) AS ccr_1,
sum(hc.street2CheckCallRaiseChance) AS ccr_opp_2,
@@ -1425,6 +1426,7 @@ class Sql:
INNER JOIN HudCache hc ON ( hc.PlayerId = hp.PlayerId+0
AND hc.gametypeId+0 = h.gametypeId+0)
INNER JOIN Players p ON (p.id = hp.PlayerId+0)
+ INNER JOIN Gametypes gt ON (gt.id = hc.gametypeId)
WHERE h.id = %s
AND hc.styleKey > %s
/* styleKey is currently 'd' (for date) followed by a yyyymmdd
@@ -1496,6 +1498,7 @@ class Sql:
sum(hc.foldToStreet4CBChance) AS f_cb_opp_4,
sum(hc.foldToStreet4CBDone) AS f_cb_4,
sum(hc.totalProfit) AS net,
+ sum(gt.bigblind) AS bigblind,
sum(hc.street1CheckCallRaiseChance) AS ccr_opp_1,
sum(hc.street1CheckCallRaiseDone) AS ccr_1,
sum(hc.street2CheckCallRaiseChance) AS ccr_opp_2,
@@ -1523,6 +1526,7 @@ class Sql:
INNER JOIN HandsPlayers hp ON (hp.handId = h.id)
INNER JOIN HudCache hc ON (hc.playerId = hp.playerId)
INNER JOIN Players p ON (p.id = hc.playerId)
+ INNER JOIN Gametypes gt ON (gt.id = hc.gametypeId)
WHERE h.id = %s
AND ( /* 2 separate parts for hero and opponents */
( hp.playerId != %s
@@ -1622,6 +1626,7 @@ class Sql:
cast(hp2.foldToStreet4CBChance as integer) AS f_cb_opp_4,
cast(hp2.foldToStreet4CBDone as integer) AS f_cb_4,
cast(hp2.totalProfit as integer) AS net,
+ cast(gt.bigblind as integer) AS bigblind,
cast(hp2.street1CheckCallRaiseChance as integer) AS ccr_opp_1,
cast(hp2.street1CheckCallRaiseDone as integer) AS ccr_1,
cast(hp2.street2CheckCallRaiseChance as integer) AS ccr_opp_2,
@@ -1651,6 +1656,7 @@ class Sql:
INNER JOIN HandsPlayers hp ON (h.id = hp.handId) /* players in this hand */
INNER JOIN HandsPlayers hp2 ON (hp2.playerId+0 = hp.playerId+0 AND (hp2.handId = h2.id+0)) /* other hands by these players */
INNER JOIN Players p ON (p.id = hp2.PlayerId+0)
+ INNER JOIN Gametypes gt ON (gt.id = h2.gametypeId)
WHERE hp.handId = %s
/* check activeseats once this data returned (don't want to do that here as it might
assume a session ended just because the number of seats dipped for a few hands)
@@ -1724,6 +1730,7 @@ class Sql:
cast(hp2.foldToStreet4CBChance as integer) AS f_cb_opp_4,
cast(hp2.foldToStreet4CBDone as integer) AS f_cb_4,
cast(hp2.totalProfit as integer) AS net,
+ cast(gt.bigblind as integer) AS bigblind,
cast(hp2.street1CheckCallRaiseChance as integer) AS ccr_opp_1,
cast(hp2.street1CheckCallRaiseDone as integer) AS ccr_1,
cast(hp2.street2CheckCallRaiseChance as integer) AS ccr_opp_2,
@@ -1754,6 +1761,7 @@ class Sql:
INNER JOIN HandsPlayers hp2 ON ( hp2.playerId+0 = hp.playerId+0
AND hp2.handId = h2.id) /* other hands by these players */
INNER JOIN Players p ON (p.id = hp2.PlayerId+0)
+ INNER JOIN Gametypes gt ON (gt.id = h2.gametypeId)
WHERE h.id = %s
/* check activeseats once this data returned (don't want to do that here as it might
assume a session ended just because the number of seats dipped for a few hands)
@@ -1827,6 +1835,7 @@ class Sql:
cast(hp2.foldToStreet4CBChance as integer) AS f_cb_opp_4,
cast(hp2.foldToStreet4CBDone as integer) AS f_cb_4,
cast(hp2.totalProfit as integer) AS net,
+ cast(gt.bigblind as integer) AS bigblind,
cast(hp2.street1CheckCallRaiseChance as integer) AS ccr_opp_1,
cast(hp2.street1CheckCallRaiseDone as integer) AS ccr_1,
cast(hp2.street2CheckCallRaiseChance as integer) AS ccr_opp_2,
@@ -1857,6 +1866,7 @@ class Sql:
INNER JOIN HandsPlayers hp2 ON ( hp2.playerId+0 = hp.playerId+0
AND hp2.handId = h2.id) /* other hands by these players */
INNER JOIN Players p ON (p.id = hp2.PlayerId+0)
+ INNER JOIN Gametypes gt ON (gt.id = h2.gametypeId)
WHERE h.id = %s
/* check activeseats once this data returned (don't want to do that here as it might
assume a session ended just because the number of seats dipped for a few hands)
diff --git a/pyfpdb/Stats.py b/pyfpdb/Stats.py
index 74558da8..84ba89d9 100755
--- a/pyfpdb/Stats.py
+++ b/pyfpdb/Stats.py
@@ -48,7 +48,7 @@
# 6 For each stat you make add a line to the __main__ function to test it.
# Standard Library modules
-#import sys
+import sys
# pyGTK modules
import pygtk
@@ -60,6 +60,10 @@ import Configuration
import Database
import Charset
+import logging
+# logging has been set up in fpdb.py or HUD_main.py, use their settings:
+log = logging.getLogger("db")
+
re_Places = re.compile("_[0-9]$")
re_Percent = re.compile("%$")
@@ -79,12 +83,23 @@ def do_stat(stat_dict, player = 24, stat = 'vpip'):
else:
base = stat[0:-2]
places = int(stat[-1:])
- result = eval("%(stat)s(stat_dict, %(player)d)" % {'stat': base, 'player': player})
+ result = (0.0, '0.0', 'notset=0', 'notset=0', '0', 'not set')
+ try:
+ result = eval("%(stat)s(stat_dict, %(player)d)" % {'stat': base, 'player': player})
+ except:
+ pass #
+ log.info("exception getting stat "+base+" for player "+str(player)+str(sys.exc_info()))
+ log.debug("result = %s" % str(result) )
+
match = re_Percent.search(result[1])
- if match is None:
- result = (result[0], "%.*f" % (places, result[0]), result[2], result[3], result[4], result[5])
- else:
- result = (result[0], "%.*f%%" % (places, 100*result[0]), result[2], result[3], result[4], result[5])
+ try:
+ if match is None:
+ result = (result[0], "%.*f" % (places, result[0]), result[2], result[3], result[4], result[5])
+ else:
+ result = (result[0], "%.*f%%" % (places, 100*result[0]), result[2], result[3], result[4], result[5])
+ except:
+ log.info( "error: %s" % str(sys.exc_info()))
+ raise
return result
# OK, for reference the tuple returned by the stat is:
@@ -198,7 +213,7 @@ def wmsd(stat_dict, player):
)
def profit100(stat_dict, player):
- """ Profit won per 100 hands (no decimal places)."""
+ """ Profit won per 100 hands."""
stat = 0.0
try:
stat = float(stat_dict[player]['net'])/float(stat_dict[player]['n'])
@@ -212,13 +227,57 @@ def profit100(stat_dict, player):
except:
print "exception calcing p/100: 100 * %d / %d" % (stat_dict[player]['net'], stat_dict[player]['n'])
return (stat,
- '%.0f' % (0),
- 'p=%.0f' % (0),
- 'p/100=%.0f' % (0),
+ '%.0f' % (0.0),
+ 'p=%.0f' % (0.0),
+ 'p/100=%.0f' % (0.0),
'(%d/%d)' % (0, 0),
'profit/100hands'
)
+def bbper100(stat_dict, player):
+ """ big blinds won per 100 hands."""
+ stat = 0.0
+ try:
+ stat = 100.0 * float(stat_dict[player]['net']) / float(stat_dict[player]['bigblind'])
+ return (stat,
+ '%5.3f' % (stat),
+ 'bb100=%5.3f' % (stat),
+ 'bb100=%5.3f' % (stat),
+ '(%d,%d)' % (100*stat_dict[player]['net'],stat_dict[player]['bigblind']),
+ 'big blinds/100 hands'
+ )
+ except:
+ log.info("exception calcing bb/100: "+str(stat_dict[player]))
+ return (stat,
+ '%.0f' % (0),
+ 'bb100=%.0f' % (0),
+ 'bb100=%.0f' % (0),
+ '(%f)' % (0),
+ 'big blinds/100 hands'
+ )
+
+def BBper100(stat_dict, player):
+ """ Big Bets won per 100 hands."""
+ stat = 0.0
+ try:
+ stat = 50 * float(stat_dict[player]['net']) / float(stat_dict[player]['bigblind'])
+ return (stat,
+ '%5.3f' % (stat),
+ 'BB100=%5.3f' % (stat),
+ 'BB100=%5.3f' % (stat),
+ '(%d,%d)' % (100*stat_dict[player]['net'],2*stat_dict[player]['bigblind']),
+ 'Big Bets/100 hands'
+ )
+ except:
+ log.info("exception calcing BB/100: "+str(stat_dict[player]))
+ return (stat,
+ '%.0f' % (0.0),
+ 'BB100=%.0f' % (0.0),
+ 'BB100=%.0f' % (0.0),
+ '(%f)' % (0.0),
+ 'Big Bets/100 hands'
+ )
+
def saw_f(stat_dict, player):
""" Saw flop/4th."""
try:
@@ -782,13 +841,27 @@ def ffreq4(stat_dict, player):
)
if __name__== "__main__":
+ statlist = dir()
+ misslist = [ "Configuration", "Database", "Charset", "codecs", "encoder"
+ , "do_stat", "do_tip", "GInitiallyUnowned", "gtk", "pygtk"
+ , "re", "re_Percent", "re_Places"
+ ]
+ statlist = [ x for x in statlist if x not in dir(sys) ]
+ statlist = [ x for x in statlist if x not in dir(codecs) ]
+ statlist = [ x for x in statlist if x not in misslist ]
+ #print "statlist is", statlist
+
c = Configuration.Config()
#TODO: restore the below code. somehow it creates a version 119 DB but commenting this out makes it print a stat list
- #db_connection = Database.Database(c)
- #h = db_connection.get_last_hand()
- #stat_dict = db_connection.get_stats_from_hand(h, "ring")
+ db_connection = Database.Database(c)
+ h = db_connection.get_last_hand()
+ stat_dict = db_connection.get_stats_from_hand(h, "ring")
- #for player in stat_dict.keys():
+ for player in stat_dict.keys():
+ print "Example stats, player =", player, "hand =", h, ":"
+ for attr in statlist:
+ print " ", do_stat(stat_dict, player=player, stat=attr)
+ break
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'vpip')
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'pfr')
#print "player = ", player, do_stat(stat_dict, player = player, stat = 'wtsd')
@@ -820,11 +893,7 @@ if __name__== "__main__":
print "\n\nLegal stats:"
print "(add _0 to name to display with 0 decimal places, _1 to display with 1, etc)\n"
- for attr in dir():
- if attr.startswith('__'): continue
- if attr in ("Configuration", "Database", "GInitiallyUnowned", "gtk", "pygtk",
- "player", "c", "db_connection", "do_stat", "do_tip", "stat_dict",
- "h", "re", "re_Percent", "re_Places"): continue
+ for attr in statlist:
print "%-14s %s" % (attr, eval("%s.__doc__" % (attr)))
# print " " % (attr)
print