Tourney parsing : Use of "Decimal" insted of float2int / Handle amounts in cents four Tourney Object
This commit is contained in:
parent
b00a58249f
commit
4a0b2274f8
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import fpdb_simple
|
|
||||||
from HandHistoryConverter import *
|
from HandHistoryConverter import *
|
||||||
|
|
||||||
# Fulltilt HH Format converter
|
# Fulltilt HH Format converter
|
||||||
|
@ -476,10 +475,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 = fpdb_simple.float2int(mg['BUYIN'])
|
tourney.buyin = 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN']))
|
||||||
tourney.fee = 0
|
tourney.fee = 0
|
||||||
if mg['FEE'] is not None:
|
if mg['FEE'] is not None:
|
||||||
tourney.fee = fpdb_simple.float2int(mg['FEE'])
|
tourney.fee = 100*Decimal(re.sub(u',', u'', "%s" % 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()
|
||||||
|
@ -524,25 +523,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 = fpdb_simple.float2int(mg['BUYIN'])
|
tourney.subTourneyBuyin = 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN']))
|
||||||
tourney.subTourneyFee = 0
|
tourney.subTourneyFee = 0
|
||||||
if mg['FEE'] is not None:
|
if mg['FEE'] is not None:
|
||||||
tourney.subTourneyFee = fpdb_simple.float2int(mg['FEE'])
|
tourney.subTourneyFee = 100*Decimal(re.sub(u',', u'', "%s" % 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 = fpdb_simple.float2int(mg['BUYIN'])
|
tourney.buyin = 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN']))
|
||||||
else :
|
else :
|
||||||
if fpdb_simple.float2int(mg['BUYIN']) != tourney.buyin:
|
if 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN'])) != tourney.buyin:
|
||||||
log.error( "Conflict between buyins read in topline (%s) and in BuyIn field (%s)" % (touney.buyin, fpdb_simple.float2int(mg['BUYIN'])) )
|
log.error( "Conflict between buyins read in topline (%s) and in BuyIn field (%s)" % (touney.buyin, 100*Decimal(re.sub(u',', u'', "%s" % mg['BUYIN']))) )
|
||||||
tourney.subTourneyBuyin = fpdb_simple.float2int(mg['BUYIN'])
|
tourney.subTourneyBuyin = 100*Decimal(re.sub(u',', u'', "%s" % 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 = fpdb_simple.float2int(mg['FEE'])
|
tourney.fee = 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE']))
|
||||||
else :
|
else :
|
||||||
if fpdb_simple.float2int(mg['FEE']) != tourney.fee:
|
if 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE'])) != tourney.fee:
|
||||||
log.error( "Conflict between fees read in topline (%s) and in BuyIn field (%s)" % (touney.fee, fpdb_simple.float2int(mg['FEE'])) )
|
log.error( "Conflict between fees read in topline (%s) and in BuyIn field (%s)" % (touney.fee, 100*Decimal(re.sub(u',', u'', "%s" % mg['FEE']))) )
|
||||||
tourney.subTourneyFee = mg['FEE']
|
tourney.subTourneyFee = 100*Decimal(re.sub(u',', u'', "%s" % 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" )
|
||||||
|
@ -598,10 +597,12 @@ class Fulltilt(HandHistoryConverter):
|
||||||
# Assign endtime to tourney (if None, that's ok, it's because the tourney wans't over over when the summary file was produced)
|
# Assign endtime to tourney (if None, that's ok, it's because the tourney wans't over over when the summary file was produced)
|
||||||
tourney.endtime = mg['ENDTIME']
|
tourney.endtime = mg['ENDTIME']
|
||||||
|
|
||||||
tourney.rebuyAmount = fpdb_simple.float2int("%s" % tourney.rebuyAmount)
|
# Deal with money amounts
|
||||||
tourney.addOnAmount = fpdb_simple.float2int("%s" % tourney.addOnAmount)
|
tourney.koBounty = 100*Decimal(re.sub(u',', u'', "%s" % tourney.koBounty))
|
||||||
|
tourney.prizepool = 100*Decimal(re.sub(u',', u'', "%s" % tourney.prizepool))
|
||||||
|
tourney.rebuyAmount = 100*Decimal(re.sub(u',', u'', "%s" % tourney.rebuyAmount))
|
||||||
|
tourney.addOnAmount = 100*Decimal(re.sub(u',', u'', "%s" % tourney.addOnAmount))
|
||||||
#print mg
|
#print mg
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def getPlayersPositionsAndWinnings(self, tourney):
|
def getPlayersPositionsAndWinnings(self, tourney):
|
||||||
|
@ -617,7 +618,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 = a.group('WINNING')
|
winnings = 100*Decimal(re.sub(u',', u'', "%s" % a.group('WINNING')))
|
||||||
else:
|
else:
|
||||||
winnings = "0"
|
winnings = "0"
|
||||||
|
|
||||||
|
|
|
@ -260,10 +260,9 @@ db: a connected fpdb_db object"""
|
||||||
Adds a player to the tourney, and initialises data structures indexed by player.
|
Adds a player to the tourney, and initialises data structures indexed by player.
|
||||||
rank (int) indicating the finishing rank (can be -1 if unknown)
|
rank (int) indicating the finishing rank (can be -1 if unknown)
|
||||||
name (string) player name
|
name (string) player name
|
||||||
winnings (string) the money the player ended the tourney with (can be 0, or -1 if unknown)
|
winnings (decimal) the money the player ended the tourney with (can be 0, or -1 if unknown)
|
||||||
"""
|
"""
|
||||||
log.debug("addPlayer: rank:%s - name : '%s' - Winnings (%s)" % (rank, name, winnings))
|
log.debug("addPlayer: rank:%s - name : '%s' - Winnings (%s)" % (rank, name, winnings))
|
||||||
winnings = re.sub(u',', u'', winnings) #some sites have commas
|
|
||||||
self.players.append(name)
|
self.players.append(name)
|
||||||
self.finishPositions.update( { name : Decimal(rank) } )
|
self.finishPositions.update( { name : Decimal(rank) } )
|
||||||
self.winnings.update( { name : Decimal(winnings) } )
|
self.winnings.update( { name : Decimal(winnings) } )
|
||||||
|
|
Loading…
Reference in New Issue
Block a user