Merge branch 'master' of git://git.assembla.com/fpdboz.git
This commit is contained in:
commit
677b0a5e35
|
@ -29,7 +29,7 @@ class Fulltilt(HandHistoryConverter):
|
||||||
|
|
||||||
sitename = "Fulltilt"
|
sitename = "Fulltilt"
|
||||||
filetype = "text"
|
filetype = "text"
|
||||||
codepage = "cp1252"
|
codepage = "utf-16"
|
||||||
siteId = 1 # Needs to match id entry in Sites database
|
siteId = 1 # Needs to match id entry in Sites database
|
||||||
|
|
||||||
# Static regexes
|
# Static regexes
|
||||||
|
@ -57,7 +57,7 @@ class Fulltilt(HandHistoryConverter):
|
||||||
(?:.*?\n(?P<CANCELLED>Hand\s\#(?P=HID)\shas\sbeen\scanceled))?
|
(?:.*?\n(?P<CANCELLED>Hand\s\#(?P=HID)\shas\sbeen\scanceled))?
|
||||||
''', re.VERBOSE|re.DOTALL)
|
''', re.VERBOSE|re.DOTALL)
|
||||||
re_Button = re.compile('^The button is in seat #(?P<BUTTON>\d+)', re.MULTILINE)
|
re_Button = re.compile('^The button is in seat #(?P<BUTTON>\d+)', re.MULTILINE)
|
||||||
re_PlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$?(?P<CASH>[,.0-9]+)\)$', re.MULTILINE)
|
re_PlayerInfo = re.compile('Seat (?P<SEAT>[0-9]+): (?P<PNAME>.*) \(\$?(?P<CASH>[,.0-9]+)\)', re.MULTILINE)
|
||||||
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
re_Board = re.compile(r"\[(?P<CARDS>.+)\]")
|
||||||
|
|
||||||
# These regexes are for FTP only
|
# These regexes are for FTP only
|
||||||
|
@ -67,6 +67,7 @@ class Fulltilt(HandHistoryConverter):
|
||||||
|
|
||||||
mixes = { 'HORSE': 'horse', '7-Game': '7game', 'HOSE': 'hose', 'HA': 'ha'}
|
mixes = { 'HORSE': 'horse', '7-Game': '7game', 'HOSE': 'hose', 'HA': 'ha'}
|
||||||
|
|
||||||
|
|
||||||
def compilePlayerRegexs(self, hand):
|
def compilePlayerRegexs(self, hand):
|
||||||
players = set([player[1] for player in hand.players])
|
players = set([player[1] for player in hand.players])
|
||||||
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
if not players <= self.compiledPlayers: # x <= y means 'x is subset of y'
|
||||||
|
@ -82,7 +83,7 @@ class Fulltilt(HandHistoryConverter):
|
||||||
self.re_HeroCards = re.compile(r"^Dealt to %s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % player_re, re.MULTILINE)
|
self.re_HeroCards = re.compile(r"^Dealt to %s(?: \[(?P<OLDCARDS>.+?)\])?( \[(?P<NEWCARDS>.+?)\])" % player_re, re.MULTILINE)
|
||||||
self.re_Action = re.compile(r"^%s(?P<ATYPE> bets| checks| raises to| completes it to| calls| folds)( \$?(?P<BET>[.,\d]+))?" % player_re, re.MULTILINE)
|
self.re_Action = re.compile(r"^%s(?P<ATYPE> bets| checks| raises to| completes it to| calls| folds)( \$?(?P<BET>[.,\d]+))?" % player_re, re.MULTILINE)
|
||||||
self.re_ShowdownAction = re.compile(r"^%s shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
self.re_ShowdownAction = re.compile(r"^%s shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
|
||||||
self.re_CollectPot = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$(?P<POT>[.\d]+)\)(, mucked| with.*)" % player_re, re.MULTILINE)
|
self.re_CollectPot = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s (\(button\) |\(small blind\) |\(big blind\) )?(collected|showed \[.*\] and won) \(\$?(?P<POT>[.,\d]+)\)(, mucked| with.*)" % player_re, re.MULTILINE)
|
||||||
self.re_SitsOut = re.compile(r"^%s sits out" % player_re, re.MULTILINE)
|
self.re_SitsOut = re.compile(r"^%s sits out" % player_re, re.MULTILINE)
|
||||||
self.re_ShownCards = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s \(.*\) showed \[(?P<CARDS>.*)\].*" % player_re, re.MULTILINE)
|
self.re_ShownCards = re.compile(r"^Seat (?P<SEAT>[0-9]+): %s \(.*\) showed \[(?P<CARDS>.*)\].*" % player_re, re.MULTILINE)
|
||||||
|
|
||||||
|
@ -136,24 +137,6 @@ class Fulltilt(HandHistoryConverter):
|
||||||
# if info['type'] == "tour": return None # importer is screwed on tournies, pass on those hands so we don't interrupt other autoimporting
|
# if info['type'] == "tour": return None # importer is screwed on tournies, pass on those hands so we don't interrupt other autoimporting
|
||||||
return info
|
return info
|
||||||
|
|
||||||
#Following function is a hack, we should be dealing with this in readFile (i think correct codepage....)
|
|
||||||
# Same function as parent class, removing the 2 end characters. - CG
|
|
||||||
def allHandsAsList(self):
|
|
||||||
"""Return a list of handtexts in the file at self.in_path"""
|
|
||||||
#TODO : any need for this to be generator? e.g. stars support can email one huge file of all hands in a year. Better to read bit by bit than all at once.
|
|
||||||
self.readFile()
|
|
||||||
|
|
||||||
# FIXME: it's a hack
|
|
||||||
if self.obs[:2] == u'\xff\xfe':
|
|
||||||
self.obs = self.obs[2:].replace('\x00', '')
|
|
||||||
|
|
||||||
self.obs = self.obs.strip()
|
|
||||||
self.obs = self.obs.replace('\r\n', '\n')
|
|
||||||
if self.obs == "" or self.obs == None:
|
|
||||||
logging.info("Read no hands.")
|
|
||||||
return []
|
|
||||||
return re.split(self.re_SplitHands, self.obs)
|
|
||||||
|
|
||||||
def readHandInfo(self, hand):
|
def readHandInfo(self, hand):
|
||||||
m = self.re_HandInfo.search(hand.handText)
|
m = self.re_HandInfo.search(hand.handText)
|
||||||
if(m == None):
|
if(m == None):
|
||||||
|
@ -176,6 +159,16 @@ class Fulltilt(HandHistoryConverter):
|
||||||
hand.gametype['currency'] = 'play'
|
hand.gametype['currency'] = 'play'
|
||||||
|
|
||||||
# TODO: if there's a way to figure these out, we should.. otherwise we have to stuff it with unknowns
|
# TODO: if there's a way to figure these out, we should.. otherwise we have to stuff it with unknowns
|
||||||
|
re_SNGBuyInFee = re.compile('''(?P<CURRENCY>\$)?(?P<BUYIN>[.0-9]+) \+ \$?(?P<FEE>[.0-9]+) (?P<EXTRA_INFO>[\sA-Za-z&()]+)?''')
|
||||||
|
# TO DO : See if important info can be retrieved from EXTRA_INFO (sould be things like Turbo, Matrix, KO, ...)
|
||||||
|
try:
|
||||||
|
n = re_SNGBuyInFee.search(m.group('TOURNAMENT'))
|
||||||
|
#print "cur %s BUYIN %s FEE %s EXTRA %s" %(n.group('CURRENCY'), n.group('BUYIN'), n.group('FEE'), n.group('EXTRA_INFO'))
|
||||||
|
hand.buyin = "%s%s+%s%s" %(n.group('CURRENCY'), n.group('BUYIN'), n.group('CURRENCY'), n.group('FEE'))
|
||||||
|
except:
|
||||||
|
#print "Unable to collect BuyIn/Fee Info"
|
||||||
|
logging.info("Unable to collect BuyIn/Fee Info from HandInfo")
|
||||||
|
|
||||||
if hand.buyin == None:
|
if hand.buyin == None:
|
||||||
hand.buyin = "$0.00+$0.00"
|
hand.buyin = "$0.00+$0.00"
|
||||||
if hand.level == None:
|
if hand.level == None:
|
||||||
|
@ -319,7 +312,7 @@ class Fulltilt(HandHistoryConverter):
|
||||||
|
|
||||||
def readCollectPot(self,hand):
|
def readCollectPot(self,hand):
|
||||||
for m in self.re_CollectPot.finditer(hand.handText):
|
for m in self.re_CollectPot.finditer(hand.handText):
|
||||||
hand.addCollectPot(player=m.group('PNAME'),pot=m.group('POT'))
|
hand.addCollectPot(player=m.group('PNAME'),pot=re.sub(u',',u'',m.group('POT')))
|
||||||
|
|
||||||
def readShownCards(self,hand):
|
def readShownCards(self,hand):
|
||||||
for m in self.re_ShownCards.finditer(hand.handText):
|
for m in self.re_ShownCards.finditer(hand.handText):
|
||||||
|
|
162
pyfpdb/Hand.py
162
pyfpdb/Hand.py
|
@ -4,12 +4,12 @@
|
||||||
#This program is free software: you can redistribute it and/or modify
|
#This program is free software: you can redistribute it and/or modify
|
||||||
#it under the terms of the GNU Affero General Public License as published by
|
#it under the terms of the GNU Affero General Public License as published by
|
||||||
#the Free Software Foundation, version 3 of the License.
|
#the Free Software Foundation, version 3 of the License.
|
||||||
#
|
#
|
||||||
#This program is distributed in the hope that it will be useful,
|
#This program is distributed in the hope that it will be useful,
|
||||||
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
#GNU General Public License for more details.
|
#GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
#You should have received a copy of the GNU Affero General Public License
|
#You should have received a copy of the GNU Affero General Public License
|
||||||
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#In the "official" distribution you can find the license in
|
#In the "official" distribution you can find the license in
|
||||||
|
@ -120,7 +120,7 @@ class Hand(object):
|
||||||
("MIXED", self.mixed),
|
("MIXED", self.mixed),
|
||||||
("LASTBET", self.lastBet),
|
("LASTBET", self.lastBet),
|
||||||
("ACTION STREETS", self.actionStreets),
|
("ACTION STREETS", self.actionStreets),
|
||||||
("STREETS", self.streets),
|
("STREETS", self.streets),
|
||||||
("ALL STREETS", self.allStreets),
|
("ALL STREETS", self.allStreets),
|
||||||
("COMMUNITY STREETS", self.communityStreets),
|
("COMMUNITY STREETS", self.communityStreets),
|
||||||
("HOLE STREETS", self.holeStreets),
|
("HOLE STREETS", self.holeStreets),
|
||||||
|
@ -133,7 +133,7 @@ class Hand(object):
|
||||||
("RAKE", self.rake),
|
("RAKE", self.rake),
|
||||||
("START TIME", self.starttime),
|
("START TIME", self.starttime),
|
||||||
)
|
)
|
||||||
|
|
||||||
structs = ( ("PLAYERS", self.players),
|
structs = ( ("PLAYERS", self.players),
|
||||||
("STACKS", self.stacks),
|
("STACKS", self.stacks),
|
||||||
("POSTED", self.posted),
|
("POSTED", self.posted),
|
||||||
|
@ -252,8 +252,8 @@ db: a connected fpdb_db object"""
|
||||||
|
|
||||||
def select(self, handId):
|
def select(self, handId):
|
||||||
""" Function to create Hand object from database """
|
""" Function to create Hand object from database """
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def addPlayer(self, seat, name, chips):
|
def addPlayer(self, seat, name, chips):
|
||||||
|
@ -302,14 +302,13 @@ If a player has None chips he won't be added."""
|
||||||
return c
|
return c
|
||||||
|
|
||||||
def addAnte(self, player, ante):
|
def addAnte(self, player, ante):
|
||||||
log.debug("%s %s antes %s" % ('ANTES', player, ante))
|
log.debug("%s %s antes %s" % ('BLINDSANTES', player, ante))
|
||||||
if player is not None:
|
if player is not None:
|
||||||
ante = re.sub(u',', u'', ante) #some sites have commas
|
ante = re.sub(u',', u'', ante) #some sites have commas
|
||||||
self.bets['ANTES'][player].append(Decimal(ante))
|
self.bets['BLINDSANTES'][player].append(Decimal(ante))
|
||||||
self.stacks[player] -= Decimal(ante)
|
self.stacks[player] -= Decimal(ante)
|
||||||
act = (player, 'posts', "ante", ante, self.stacks[player]==0)
|
act = (player, 'posts', "ante", ante, self.stacks[player]==0)
|
||||||
self.actions['ANTES'].append(act)
|
self.actions['BLINDSANTES'].append(act)
|
||||||
#~ self.lastBet['ANTES'] = Decimal(ante)
|
|
||||||
self.pot.addMoney(player, Decimal(ante))
|
self.pot.addMoney(player, Decimal(ante))
|
||||||
|
|
||||||
def addBlind(self, player, blindtype, amount):
|
def addBlind(self, player, blindtype, amount):
|
||||||
|
@ -324,19 +323,19 @@ If a player has None chips he won't be added."""
|
||||||
log.debug("addBlind: %s posts %s, %s" % (player, blindtype, amount))
|
log.debug("addBlind: %s posts %s, %s" % (player, blindtype, amount))
|
||||||
if player is not None:
|
if player is not None:
|
||||||
amount = re.sub(u',', u'', amount) #some sites have commas
|
amount = re.sub(u',', u'', amount) #some sites have commas
|
||||||
self.bets['PREFLOP'][player].append(Decimal(amount))
|
|
||||||
self.stacks[player] -= Decimal(amount)
|
self.stacks[player] -= Decimal(amount)
|
||||||
#print "DEBUG %s posts, stack %s" % (player, self.stacks[player])
|
|
||||||
act = (player, 'posts', blindtype, amount, self.stacks[player]==0)
|
act = (player, 'posts', blindtype, amount, self.stacks[player]==0)
|
||||||
self.actions['BLINDSANTES'].append(act)
|
self.actions['BLINDSANTES'].append(act)
|
||||||
|
|
||||||
|
if blindtype == 'both':
|
||||||
|
amount = self.bb
|
||||||
|
self.bets['BLINDSANTES'][player].append(Decimal(self.sb))
|
||||||
|
self.pot.addCommonMoney(Decimal(self.sb))
|
||||||
|
|
||||||
|
self.bets['PREFLOP'][player].append(Decimal(amount))
|
||||||
self.pot.addMoney(player, Decimal(amount))
|
self.pot.addMoney(player, Decimal(amount))
|
||||||
if blindtype == 'big blind':
|
self.lastBet['PREFLOP'] = Decimal(amount)
|
||||||
self.lastBet['PREFLOP'] = Decimal(amount)
|
|
||||||
elif blindtype == 'both':
|
|
||||||
# extra small blind is 'dead'
|
|
||||||
self.lastBet['PREFLOP'] = Decimal(self.bb)
|
|
||||||
self.posted = self.posted + [[player,blindtype]]
|
self.posted = self.posted + [[player,blindtype]]
|
||||||
#print "DEBUG: self.posted: %s" %(self.posted)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -354,22 +353,22 @@ If a player has None chips he won't be added."""
|
||||||
act = (player, 'calls', amount, self.stacks[player]==0)
|
act = (player, 'calls', amount, self.stacks[player]==0)
|
||||||
self.actions[street].append(act)
|
self.actions[street].append(act)
|
||||||
self.pot.addMoney(player, Decimal(amount))
|
self.pot.addMoney(player, Decimal(amount))
|
||||||
|
|
||||||
def addRaiseBy(self, street, player, amountBy):
|
def addRaiseBy(self, street, player, amountBy):
|
||||||
"""\
|
"""\
|
||||||
Add a raise by amountBy on [street] by [player]
|
Add a raise by amountBy on [street] by [player]
|
||||||
"""
|
"""
|
||||||
#Given only the amount raised by, the amount of the raise can be calculated by
|
#Given only the amount raised by, the amount of the raise can be calculated by
|
||||||
# working out how much this player has already in the pot
|
# working out how much this player has already in the pot
|
||||||
# (which is the sum of self.bets[street][player])
|
# (which is the sum of self.bets[street][player])
|
||||||
# and how much he needs to call to match the previous player
|
# and how much he needs to call to match the previous player
|
||||||
# (which is tracked by self.lastBet)
|
# (which is tracked by self.lastBet)
|
||||||
# let Bp = previous bet
|
# let Bp = previous bet
|
||||||
# Bc = amount player has committed so far
|
# Bc = amount player has committed so far
|
||||||
# Rb = raise by
|
# Rb = raise by
|
||||||
# then: C = Bp - Bc (amount to call)
|
# then: C = Bp - Bc (amount to call)
|
||||||
# Rt = Bp + Rb (raise to)
|
# Rt = Bp + Rb (raise to)
|
||||||
#
|
#
|
||||||
amountBy = re.sub(u',', u'', amountBy) #some sites have commas
|
amountBy = re.sub(u',', u'', amountBy) #some sites have commas
|
||||||
self.checkPlayerExists(player)
|
self.checkPlayerExists(player)
|
||||||
Rb = Decimal(amountBy)
|
Rb = Decimal(amountBy)
|
||||||
|
@ -377,7 +376,7 @@ Add a raise by amountBy on [street] by [player]
|
||||||
Bc = reduce(operator.add, self.bets[street][player], 0)
|
Bc = reduce(operator.add, self.bets[street][player], 0)
|
||||||
C = Bp - Bc
|
C = Bp - Bc
|
||||||
Rt = Bp + Rb
|
Rt = Bp + Rb
|
||||||
|
|
||||||
self._addRaise(street, player, C, Rb, Rt)
|
self._addRaise(street, player, C, Rb, Rt)
|
||||||
#~ self.bets[street][player].append(C + Rb)
|
#~ self.bets[street][player].append(C + Rb)
|
||||||
#~ self.stacks[player] -= (C + Rb)
|
#~ self.stacks[player] -= (C + Rb)
|
||||||
|
@ -395,7 +394,7 @@ For sites which by "raises x" mean "calls and raises putting a total of x in the
|
||||||
C = Bp - Bc
|
C = Bp - Bc
|
||||||
Rb = CRb - C
|
Rb = CRb - C
|
||||||
Rt = Bp + Rb
|
Rt = Bp + Rb
|
||||||
|
|
||||||
self._addRaise(street, player, C, Rb, Rt)
|
self._addRaise(street, player, C, Rb, Rt)
|
||||||
|
|
||||||
def addRaiseTo(self, street, player, amountTo):
|
def addRaiseTo(self, street, player, amountTo):
|
||||||
|
@ -420,9 +419,9 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
self.actions[street].append(act)
|
self.actions[street].append(act)
|
||||||
self.lastBet[street] = Rt # TODO check this is correct
|
self.lastBet[street] = Rt # TODO check this is correct
|
||||||
self.pot.addMoney(player, C+Rb)
|
self.pot.addMoney(player, C+Rb)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def addBet(self, street, player, amount):
|
def addBet(self, street, player, amount):
|
||||||
log.debug("%s %s bets %s" %(street, player, amount))
|
log.debug("%s %s bets %s" %(street, player, amount))
|
||||||
amount = re.sub(u',', u'', amount) #some sites have commas
|
amount = re.sub(u',', u'', amount) #some sites have commas
|
||||||
|
@ -440,7 +439,7 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
self.checkPlayerExists(player)
|
self.checkPlayerExists(player)
|
||||||
act = (player, 'stands pat')
|
act = (player, 'stands pat')
|
||||||
self.actions[street].append(act)
|
self.actions[street].append(act)
|
||||||
|
|
||||||
|
|
||||||
def addFold(self, street, player):
|
def addFold(self, street, player):
|
||||||
log.debug("%s %s folds" % (street, player))
|
log.debug("%s %s folds" % (street, player))
|
||||||
|
@ -448,7 +447,7 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
self.folded.add(player)
|
self.folded.add(player)
|
||||||
self.pot.addFold(player)
|
self.pot.addFold(player)
|
||||||
self.actions[street].append((player, 'folds'))
|
self.actions[street].append((player, 'folds'))
|
||||||
|
|
||||||
|
|
||||||
def addCheck(self, street, player):
|
def addCheck(self, street, player):
|
||||||
#print "DEBUG: %s %s checked" % (street, player)
|
#print "DEBUG: %s %s checked" % (street, player)
|
||||||
|
@ -472,6 +471,7 @@ Add a raise on [street] by [player] to [amountTo]
|
||||||
For when a player shows cards for any reason (for showdown or out of choice).
|
For when a player shows cards for any reason (for showdown or out of choice).
|
||||||
Card ranks will be uppercased
|
Card ranks will be uppercased
|
||||||
"""
|
"""
|
||||||
|
import sys; sys.exit(1)
|
||||||
log.debug("addShownCards %s hole=%s all=%s" % (player, cards, holeandboard))
|
log.debug("addShownCards %s hole=%s all=%s" % (player, cards, holeandboard))
|
||||||
if cards is not None:
|
if cards is not None:
|
||||||
self.addHoleCards(cards,player,shown, mucked)
|
self.addHoleCards(cards,player,shown, mucked)
|
||||||
|
@ -482,7 +482,7 @@ Card ranks will be uppercased
|
||||||
|
|
||||||
def totalPot(self):
|
def totalPot(self):
|
||||||
"""If all bets and blinds have been added, totals up the total pot size"""
|
"""If all bets and blinds have been added, totals up the total pot size"""
|
||||||
|
|
||||||
# This gives us the total amount put in the pot
|
# This gives us the total amount put in the pot
|
||||||
if self.totalpot is None:
|
if self.totalpot is None:
|
||||||
self.pot.end()
|
self.pot.end()
|
||||||
|
@ -552,6 +552,8 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
||||||
return ("%s: posts big blind %s%s%s" %(act[0], self.sym, act[3], ' and is all-in' if act[4] else ''))
|
return ("%s: posts big blind %s%s%s" %(act[0], self.sym, act[3], ' and is all-in' if act[4] else ''))
|
||||||
elif(act[2] == "both"):
|
elif(act[2] == "both"):
|
||||||
return ("%s: posts small & big blinds %s%s%s" %(act[0], self.sym, act[3], ' and is all-in' if act[4] else ''))
|
return ("%s: posts small & big blinds %s%s%s" %(act[0], self.sym, act[3], ' and is all-in' if act[4] else ''))
|
||||||
|
elif(act[2] == "ante"):
|
||||||
|
return ("%s: posts the ante %s%s%s" %(act[0], self.sym, act[3], ' and is all-in' if act[4] else ''))
|
||||||
elif act[1] == 'bringin':
|
elif act[1] == 'bringin':
|
||||||
return ("%s: brings in for %s%s%s" %(act[0], self.sym, act[2], ' and is all-in' if act[3] else ''))
|
return ("%s: brings in for %s%s%s" %(act[0], self.sym, act[2], ' and is all-in' if act[3] else ''))
|
||||||
elif act[1] == 'discards':
|
elif act[1] == 'discards':
|
||||||
|
@ -569,14 +571,14 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
||||||
def writeGameLine(self):
|
def writeGameLine(self):
|
||||||
"""Return the first HH line for the current hand."""
|
"""Return the first HH line for the current hand."""
|
||||||
gs = "PokerStars Game #%s: " % self.handid
|
gs = "PokerStars Game #%s: " % self.handid
|
||||||
|
|
||||||
if self.tourNo != None and self.mixed != None: # mixed tournament
|
if self.tourNo != None and self.mixed != None: # mixed tournament
|
||||||
gs = gs + "Tournament #%s, %s %s (%s) - Level %s (%s) - " % (self.tourNo, self.buyin, self.MS[self.mixed], self.getGameTypeAsString(), self.level, self.getStakesAsString())
|
gs = gs + "Tournament #%s, %s %s (%s) - Level %s (%s) - " % (self.tourNo, self.buyin, self.MS[self.mixed], self.getGameTypeAsString(), self.level, self.getStakesAsString())
|
||||||
elif self.tourNo != None: # all other tournaments
|
elif self.tourNo != None: # all other tournaments
|
||||||
gs = gs + "Tournament #%s, %s %s - Level %s (%s) - " % (self.tourNo,
|
gs = gs + "Tournament #%s, %s %s - Level %s (%s) - " % (self.tourNo,
|
||||||
self.buyin, self.getGameTypeAsString(), self.level, self.getStakesAsString())
|
self.buyin, self.getGameTypeAsString(), self.level, self.getStakesAsString())
|
||||||
elif self.mixed != None: # all other mixed games
|
elif self.mixed != None: # all other mixed games
|
||||||
gs = gs + " %s (%s, %s) - " % (self.MS[self.mixed],
|
gs = gs + " %s (%s, %s) - " % (self.MS[self.mixed],
|
||||||
self.getGameTypeAsString(), self.getStakesAsString())
|
self.getGameTypeAsString(), self.getStakesAsString())
|
||||||
else: # non-mixed cash games
|
else: # non-mixed cash games
|
||||||
gs = gs + " %s (%s) - " % (self.getGameTypeAsString(), self.getStakesAsString())
|
gs = gs + " %s (%s) - " % (self.getGameTypeAsString(), self.getStakesAsString())
|
||||||
|
@ -595,8 +597,8 @@ Map the tuple self.gametype onto the pokerstars string describing it
|
||||||
|
|
||||||
def writeHand(self, fh=sys.__stdout__):
|
def writeHand(self, fh=sys.__stdout__):
|
||||||
# PokerStars format.
|
# PokerStars format.
|
||||||
print >>fh, self.writeGameLine()
|
print >>fh, self.writeGameLine()
|
||||||
print >>fh, self.writeTableLine()
|
print >>fh, self.writeTableLine()
|
||||||
|
|
||||||
|
|
||||||
class HoldemOmahaHand(Hand):
|
class HoldemOmahaHand(Hand):
|
||||||
|
@ -611,9 +613,9 @@ class HoldemOmahaHand(Hand):
|
||||||
Hand.__init__(self, sitename, gametype, handText, builtFrom = "HHC")
|
Hand.__init__(self, sitename, gametype, handText, builtFrom = "HHC")
|
||||||
self.sb = gametype['sb']
|
self.sb = gametype['sb']
|
||||||
self.bb = gametype['bb']
|
self.bb = gametype['bb']
|
||||||
|
|
||||||
#Populate a HoldemOmahaHand
|
#Populate a HoldemOmahaHand
|
||||||
#Generally, we call 'read' methods here, which get the info according to the particular filter (hhc)
|
#Generally, we call 'read' methods here, which get the info according to the particular filter (hhc)
|
||||||
# which then invokes a 'addXXX' callback
|
# which then invokes a 'addXXX' callback
|
||||||
if builtFrom == "HHC":
|
if builtFrom == "HHC":
|
||||||
hhc.readHandInfo(self)
|
hhc.readHandInfo(self)
|
||||||
|
@ -621,6 +623,7 @@ class HoldemOmahaHand(Hand):
|
||||||
hhc.compilePlayerRegexs(self)
|
hhc.compilePlayerRegexs(self)
|
||||||
hhc.markStreets(self)
|
hhc.markStreets(self)
|
||||||
hhc.readBlinds(self)
|
hhc.readBlinds(self)
|
||||||
|
hhc.readAntes(self)
|
||||||
hhc.readButton(self)
|
hhc.readButton(self)
|
||||||
hhc.readHeroCards(self)
|
hhc.readHeroCards(self)
|
||||||
hhc.readShowdownActions(self)
|
hhc.readShowdownActions(self)
|
||||||
|
@ -647,7 +650,7 @@ class HoldemOmahaHand(Hand):
|
||||||
else:
|
else:
|
||||||
log.warning("HoldemOmahaHand.__init__:Neither HHC nor DB+handid provided")
|
log.warning("HoldemOmahaHand.__init__:Neither HHC nor DB+handid provided")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False):
|
def addShownCards(self, cards, player, shown=True, mucked=False, dealt=False):
|
||||||
if player == self.hero: # we have hero's cards just update shown/mucked
|
if player == self.hero: # we have hero's cards just update shown/mucked
|
||||||
|
@ -702,7 +705,7 @@ class HoldemOmahaHand(Hand):
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
if street in self.actionStreets and self.actions[street]:
|
if street in self.actionStreets and self.actions[street]:
|
||||||
lines.append(
|
lines.append(
|
||||||
T.ol(class_='actions', data=self.actions[street], render=render_action) [
|
T.ol(class_='actions', data=self.actions[street], render=render_action) [
|
||||||
T.li(pattern='list_item')[ T.slot(name='action') ]
|
T.li(pattern='list_item')[ T.slot(name='action') ]
|
||||||
]
|
]
|
||||||
|
@ -736,8 +739,8 @@ class HoldemOmahaHand(Hand):
|
||||||
context.tag[ pat().fillSlots('action', x)]
|
context.tag[ pat().fillSlots('action', x)]
|
||||||
return context.tag
|
return context.tag
|
||||||
|
|
||||||
s = T.p[
|
s = T.p[
|
||||||
T.h1[
|
T.h1[
|
||||||
T.span(class_='site')["%s Game #%s]" % ('PokerStars', self.handid)],
|
T.span(class_='site')["%s Game #%s]" % ('PokerStars', self.handid)],
|
||||||
T.span(class_='type_limit')[ "%s ($%s/$%s)" %(self.getGameTypeAsString(), self.sb, self.bb) ],
|
T.span(class_='type_limit')[ "%s ($%s/$%s)" %(self.getGameTypeAsString(), self.sb, self.bb) ],
|
||||||
T.span(class_='date')[ datetime.datetime.strftime(self.starttime,'%Y/%m/%d - %H:%M:%S ET') ]
|
T.span(class_='date')[ datetime.datetime.strftime(self.starttime,'%Y/%m/%d - %H:%M:%S ET') ]
|
||||||
|
@ -763,7 +766,7 @@ class HoldemOmahaHand(Hand):
|
||||||
|
|
||||||
return str(tidy.parseString(flat.flatten(s), **options))
|
return str(tidy.parseString(flat.flatten(s), **options))
|
||||||
|
|
||||||
|
|
||||||
def writeHand(self, fh=sys.__stdout__):
|
def writeHand(self, fh=sys.__stdout__):
|
||||||
# PokerStars format.
|
# PokerStars format.
|
||||||
super(HoldemOmahaHand, self).writeHand(fh)
|
super(HoldemOmahaHand, self).writeHand(fh)
|
||||||
|
@ -777,7 +780,7 @@ class HoldemOmahaHand(Hand):
|
||||||
if self.actions['BLINDSANTES']:
|
if self.actions['BLINDSANTES']:
|
||||||
for act in self.actions['BLINDSANTES']:
|
for act in self.actions['BLINDSANTES']:
|
||||||
print >>fh, self.actionString(act)
|
print >>fh, self.actionString(act)
|
||||||
|
|
||||||
print >>fh, ("*** HOLE CARDS ***")
|
print >>fh, ("*** HOLE CARDS ***")
|
||||||
for player in self.dealt:
|
for player in self.dealt:
|
||||||
print >>fh, ("Dealt to %s [%s]" %(player, " ".join(self.holecards['PREFLOP'][player][1])))
|
print >>fh, ("Dealt to %s [%s]" %(player, " ".join(self.holecards['PREFLOP'][player][1])))
|
||||||
|
@ -823,7 +826,7 @@ class HoldemOmahaHand(Hand):
|
||||||
numOfHoleCardsNeeded = 2
|
numOfHoleCardsNeeded = 2
|
||||||
if len(self.holecards['PREFLOP'][name]) == numOfHoleCardsNeeded:
|
if len(self.holecards['PREFLOP'][name]) == numOfHoleCardsNeeded:
|
||||||
print >>fh, ("%s shows [%s] (a hand...)" % (name, " ".join(self.holecards['PREFLOP'][name][1])))
|
print >>fh, ("%s shows [%s] (a hand...)" % (name, " ".join(self.holecards['PREFLOP'][name][1])))
|
||||||
|
|
||||||
# Current PS format has the lines:
|
# Current PS format has the lines:
|
||||||
# Uncalled bet ($111.25) returned to s0rrow
|
# Uncalled bet ($111.25) returned to s0rrow
|
||||||
# s0rrow collected $5.15 from side pot
|
# s0rrow collected $5.15 from side pot
|
||||||
|
@ -865,7 +868,7 @@ class HoldemOmahaHand(Hand):
|
||||||
print >>fh, ("Seat %d: %s mucked" % (seatnum, name))
|
print >>fh, ("Seat %d: %s mucked" % (seatnum, name))
|
||||||
|
|
||||||
print >>fh, "\n\n"
|
print >>fh, "\n\n"
|
||||||
|
|
||||||
class DrawHand(Hand):
|
class DrawHand(Hand):
|
||||||
def __init__(self, hhc, sitename, gametype, handText, builtFrom = "HHC"):
|
def __init__(self, hhc, sitename, gametype, handText, builtFrom = "HHC"):
|
||||||
if gametype['base'] != 'draw':
|
if gametype['base'] != 'draw':
|
||||||
|
@ -885,6 +888,7 @@ class DrawHand(Hand):
|
||||||
hhc.compilePlayerRegexs(self)
|
hhc.compilePlayerRegexs(self)
|
||||||
hhc.markStreets(self)
|
hhc.markStreets(self)
|
||||||
hhc.readBlinds(self)
|
hhc.readBlinds(self)
|
||||||
|
hhc.readAntes(self)
|
||||||
hhc.readButton(self)
|
hhc.readButton(self)
|
||||||
hhc.readHeroCards(self)
|
hhc.readHeroCards(self)
|
||||||
hhc.readShowdownActions(self)
|
hhc.readShowdownActions(self)
|
||||||
|
@ -911,8 +915,8 @@ class DrawHand(Hand):
|
||||||
# - this is a bet of 1 sb, as yet uncalled.
|
# - this is a bet of 1 sb, as yet uncalled.
|
||||||
# Player in the big blind posts
|
# Player in the big blind posts
|
||||||
# - this is a call of 1 sb and a raise to 1 bb
|
# - this is a call of 1 sb and a raise to 1 bb
|
||||||
#
|
#
|
||||||
|
|
||||||
log.debug("addBlind: %s posts %s, %s" % (player, blindtype, amount))
|
log.debug("addBlind: %s posts %s, %s" % (player, blindtype, amount))
|
||||||
if player is not None:
|
if player is not None:
|
||||||
self.bets['DEAL'][player].append(Decimal(amount))
|
self.bets['DEAL'][player].append(Decimal(amount))
|
||||||
|
@ -922,7 +926,7 @@ class DrawHand(Hand):
|
||||||
self.actions['BLINDSANTES'].append(act)
|
self.actions['BLINDSANTES'].append(act)
|
||||||
self.pot.addMoney(player, Decimal(amount))
|
self.pot.addMoney(player, Decimal(amount))
|
||||||
if blindtype == 'big blind':
|
if blindtype == 'big blind':
|
||||||
self.lastBet['DEAL'] = Decimal(amount)
|
self.lastBet['DEAL'] = Decimal(amount)
|
||||||
elif blindtype == 'both':
|
elif blindtype == 'both':
|
||||||
# extra small blind is 'dead'
|
# extra small blind is 'dead'
|
||||||
self.lastBet['DEAL'] = Decimal(self.bb)
|
self.lastBet['DEAL'] = Decimal(self.bb)
|
||||||
|
@ -1042,17 +1046,17 @@ class StudHand(Hand):
|
||||||
if gametype['base'] != 'stud':
|
if gametype['base'] != 'stud':
|
||||||
pass # or indeed don't pass and complain instead
|
pass # or indeed don't pass and complain instead
|
||||||
|
|
||||||
self.allStreets = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH']
|
self.allStreets = ['BLINDSANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH']
|
||||||
self.communityStreets = []
|
self.communityStreets = []
|
||||||
self.actionStreets = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH']
|
self.actionStreets = ['BLINDSANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH']
|
||||||
|
|
||||||
self.streetList = ['ANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH'] # a list of the observed street names in order
|
self.streetList = ['BLINDSANTES','THIRD','FOURTH','FIFTH','SIXTH','SEVENTH'] # a list of the observed street names in order
|
||||||
self.holeStreets = ['THIRD','FOURTH','FIFTH','SIXTH','SEVENTH']
|
self.holeStreets = ['THIRD','FOURTH','FIFTH','SIXTH','SEVENTH']
|
||||||
Hand.__init__(self, sitename, gametype, handText)
|
Hand.__init__(self, sitename, gametype, handText)
|
||||||
self.sb = gametype['sb']
|
self.sb = gametype['sb']
|
||||||
self.bb = gametype['bb']
|
self.bb = gametype['bb']
|
||||||
#Populate the StudHand
|
#Populate the StudHand
|
||||||
#Generally, we call a 'read' method here, which gets the info according to the particular filter (hhc)
|
#Generally, we call a 'read' method here, which gets the info according to the particular filter (hhc)
|
||||||
# which then invokes a 'addXXX' callback
|
# which then invokes a 'addXXX' callback
|
||||||
if builtFrom == "HHC":
|
if builtFrom == "HHC":
|
||||||
hhc.readHandInfo(self)
|
hhc.readHandInfo(self)
|
||||||
|
@ -1064,7 +1068,7 @@ class StudHand(Hand):
|
||||||
hhc.readHeroCards(self)
|
hhc.readHeroCards(self)
|
||||||
# Read actions in street order
|
# Read actions in street order
|
||||||
for street in self.actionStreets:
|
for street in self.actionStreets:
|
||||||
if street == 'ANTES': continue # OMG--sometime someone folds in the ante round
|
if street == 'BLINDSANTES': continue # OMG--sometime someone folds in the ante round
|
||||||
if self.streets[street]:
|
if self.streets[street]:
|
||||||
log.debug(street + self.streets[street])
|
log.debug(street + self.streets[street])
|
||||||
hhc.readAction(self, street)
|
hhc.readAction(self, street)
|
||||||
|
@ -1128,7 +1132,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
#~ self.actions[street].append(act)
|
#~ self.actions[street].append(act)
|
||||||
#~ self.lastBet[street] = Rt # TODO check this is correct
|
#~ self.lastBet[street] = Rt # TODO check this is correct
|
||||||
#~ self.pot.addMoney(player, C+Rb)
|
#~ self.pot.addMoney(player, C+Rb)
|
||||||
|
|
||||||
def addBringIn(self, player, bringin):
|
def addBringIn(self, player, bringin):
|
||||||
if player is not None:
|
if player is not None:
|
||||||
log.debug("Bringin: %s, %s" % (player , bringin))
|
log.debug("Bringin: %s, %s" % (player , bringin))
|
||||||
|
@ -1152,15 +1156,15 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
# PokerStars format.
|
# PokerStars format.
|
||||||
|
|
||||||
super(StudHand, self).writeHand(fh)
|
super(StudHand, self).writeHand(fh)
|
||||||
|
|
||||||
players_who_post_antes = set([x[0] for x in self.actions['ANTES']])
|
players_who_post_antes = set([x[0] for x in self.actions['BLINDSANTES']])
|
||||||
|
|
||||||
for player in [x for x in self.players if x[1] in players_who_post_antes]:
|
for player in [x for x in self.players if x[1] in players_who_post_antes]:
|
||||||
#Only print stacks of players who do something preflop
|
#Only print stacks of players who do something preflop
|
||||||
print >>fh, _("Seat %s: %s (%s%s in chips)" %(player[0], player[1], self.sym, player[2]))
|
print >>fh, _("Seat %s: %s (%s%s in chips)" %(player[0], player[1], self.sym, player[2]))
|
||||||
|
|
||||||
if 'ANTES' in self.actions:
|
if 'BLINDSANTES' in self.actions:
|
||||||
for act in self.actions['ANTES']:
|
for act in self.actions['BLINDSANTES']:
|
||||||
print >>fh, _("%s: posts the ante %s%s" %(act[0], self.sym, act[3]))
|
print >>fh, _("%s: posts the ante %s%s" %(act[0], self.sym, act[3]))
|
||||||
|
|
||||||
if 'THIRD' in self.actions:
|
if 'THIRD' in self.actions:
|
||||||
|
@ -1283,7 +1287,7 @@ Add a complete on [street] by [player] to [amountTo]
|
||||||
else:
|
else:
|
||||||
return hc + " ".join(self.holecards[street][player][0]) + ']'
|
return hc + " ".join(self.holecards[street][player][0]) + ']'
|
||||||
|
|
||||||
if street == 'SEVENTH' and player != self.hero: return # only write 7th st line for hero, LDO
|
if street == 'SEVENTH' and player != self.hero: return # only write 7th st line for hero, LDO
|
||||||
return hc + " ".join(self.holecards[street][player][1]) + "] [" + " ".join(self.holecards[street][player][0]) + "]"
|
return hc + " ".join(self.holecards[street][player][1]) + "] [" + " ".join(self.holecards[street][player][0]) + "]"
|
||||||
|
|
||||||
def join_holecards(self, player):
|
def join_holecards(self, player):
|
||||||
|
@ -1308,27 +1312,31 @@ class Pot(object):
|
||||||
self.contenders = set()
|
self.contenders = set()
|
||||||
self.committed = {}
|
self.committed = {}
|
||||||
self.streettotals = {}
|
self.streettotals = {}
|
||||||
|
self.common = Decimal(0)
|
||||||
self.total = None
|
self.total = None
|
||||||
self.returned = {}
|
self.returned = {}
|
||||||
self.sym = u'$' # this is the default currency symbol
|
self.sym = u'$' # this is the default currency symbol
|
||||||
|
|
||||||
def setSym(self, sym):
|
def setSym(self, sym):
|
||||||
self.sym = sym
|
self.sym = sym
|
||||||
|
|
||||||
def addPlayer(self,player):
|
def addPlayer(self,player):
|
||||||
self.committed[player] = Decimal(0)
|
self.committed[player] = Decimal(0)
|
||||||
|
|
||||||
def addFold(self, player):
|
def addFold(self, player):
|
||||||
# addFold must be called when a player folds
|
# addFold must be called when a player folds
|
||||||
self.contenders.discard(player)
|
self.contenders.discard(player)
|
||||||
|
|
||||||
|
def addCommonMoney(self, amount):
|
||||||
|
self.common += amount
|
||||||
|
|
||||||
def addMoney(self, player, amount):
|
def addMoney(self, player, amount):
|
||||||
# addMoney must be called for any actions that put money in the pot, in the order they occur
|
# addMoney must be called for any actions that put money in the pot, in the order they occur
|
||||||
self.contenders.add(player)
|
self.contenders.add(player)
|
||||||
self.committed[player] += amount
|
self.committed[player] += amount
|
||||||
|
|
||||||
def markTotal(self, street):
|
def markTotal(self, street):
|
||||||
self.streettotals[street] = sum(self.committed.values())
|
self.streettotals[street] = sum(self.committed.values()) + self.common
|
||||||
|
|
||||||
def getTotalAtStreet(self, street):
|
def getTotalAtStreet(self, street):
|
||||||
if street in self.streettotals:
|
if street in self.streettotals:
|
||||||
|
@ -1336,8 +1344,8 @@ class Pot(object):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def end(self):
|
def end(self):
|
||||||
self.total = sum(self.committed.values())
|
self.total = sum(self.committed.values()) + self.common
|
||||||
|
|
||||||
# Return any uncalled bet.
|
# Return any uncalled bet.
|
||||||
committed = sorted([ (v,k) for (k,v) in self.committed.items()])
|
committed = sorted([ (v,k) for (k,v) in self.committed.items()])
|
||||||
lastbet = committed[-1][0] - committed[-2][0]
|
lastbet = committed[-1][0] - committed[-2][0]
|
||||||
|
@ -1355,7 +1363,7 @@ class Pot(object):
|
||||||
self.pots = []
|
self.pots = []
|
||||||
while len(commitsall) > 0:
|
while len(commitsall) > 0:
|
||||||
commitslive = [(v,k) for (v,k) in commitsall if k in self.contenders]
|
commitslive = [(v,k) for (v,k) in commitsall if k in self.contenders]
|
||||||
v1 = commitslive[0][0]
|
v1 = commitslive[0][0]
|
||||||
self.pots += [sum([min(v,v1) for (v,k) in commitsall])]
|
self.pots += [sum([min(v,v1) for (v,k) in commitsall])]
|
||||||
commitsall = [((v-v1),k) for (v,k) in commitsall if v-v1 >0]
|
commitsall = [((v-v1),k) for (v,k) in commitsall if v-v1 >0]
|
||||||
|
|
||||||
|
@ -1365,7 +1373,7 @@ class Pot(object):
|
||||||
# and y+z+r = x
|
# and y+z+r = x
|
||||||
# for example:
|
# for example:
|
||||||
# Total pot $124.30 Main pot $98.90. Side pot $23.40. | Rake $2
|
# Total pot $124.30 Main pot $98.90. Side pot $23.40. | Rake $2
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.sym is None:
|
if self.sym is None:
|
||||||
self.sym = "C"
|
self.sym = "C"
|
||||||
|
@ -1373,17 +1381,17 @@ class Pot(object):
|
||||||
print "call Pot.end() before printing pot total"
|
print "call Pot.end() before printing pot total"
|
||||||
# NB if I'm sure end() is idempotent, call it here.
|
# NB if I'm sure end() is idempotent, call it here.
|
||||||
raise FpdbParseError
|
raise FpdbParseError
|
||||||
|
|
||||||
ret = "Total pot %s%.2f" % (self.sym, self.total)
|
ret = "Total pot %s%.2f" % (self.sym, self.total)
|
||||||
if len(self.pots) < 2:
|
if len(self.pots) < 2:
|
||||||
return ret;
|
return ret;
|
||||||
ret += " Main pot %s%.2f" % (self.sym, self.pots[0])
|
ret += " Main pot %s%.2f" % (self.sym, self.pots[0])
|
||||||
|
|
||||||
return ret + ''.join([ (" Side pot %s%.2f." % (self.sym, self.pots[x]) ) for x in xrange(1, len(self.pots)) ])
|
return ret + ''.join([ (" Side pot %s%.2f." % (self.sym, self.pots[x]) ) for x in xrange(1, len(self.pots)) ])
|
||||||
|
|
||||||
def assemble(cnxn, handid):
|
def assemble(cnxn, handid):
|
||||||
c = cnxn.cursor()
|
c = cnxn.cursor()
|
||||||
|
|
||||||
# We need at least sitename, gametype, handid
|
# We need at least sitename, gametype, handid
|
||||||
# for the Hand.__init__
|
# for the Hand.__init__
|
||||||
c.execute("""
|
c.execute("""
|
||||||
|
@ -1426,10 +1434,10 @@ limit 1""", {'handid':handid})
|
||||||
h.setCommunityCards('FLOP', cards[0:3])
|
h.setCommunityCards('FLOP', cards[0:3])
|
||||||
if cards[3]:
|
if cards[3]:
|
||||||
h.setCommunityCards('TURN', [cards[3]])
|
h.setCommunityCards('TURN', [cards[3]])
|
||||||
if cards[4]:
|
if cards[4]:
|
||||||
h.setCommunityCards('RIVER', [cards[4]])
|
h.setCommunityCards('RIVER', [cards[4]])
|
||||||
#[Card.valueSuitFromCard(x) for x in cards]
|
#[Card.valueSuitFromCard(x) for x in cards]
|
||||||
|
|
||||||
# HandInfo : HID, TABLE
|
# HandInfo : HID, TABLE
|
||||||
# BUTTON - why is this treated specially in Hand?
|
# BUTTON - why is this treated specially in Hand?
|
||||||
# answer: it is written out in hand histories
|
# answer: it is written out in hand histories
|
||||||
|
@ -1447,7 +1455,7 @@ WHERE h.id = %(handid)s
|
||||||
h.handid = res[0]
|
h.handid = res[0]
|
||||||
h.tablename = res[1]
|
h.tablename = res[1]
|
||||||
h.starttime = res[2] # automatically a datetime
|
h.starttime = res[2] # automatically a datetime
|
||||||
|
|
||||||
# PlayerStacks
|
# PlayerStacks
|
||||||
c.execute("""
|
c.execute("""
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -1472,7 +1480,7 @@ and p.id = hp.playerid
|
||||||
h.addCollectPot(name, winnings)
|
h.addCollectPot(name, winnings)
|
||||||
if position == 'B':
|
if position == 'B':
|
||||||
h.buttonpos = seat
|
h.buttonpos = seat
|
||||||
|
|
||||||
|
|
||||||
# actions
|
# actions
|
||||||
c.execute("""
|
c.execute("""
|
||||||
|
@ -1520,7 +1528,7 @@ ORDER BY
|
||||||
#hc.readShownCards(self)
|
#hc.readShownCards(self)
|
||||||
h.totalPot()
|
h.totalPot()
|
||||||
h.rake = h.totalpot - h.totalcollected
|
h.rake = h.totalpot - h.totalcollected
|
||||||
|
|
||||||
|
|
||||||
return h
|
return h
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,11 @@ class Hud:
|
||||||
for i, w in enumerate(self.stat_windows.itervalues()):
|
for i, w in enumerate(self.stat_windows.itervalues()):
|
||||||
(x, y) = loc[adj[i+1]]
|
(x, y) = loc[adj[i+1]]
|
||||||
w.relocate(x, y)
|
w.relocate(x, y)
|
||||||
|
|
||||||
|
# While we're at it, fix the positions of mucked cards too
|
||||||
|
for aux in self.aux_windows:
|
||||||
|
aux.update_card_positions()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def on_button_press(self, widget, event):
|
def on_button_press(self, widget, event):
|
||||||
|
@ -235,6 +240,7 @@ class Hud:
|
||||||
self.aux_windows = []
|
self.aux_windows = []
|
||||||
|
|
||||||
def reposition_windows(self, *args):
|
def reposition_windows(self, *args):
|
||||||
|
self.update_table_position()
|
||||||
for w in self.stat_windows.itervalues():
|
for w in self.stat_windows.itervalues():
|
||||||
if type(w) == int:
|
if type(w) == int:
|
||||||
# print "in reposition, w =", w
|
# print "in reposition, w =", w
|
||||||
|
|
|
@ -345,6 +345,22 @@ class Aux_Seats(Aux_Window):
|
||||||
def create_contents(self): pass
|
def create_contents(self): pass
|
||||||
def update_contents(self): pass
|
def update_contents(self): pass
|
||||||
|
|
||||||
|
def update_card_positions(self):
|
||||||
|
# self.adj does not exist until .create() has been run
|
||||||
|
try:
|
||||||
|
adj = self.adj
|
||||||
|
except AttributeError:
|
||||||
|
return
|
||||||
|
loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max))
|
||||||
|
for i in (range(1, self.hud.max + 1) + ['common']):
|
||||||
|
if i == 'common':
|
||||||
|
(x, y) = self.params['layout'][self.hud.max].common
|
||||||
|
else:
|
||||||
|
(x, y) = loc[adj[i]]
|
||||||
|
self.positions[i] = self.card_positions(x, self.hud.table.x, y, self.hud.table.y)
|
||||||
|
self.m_windows[i].move(self.positions[i][0], self.positions[i][1])
|
||||||
|
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
self.adj = self.hud.adj_seats(0, self.config) # move adj_seats to aux and get rid of it in Hud.py
|
self.adj = self.hud.adj_seats(0, self.config) # move adj_seats to aux and get rid of it in Hud.py
|
||||||
loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max))
|
loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max))
|
||||||
|
@ -362,7 +378,7 @@ class Aux_Seats(Aux_Window):
|
||||||
self.m_windows[i].set_transient_for(self.hud.main_window)
|
self.m_windows[i].set_transient_for(self.hud.main_window)
|
||||||
self.m_windows[i].set_focus_on_map(False)
|
self.m_windows[i].set_focus_on_map(False)
|
||||||
self.m_windows[i].connect("configure_event", self.configure_event_cb, i)
|
self.m_windows[i].connect("configure_event", self.configure_event_cb, i)
|
||||||
self.positions[i] = (int(x) + self.hud.table.x, int(y) + self.hud.table.y)
|
self.positions[i] = self.card_positions(x, self.hud.table.x, y, self.hud.table.y)
|
||||||
self.m_windows[i].move(self.positions[i][0], self.positions[i][1])
|
self.m_windows[i].move(self.positions[i][0], self.positions[i][1])
|
||||||
if self.params.has_key('opacity'):
|
if self.params.has_key('opacity'):
|
||||||
self.m_windows[i].set_opacity(float(self.params['opacity']))
|
self.m_windows[i].set_opacity(float(self.params['opacity']))
|
||||||
|
@ -374,6 +390,13 @@ class Aux_Seats(Aux_Window):
|
||||||
if self.uses_timer:
|
if self.uses_timer:
|
||||||
self.m_windows[i].hide()
|
self.m_windows[i].hide()
|
||||||
|
|
||||||
|
|
||||||
|
def card_positions(self, x, table_x, y, table_y):
|
||||||
|
_x = int(x) + int(table_x)
|
||||||
|
_y = int(y) + int(table_y)
|
||||||
|
return (_x, _y)
|
||||||
|
|
||||||
|
|
||||||
def update_gui(self, new_hand_id):
|
def update_gui(self, new_hand_id):
|
||||||
"""Update the gui, LDO."""
|
"""Update the gui, LDO."""
|
||||||
for i in self.m_windows.keys():
|
for i in self.m_windows.keys():
|
||||||
|
|
|
@ -1587,6 +1587,9 @@ class Sql:
|
||||||
# used in GuiPlayerStats:
|
# used in GuiPlayerStats:
|
||||||
self.query['getPlayerId'] = """SELECT id from Players where name = %s"""
|
self.query['getPlayerId'] = """SELECT id from Players where name = %s"""
|
||||||
|
|
||||||
|
self.query['getPlayerIdBySite'] = """SELECT id from Players where name = %s AND siteId = %s"""
|
||||||
|
|
||||||
|
|
||||||
# used in Filters:
|
# used in Filters:
|
||||||
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
|
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
|
||||||
self.query['getGames'] = """SELECT DISTINCT category from Gametypes"""
|
self.query['getGames'] = """SELECT DISTINCT category from Gametypes"""
|
||||||
|
|
|
@ -39,6 +39,7 @@ if os.name == 'nt':
|
||||||
|
|
||||||
# FreePokerTools modules
|
# FreePokerTools modules
|
||||||
import Configuration
|
import Configuration
|
||||||
|
from fpdb_simple import LOCALE_ENCODING
|
||||||
|
|
||||||
# Each TableWindow object must have the following attributes correctly populated:
|
# Each TableWindow object must have the following attributes correctly populated:
|
||||||
# tw.name = the table name from the title bar, which must to match the table name
|
# tw.name = the table name from the title bar, which must to match the table name
|
||||||
|
@ -230,20 +231,13 @@ def discover_nt_by_name(c, tablename):
|
||||||
"""Finds poker client window with the given table name."""
|
"""Finds poker client window with the given table name."""
|
||||||
titles = {}
|
titles = {}
|
||||||
win32gui.EnumWindows(win_enum_handler, titles)
|
win32gui.EnumWindows(win_enum_handler, titles)
|
||||||
|
|
||||||
def getDefaultEncoding():
|
|
||||||
# FIXME: if somebody know better place fot this function - move it
|
|
||||||
# FIXME: it's better to use GetCPInfo for windows http://msdn.microsoft.com/en-us/library/dd318078(VS.85).aspx
|
|
||||||
# but i have no idea, how to call it
|
|
||||||
import locale
|
|
||||||
return locale.getpreferredencoding()
|
|
||||||
|
|
||||||
for hwnd in titles:
|
for hwnd in titles:
|
||||||
#print "Tables.py: tablename =", tablename, "title =", titles[hwnd]
|
#print "Tables.py: tablename =", tablename, "title =", titles[hwnd]
|
||||||
try:
|
try:
|
||||||
# maybe it's better to make global titles[hwnd] decoding?
|
# maybe it's better to make global titles[hwnd] decoding?
|
||||||
# this can blow up in XP on some windows, eg firefox displaying http://docs.python.org/tutorial/classes.html
|
# this can blow up in XP on some windows, eg firefox displaying http://docs.python.org/tutorial/classes.html
|
||||||
if not tablename.lower() in titles[hwnd].decode(getDefaultEncoding()).lower(): continue
|
if not tablename.lower() in titles[hwnd].decode(LOCALE_ENCODING).lower(): continue
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
if 'History for table:' in titles[hwnd]: continue # Everleaf Network HH viewer window
|
if 'History for table:' in titles[hwnd]: continue # Everleaf Network HH viewer window
|
||||||
|
|
|
@ -380,8 +380,9 @@ class Importer:
|
||||||
conv = None
|
conv = None
|
||||||
(stored, duplicates, partial, errors, ttime) = (0, 0, 0, 0, 0)
|
(stored, duplicates, partial, errors, ttime) = (0, 0, 0, 0, 0)
|
||||||
|
|
||||||
|
file = file.decode(fpdb_simple.LOCALE_ENCODING)
|
||||||
|
|
||||||
# Load filter, process file, pass returned filename to import_fpdb_file
|
# Load filter, process file, pass returned filename to import_fpdb_file
|
||||||
|
|
||||||
if self.settings['threads'] > 0 and self.writeq != None:
|
if self.settings['threads'] > 0 and self.writeq != None:
|
||||||
print "\nConverting " + file + " (" + str(q.qsize()) + ")"
|
print "\nConverting " + file + " (" + str(q.qsize()) + ")"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -38,7 +38,7 @@ MYSQL_INNODB = 2
|
||||||
PGSQL = 3
|
PGSQL = 3
|
||||||
SQLITE = 4
|
SQLITE = 4
|
||||||
|
|
||||||
(localename, encoding) = locale.getdefaultlocale()
|
LOCALE_ENCODING = locale.getdefaultlocale()[1]
|
||||||
|
|
||||||
class DuplicateError(Exception):
|
class DuplicateError(Exception):
|
||||||
def __init__(self, value):
|
def __init__(self, value):
|
||||||
|
@ -51,7 +51,7 @@ class FpdbError(Exception):
|
||||||
self.value = value
|
self.value = value
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self.value)
|
return repr(self.value)
|
||||||
|
|
||||||
#returns an array of the total money paid. intending to add rebuys/addons here
|
#returns an array of the total money paid. intending to add rebuys/addons here
|
||||||
def calcPayin(count, buyin, fee):
|
def calcPayin(count, buyin, fee):
|
||||||
return [buyin + fee for i in xrange(count)]
|
return [buyin + fee for i in xrange(count)]
|
||||||
|
@ -546,7 +546,7 @@ def parseActionType(line):
|
||||||
#parses the ante out of the given line and checks which player paid it, updates antes accordingly.
|
#parses the ante out of the given line and checks which player paid it, updates antes accordingly.
|
||||||
def parseAnteLine(line, isTourney, names, antes):
|
def parseAnteLine(line, isTourney, names, antes):
|
||||||
for i, name in enumerate(names):
|
for i, name in enumerate(names):
|
||||||
if line.startswith(name.encode(encoding)):
|
if line.startswith(name.encode(LOCALE_ENCODING)):
|
||||||
pos = line.rfind("$") + 1
|
pos = line.rfind("$") + 1
|
||||||
if not isTourney:
|
if not isTourney:
|
||||||
antes[i] += float2int(line[pos:])
|
antes[i] += float2int(line[pos:])
|
||||||
|
@ -708,7 +708,7 @@ def parseHandStartTime(topline):
|
||||||
def findName(line):
|
def findName(line):
|
||||||
pos1 = line.find(":") + 2
|
pos1 = line.find(":") + 2
|
||||||
pos2 = line.rfind("(") - 1
|
pos2 = line.rfind("(") - 1
|
||||||
return unicode(line[pos1:pos2], encoding)
|
return unicode(line[pos1:pos2], LOCALE_ENCODING)
|
||||||
|
|
||||||
def parseNames(lines):
|
def parseNames(lines):
|
||||||
return [findName(line) for line in lines]
|
return [findName(line) for line in lines]
|
||||||
|
@ -825,7 +825,7 @@ def parseTourneyNo(topline):
|
||||||
def parseWinLine(line, names, winnings, isTourney):
|
def parseWinLine(line, names, winnings, isTourney):
|
||||||
#print "parseWinLine: line:",line
|
#print "parseWinLine: line:",line
|
||||||
for i,n in enumerate(names):
|
for i,n in enumerate(names):
|
||||||
n = n.encode(encoding)
|
n = n.encode(LOCALE_ENCODING)
|
||||||
if line.startswith(n):
|
if line.startswith(n):
|
||||||
if isTourney:
|
if isTourney:
|
||||||
pos1 = line.rfind("collected ") + 10
|
pos1 = line.rfind("collected ") + 10
|
||||||
|
@ -1035,14 +1035,15 @@ def recognisePlayerIDs(db, names, site_id):
|
||||||
def recognisePlayerNo(line, names, atype):
|
def recognisePlayerNo(line, names, atype):
|
||||||
#print "recogniseplayerno, names:",names
|
#print "recogniseplayerno, names:",names
|
||||||
for i in xrange(len(names)):
|
for i in xrange(len(names)):
|
||||||
|
encodedName = names[i].encode(LOCALE_ENCODING)
|
||||||
if (atype=="unbet"):
|
if (atype=="unbet"):
|
||||||
if (line.endswith(names[i].encode(encoding))):
|
if (line.endswith(encodedName)):
|
||||||
return (i)
|
return (i)
|
||||||
elif (line.startswith("Dealt to ")):
|
elif (line.startswith("Dealt to ")):
|
||||||
#print "recognisePlayerNo, card precut, line:",line
|
#print "recognisePlayerNo, card precut, line:",line
|
||||||
tmp=line[9:]
|
tmp=line[9:]
|
||||||
#print "recognisePlayerNo, card postcut, tmp:",tmp
|
#print "recognisePlayerNo, card postcut, tmp:",tmp
|
||||||
if (tmp.startswith(names[i].encode(encoding))):
|
if (tmp.startswith(encodedName)):
|
||||||
return (i)
|
return (i)
|
||||||
elif (line.startswith("Seat ")):
|
elif (line.startswith("Seat ")):
|
||||||
if (line.startswith("Seat 10")):
|
if (line.startswith("Seat 10")):
|
||||||
|
@ -1050,10 +1051,10 @@ def recognisePlayerNo(line, names, atype):
|
||||||
else:
|
else:
|
||||||
tmp=line[8:]
|
tmp=line[8:]
|
||||||
|
|
||||||
if (tmp.startswith(names[i].encode(encoding))):
|
if (tmp.startswith(encodedName)):
|
||||||
return (i)
|
return (i)
|
||||||
else:
|
else:
|
||||||
if (line.startswith(names[i].encode(encoding))):
|
if (line.startswith(encodedName)):
|
||||||
return (i)
|
return (i)
|
||||||
#if we're here we mustve failed
|
#if we're here we mustve failed
|
||||||
raise FpdbError ("failed to recognise player in: "+line+" atype:"+atype)
|
raise FpdbError ("failed to recognise player in: "+line+" atype:"+atype)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user