def sellstuff(self, stuff, toperson): if toperson.money >= stuff.price and stuff.ownerid == self.playerid: #solidinvestment = doo.getplayer(stuff.solidinvestment) solidstuff = doo.getsolidstuffbyplayerid(stuff.solidinvestment) tax = stuff.price * solidstuff.gettax() self.money += float(stuff.price - tax) self.put() #self.stuff.remove(stuff.stuffid) if stuff.sellto(toperson): toperson.points += 1 toperson.put() stuff.put() self.points += 1 #doo.makealert(self, "Sold %s to %s for %s" % (stuff.name, toperson.name, stuff.price)) self.put() doo.collecttax(stuff, stuff.price) return True else: return False else: return False
def buystuff(self, stuff): if stuff.ownerid: owner = doo.getplayer(stuff.ownerid) if owner: return owner.sellstuff(stuff, self) else: return False else: success = stuff.sellto(self) if success: self.points += 1 self.put() doo.collecttax(stuff, stuff.price) return True else: return False