def __init__(self, offerid, playerid, problemnumbers, price, kind='all'): self.offerid = int(offerid) self.playerid = int(playerid) self.problemnumbers = map(int, list(problemnumbers)) self.problemnumbers.sort() reduced = relation.reduce_rns(self.problemnumbers) if reduced: self.problemnumbers = reduced self.price = float(price) self.actedon = False # FIXME This is totally bogus. self.bep = relation.break_even(self.problemnumbers, 3) self.potential = 0 self.kind = kind
def SetPrice(self, price=None, markup=0.09): """Set or Generate a price.""" if self.IsSecret(): self.price = 1 logging.debug('Got problem number %s to generate price @ %s' % (self.problemnumbers, self.price)) return price apply_markup = True if price is None: ptv = problem.Problem.GetBestPriceAndType(self.problemnumbers[0]) if ptv: price = ptv[0] + 0.5 * FLAGS.mindecrement apply_markup = False else: price = relation.break_even(self.problemnumbers, 3) if apply_markup: price += markup if price > 1: price = 1 self.price = price logging.debug('Got problem number %s to generate price @ %s' % (self.problemnumbers, self.price)) return price