Merge branch 'master' of git://git.assembla.com/fpdboz
This commit is contained in:
commit
5435c164f9
|
@ -1409,6 +1409,14 @@ class Database:
|
||||||
pdata[p]['street2Aggr'],
|
pdata[p]['street2Aggr'],
|
||||||
pdata[p]['street3Aggr'],
|
pdata[p]['street3Aggr'],
|
||||||
pdata[p]['street4Aggr'],
|
pdata[p]['street4Aggr'],
|
||||||
|
pdata[p]['street1CBChance'],
|
||||||
|
pdata[p]['street2CBChance'],
|
||||||
|
pdata[p]['street3CBChance'],
|
||||||
|
pdata[p]['street4CBChance'],
|
||||||
|
pdata[p]['street1CBDone'],
|
||||||
|
pdata[p]['street2CBDone'],
|
||||||
|
pdata[p]['street3CBDone'],
|
||||||
|
pdata[p]['street4CBDone'],
|
||||||
pdata[p]['wonWhenSeenStreet1'],
|
pdata[p]['wonWhenSeenStreet1'],
|
||||||
pdata[p]['street0Calls'],
|
pdata[p]['street0Calls'],
|
||||||
pdata[p]['street1Calls'],
|
pdata[p]['street1Calls'],
|
||||||
|
@ -1449,6 +1457,14 @@ class Database:
|
||||||
street2Aggr,
|
street2Aggr,
|
||||||
street3Aggr,
|
street3Aggr,
|
||||||
street4Aggr,
|
street4Aggr,
|
||||||
|
street1CBChance,
|
||||||
|
street2CBChance,
|
||||||
|
street3CBChance,
|
||||||
|
street4CBChance,
|
||||||
|
street1CBDone,
|
||||||
|
street2CBDone,
|
||||||
|
street3CBDone,
|
||||||
|
street4CBDone,
|
||||||
wonWhenSeenStreet1,
|
wonWhenSeenStreet1,
|
||||||
street0Calls,
|
street0Calls,
|
||||||
street1Calls,
|
street1Calls,
|
||||||
|
@ -1462,7 +1478,8 @@ class Database:
|
||||||
street4Bets
|
street4Bets
|
||||||
)
|
)
|
||||||
VALUES (
|
VALUES (
|
||||||
%s, %s,
|
%s, %s, %s, %s, %s,
|
||||||
|
%s, %s, %s, %s, %s,
|
||||||
%s, %s, %s, %s, %s,
|
%s, %s, %s, %s, %s,
|
||||||
%s, %s, %s, %s, %s,
|
%s, %s, %s, %s, %s,
|
||||||
%s, %s, %s, %s, %s,
|
%s, %s, %s, %s, %s,
|
||||||
|
@ -1491,14 +1508,6 @@ class Database:
|
||||||
# foldedBbToSteal,
|
# foldedBbToSteal,
|
||||||
# foldSbToStealChance,
|
# foldSbToStealChance,
|
||||||
# foldedSbToSteal,
|
# foldedSbToSteal,
|
||||||
# street1CBChance,
|
|
||||||
# street1CBDone,
|
|
||||||
# street2CBChance,
|
|
||||||
# street2CBDone,
|
|
||||||
# street3CBChance,
|
|
||||||
# street3CBDone,
|
|
||||||
# street4CBChance,
|
|
||||||
# street4CBDone,
|
|
||||||
# foldToStreet1CBChance,
|
# foldToStreet1CBChance,
|
||||||
# foldToStreet1CBDone,
|
# foldToStreet1CBDone,
|
||||||
# foldToStreet2CBChance,
|
# foldToStreet2CBChance,
|
||||||
|
@ -1663,6 +1672,15 @@ class Database:
|
||||||
# street4CheckCallRaiseChance,
|
# street4CheckCallRaiseChance,
|
||||||
# street4CheckCallRaiseDone)
|
# street4CheckCallRaiseDone)
|
||||||
|
|
||||||
|
def isDuplicate(self, gametypeID, siteHandNo):
|
||||||
|
dup = False
|
||||||
|
c = self.get_cursor()
|
||||||
|
c.execute(self.sql.query['isAlreadyInDB'], (gametypeID, siteHandNo))
|
||||||
|
result = c.fetchall()
|
||||||
|
if len(result) > 0:
|
||||||
|
dup = True
|
||||||
|
return dup
|
||||||
|
|
||||||
def getGameTypeId(self, siteid, game):
|
def getGameTypeId(self, siteid, game):
|
||||||
c = self.get_cursor()
|
c = self.get_cursor()
|
||||||
#FIXME: Fixed for NL at the moment
|
#FIXME: Fixed for NL at the moment
|
||||||
|
@ -1702,6 +1720,13 @@ class Database:
|
||||||
q = "SELECT name, id FROM Players WHERE siteid=%s and name=%s"
|
q = "SELECT name, id FROM Players WHERE siteid=%s and name=%s"
|
||||||
q = q.replace('%s', self.sql.query['placeholder'])
|
q = q.replace('%s', self.sql.query['placeholder'])
|
||||||
|
|
||||||
|
#NOTE/FIXME?: MySQL has ON DUPLICATE KEY UPDATE
|
||||||
|
#Usage:
|
||||||
|
# INSERT INTO `tags` (`tag`, `count`)
|
||||||
|
# VALUES ($tag, 1)
|
||||||
|
# ON DUPLICATE KEY UPDATE `count`=`count`+1;
|
||||||
|
|
||||||
|
|
||||||
#print "DEBUG: name: %s site: %s" %(name, site_id)
|
#print "DEBUG: name: %s site: %s" %(name, site_id)
|
||||||
|
|
||||||
c.execute (q, (site_id, name))
|
c.execute (q, (site_id, name))
|
||||||
|
|
|
@ -49,10 +49,14 @@ class DerivedStats():
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
self.handsplayers[player[1]]['street%dCalls' % i] = 0
|
self.handsplayers[player[1]]['street%dCalls' % i] = 0
|
||||||
self.handsplayers[player[1]]['street%dBets' % i] = 0
|
self.handsplayers[player[1]]['street%dBets' % i] = 0
|
||||||
|
for i in range(1,5):
|
||||||
|
self.handsplayers[player[1]]['street%dCBChance' %i] = False
|
||||||
|
self.handsplayers[player[1]]['street%dCBDone' %i] = False
|
||||||
|
|
||||||
self.assembleHands(self.hand)
|
self.assembleHands(self.hand)
|
||||||
self.assembleHandsPlayers(self.hand)
|
self.assembleHandsPlayers(self.hand)
|
||||||
|
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print "Hands:"
|
print "Hands:"
|
||||||
pp.pprint(self.hands)
|
pp.pprint(self.hands)
|
||||||
|
@ -137,6 +141,8 @@ class DerivedStats():
|
||||||
for player in hand.pot.committed:
|
for player in hand.pot.committed:
|
||||||
self.handsplayers[player]['totalProfit'] = int(self.handsplayers[player]['winnings'] - (100*hand.pot.committed[player]))
|
self.handsplayers[player]['totalProfit'] = int(self.handsplayers[player]['winnings'] - (100*hand.pot.committed[player]))
|
||||||
|
|
||||||
|
self.calcCBets(hand)
|
||||||
|
|
||||||
#default_holecards = ["Xx", "Xx", "Xx", "Xx"]
|
#default_holecards = ["Xx", "Xx", "Xx", "Xx"]
|
||||||
#if hand.gametype['base'] == "hold":
|
#if hand.gametype['base'] == "hold":
|
||||||
# pass
|
# pass
|
||||||
|
@ -221,6 +227,20 @@ class DerivedStats():
|
||||||
for (i, street) in enumerate(hand.actionStreets[1:]):
|
for (i, street) in enumerate(hand.actionStreets[1:]):
|
||||||
self.hands['street%dRaises' % i] = len(filter( lambda action: action[1] in ('raises','bets'), hand.actions[street]))
|
self.hands['street%dRaises' % i] = len(filter( lambda action: action[1] in ('raises','bets'), hand.actions[street]))
|
||||||
|
|
||||||
|
def calcCBets(self, hand):
|
||||||
|
# Continuation Bet chance, action:
|
||||||
|
# Had the last bet (initiative) on previous street, got called, close street action
|
||||||
|
# Then no bets before the player with initiatives first action on current street
|
||||||
|
# ie. if player on street-1 had initiative
|
||||||
|
# and no donkbets occurred
|
||||||
|
for i, street in enumerate(hand.actionStreets[2:], start=1):
|
||||||
|
name = self.lastBetOrRaiser(hand.actionStreets[i])
|
||||||
|
if name:
|
||||||
|
chance = self.noBetsBefore(hand.actionStreets[i+1], name)
|
||||||
|
self.handsplayers[name]['street%dCBChance' %i] = True
|
||||||
|
if chance == True:
|
||||||
|
self.handsplayers[name]['street%dCBDone' %i] = self.betStreet(hand.actionStreets[i+1], name)
|
||||||
|
|
||||||
def seen(self, hand, i):
|
def seen(self, hand, i):
|
||||||
pas = set()
|
pas = set()
|
||||||
for act in hand.actions[hand.actionStreets[i+1]]:
|
for act in hand.actions[hand.actionStreets[i+1]]:
|
||||||
|
@ -273,3 +293,35 @@ class DerivedStats():
|
||||||
if f is not None and action[1] in f: continue
|
if f is not None and action[1] in f: continue
|
||||||
players.add(action[0])
|
players.add(action[0])
|
||||||
return players
|
return players
|
||||||
|
|
||||||
|
def noBetsBefore(self, street, player):
|
||||||
|
"""Returns true if there were no bets before the specified players turn, false otherwise"""
|
||||||
|
betOrRaise = False
|
||||||
|
for act in self.hand.actions[street]:
|
||||||
|
#Must test for player first in case UTG
|
||||||
|
if act[0] == player:
|
||||||
|
betOrRaise = True
|
||||||
|
break
|
||||||
|
if act[1] in ('bets', 'raises'):
|
||||||
|
break
|
||||||
|
return betOrRaise
|
||||||
|
|
||||||
|
def betStreet(self, street, player):
|
||||||
|
"""Returns true if player bet/raised the street as their first action"""
|
||||||
|
betOrRaise = False
|
||||||
|
for act in self.hand.actions[street]:
|
||||||
|
if act[0] == player and act[1] in ('bets', 'raises'):
|
||||||
|
betOrRaise = True
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
return betOrRaise
|
||||||
|
|
||||||
|
|
||||||
|
def lastBetOrRaiser(self, street):
|
||||||
|
"""Returns player name that placed the last bet or raise for that street.
|
||||||
|
None if there were no bets or raises on that street"""
|
||||||
|
lastbet = None
|
||||||
|
for act in self.hand.actions[street]:
|
||||||
|
if act[1] in ('bets', 'raises'):
|
||||||
|
lastbet = act[0]
|
||||||
|
return lastbet
|
||||||
|
|
|
@ -210,23 +210,23 @@ db: a connected fpdb_db object"""
|
||||||
#####
|
#####
|
||||||
# End prep functions
|
# End prep functions
|
||||||
#####
|
#####
|
||||||
|
|
||||||
# HandsActions - all actions for all players for all streets - self.actions
|
|
||||||
# HudCache data can be generated from HandsActions (HandsPlayers?)
|
|
||||||
|
|
||||||
# Hands - Summary information of hand indexed by handId - gameinfo
|
|
||||||
hh = self.stats.getHands()
|
hh = self.stats.getHands()
|
||||||
|
|
||||||
|
if not db.isDuplicate(gtid, hh['siteHandNo']):
|
||||||
|
# Hands - Summary information of hand indexed by handId - gameinfo
|
||||||
hh['gameTypeId'] = gtid
|
hh['gameTypeId'] = gtid
|
||||||
# seats TINYINT NOT NULL,
|
# seats TINYINT NOT NULL,
|
||||||
hh['seats'] = len(sqlids)
|
hh['seats'] = len(sqlids)
|
||||||
|
|
||||||
#print hh
|
|
||||||
handid = db.storeHand(hh)
|
handid = db.storeHand(hh)
|
||||||
# HandsPlayers - ? ... Do we fix winnings?
|
|
||||||
db.storeHandsPlayers(handid, sqlids, self.stats.getHandsPlayers())
|
db.storeHandsPlayers(handid, sqlids, self.stats.getHandsPlayers())
|
||||||
|
# HandsActions - all actions for all players for all streets - self.actions
|
||||||
|
# HudCache data can be generated from HandsActions (HandsPlayers?)
|
||||||
# Tourneys ?
|
# Tourneys ?
|
||||||
# TourneysPlayers
|
# TourneysPlayers
|
||||||
|
else:
|
||||||
|
log.info("Hand.insert(): hid #: %s is a duplicate" % hh['siteHandNo'])
|
||||||
|
#Raise Duplicate exception?
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def select(self, handId):
|
def select(self, handId):
|
||||||
|
|
|
@ -64,5 +64,4 @@ def testSQLiteModFunction():
|
||||||
assert vars[idx]%13 == int(i[0])
|
assert vars[idx]%13 == int(i[0])
|
||||||
idx = idx+1
|
idx = idx+1
|
||||||
|
|
||||||
assert 0 == 1
|
|
||||||
cur.execute("DROP TABLE test")
|
cur.execute("DROP TABLE test")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user