FTP: Make FTP use clearMoneyString()

FTP Summary files have a slightly different format than those written my the client.

Also convert all tourney string munging to clearMoneyString
This commit is contained in:
Worros 2010-12-20 14:25:58 +08:00
parent 0b02b05f67
commit c979c172d8

View File

@ -207,8 +207,8 @@ class Fulltilt(HandHistoryConverter):
info['limitType'] = 'cn' info['limitType'] = 'cn'
else: else:
info['limitType'] = limits[mg['LIMIT']] info['limitType'] = limits[mg['LIMIT']]
info['sb'] = mg['SB'] info['sb'] = self.clearMoneyString(mg['SB'])
info['bb'] = mg['BB'] info['bb'] = self.clearMoneyString(mg['BB'])
if mg['GAME'] is not None: if mg['GAME'] is not None:
(info['base'], info['category']) = games[mg['GAME']] (info['base'], info['category']) = games[mg['GAME']]
if mg['CURRENCY'] is not None: if mg['CURRENCY'] is not None:
@ -340,15 +340,15 @@ class Fulltilt(HandHistoryConverter):
def readBlinds(self, hand): def readBlinds(self, hand):
try: try:
m = self.re_PostSB.search(hand.handText) m = self.re_PostSB.search(hand.handText)
hand.addBlind(m.group('PNAME'), 'small blind', m.group('SB')) hand.addBlind(m.group('PNAME'), 'small blind', self.clearMoneyString(m.group('SB')))
except: # no small blind except: # no small blind
hand.addBlind(None, None, None) hand.addBlind(None, None, None)
for a in self.re_PostDead.finditer(hand.handText): for a in self.re_PostDead.finditer(hand.handText):
hand.addBlind(a.group('PNAME'), 'secondsb', a.group('SB')) hand.addBlind(a.group('PNAME'), 'secondsb', self.clearMoneyString(a.group('SB')))
for a in self.re_PostBB.finditer(hand.handText): for a in self.re_PostBB.finditer(hand.handText):
hand.addBlind(a.group('PNAME'), 'big blind', a.group('BB')) hand.addBlind(a.group('PNAME'), 'big blind', self.clearMoneyString(a.group('BB')))
for a in self.re_PostBoth.finditer(hand.handText): for a in self.re_PostBoth.finditer(hand.handText):
hand.addBlind(a.group('PNAME'), 'small & big blinds', a.group('SBBB')) hand.addBlind(a.group('PNAME'), 'small & big blinds', self.clearMoneyString(a.group('SBBB')))
def readAntes(self, hand): def readAntes(self, hand):
logging.debug(_("reading antes")) logging.debug(_("reading antes"))
@ -529,10 +529,10 @@ class Fulltilt(HandHistoryConverter):
# Additional info can be stored in the tourney object # Additional info can be stored in the tourney object
if mg['BUYIN'] is not None: if mg['BUYIN'] is not None:
tourney.buyin = 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN'])) tourney.buyin = 100*Decimal(self.clearMoneyString(mg['BUYIN']))
tourney.fee = 0 tourney.fee = 0
if mg['FEE'] is not None: if mg['FEE'] is not None:
tourney.fee = 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE'])) tourney.fee = 100*Decimal(self.clearMoneyString(mg['FEE']))
if mg['TOURNAMENT_NAME'] is not None: if mg['TOURNAMENT_NAME'] is not None:
# Tournament Name can have a trailing space at the end (depending on the tournament description) # Tournament Name can have a trailing space at the end (depending on the tournament description)
tourney.tourneyName = mg['TOURNAMENT_NAME'].rstrip() tourney.tourneyName = mg['TOURNAMENT_NAME'].rstrip()
@ -576,25 +576,25 @@ class Fulltilt(HandHistoryConverter):
mg = m.groupdict() mg = m.groupdict()
if tourney.isMatrix : if tourney.isMatrix :
if mg['BUYIN'] is not None: if mg['BUYIN'] is not None:
tourney.subTourneyBuyin = 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN'])) tourney.subTourneyBuyin = 100*Decimal(self.clearMoneyString(mg['BUYIN']))
tourney.subTourneyFee = 0 tourney.subTourneyFee = 0
if mg['FEE'] is not None: if mg['FEE'] is not None:
tourney.subTourneyFee = 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE'])) tourney.subTourneyFee = 100*Decimal(self.clearMoneyString(mg['FEE']))
else : else :
if mg['BUYIN'] is not None: if mg['BUYIN'] is not None:
if tourney.buyin is None: if tourney.buyin is None:
tourney.buyin = 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN'])) tourney.buyin = 100*Decimal(clearMoneyString(mg['BUYIN']))
else : else :
if 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN'])) != tourney.buyin: if 100*Decimal(clearMoneyString(mg['BUYIN'])) != tourney.buyin:
log.error(_("Conflict between buyins read in topline (%s) and in BuyIn field (%s)") % (tourney.buyin, 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN']))) ) log.error(_("Conflict between buyins read in topline (%s) and in BuyIn field (%s)") % (tourney.buyin, 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN']))) )
tourney.subTourneyBuyin = 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN'])) tourney.subTourneyBuyin = 100*Decimal(clearMoneyString(mg['BUYIN']))
if mg['FEE'] is not None: if mg['FEE'] is not None:
if tourney.fee is None: if tourney.fee is None:
tourney.fee = 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE'])) tourney.fee = 100*Decimal(clearMoneyString(mg['FEE']))
else : else :
if 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE'])) != tourney.fee: if 100*Decimal(clearMoneyString(mg['FEE'])) != tourney.fee:
log.error(_("Conflict between fees read in topline (%s) and in BuyIn field (%s)") % (tourney.fee, 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE']))) ) log.error(_("Conflict between fees read in topline (%s) and in BuyIn field (%s)") % (tourney.fee, 100*Decimal(clearMoneyString(mg['FEE']))) )
tourney.subTourneyFee = 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE'])) tourney.subTourneyFee = 100*Decimal(clearMoneyString(mg['FEE']))
if tourney.buyin is None: if tourney.buyin is None:
log.info(_("Unable to affect a buyin to this tournament : assume it's a freeroll")) log.info(_("Unable to affect a buyin to this tournament : assume it's a freeroll"))
@ -663,10 +663,10 @@ class Fulltilt(HandHistoryConverter):
tourney.koCounts.update( { tourney.hero : Decimal(mg['COUNT_KO']) } ) tourney.koCounts.update( { tourney.hero : Decimal(mg['COUNT_KO']) } )
# Deal with money amounts # Deal with money amounts
tourney.koBounty = 100*Decimal(re.sub(u',', u'', "%s" % tourney.koBounty)) tourney.koBounty = 100*Decimal(clearMoneyString(tourney.koBounty))
tourney.prizepool = 100*Decimal(re.sub(u',', u'', "%s" % tourney.prizepool)) tourney.prizepool = 100*Decimal(clearMoneyString(tourney.prizepool))
tourney.rebuyCost = 100*Decimal(re.sub(u',', u'', "%s" % tourney.rebuyCost)) tourney.rebuyCost = 100*Decimal(clearMoneyString(tourney.rebuyCost))
tourney.addOnCost = 100*Decimal(re.sub(u',', u'', "%s" % tourney.addOnCost)) tourney.addOnCost = 100*Decimal(clearMoneyString(tourney.addOnCost))
# Calculate payin amounts and update winnings -- not possible to take into account nb of rebuys, addons or Knockouts for other players than hero on FTP # Calculate payin amounts and update winnings -- not possible to take into account nb of rebuys, addons or Knockouts for other players than hero on FTP
for p in tourney.players : for p in tourney.players :
@ -692,7 +692,7 @@ class Fulltilt(HandHistoryConverter):
rank = Decimal(a.group('RANK')) rank = Decimal(a.group('RANK'))
if a.group('WINNING') is not None: if a.group('WINNING') is not None:
winnings = 100*Decimal(re.sub(u',', u'', "%s" % a.group('WINNING'))) winnings = 100*Decimal(clearMoneyString(a.group('WINNING')))
else: else:
winnings = "0" winnings = "0"