def get(self): user = users.get_current_user() if not user: self.redirect("/") player = doo.getplayerbyuser(user) if not player: player = doo.makeplayer(user.nickname(), user=user) stuff = doo.getstuffbyid(self.request.get('stuffid')) if not stuff: self.error(404) if stuff.ownerid != player.playerid: self.error(404) liquidationvalue = formattar.getmoney(stuff.liquidaterate * stuff.price) template_values = { 'player': player, 'stuff': stuff, 'liquidationvalue': liquidationvalue, } path = os.path.join(os.path.dirname(__file__), 'liquidatestuff.html') self.response.out.write(template.render(path, template_values))
def get(self): user = users.get_current_user() if not user: self.redirect("/") player = doo.getplayerbyuser(user) if not player: player = doo.makeplayer(user.nickname(), user=user) stuff = doo.getstuffbyid(self.request.get('stuffid')) stuff.setforsale(True) self.response.out.write(stuff.name)
def get(self): user = users.get_current_user() if not user: self.redirect("/") player = doo.getplayerbyuser(user) if not player: player = doo.makeplayer(user.nickname(), user=user) stuff = doo.getstuffbyid(self.request.get("stuffid")) template_values = {"stuff": stuff, "player": player} path = os.path.join(os.path.dirname(__file__), "editstuff.html") self.response.out.write(template.render(path, template_values))
def post(self): user = users.get_current_user() if not user: self.redirect("/") player = doo.getplayerbyuser(user) if not player: player = doo.makeplayer(user.nickname(), user=user) stuff = doo.getstuffbyid(self.request.get('stuffid')) if not stuff: self.error(404) if stuff.ownerid != player.playerid: self.error(404) if not doo.liquidatestuff(stuff.stuffid): doo.makealert(player, 'Liquidation of %s failed' % (stuff.name))
def get(self): user = users.get_current_user() if not user: self.redirect("/") player = doo.getplayerbyuser(user) if not player: player = doo.makeplayer(user.nickname(), user=user) stuff = doo.getstuffbyid(self.request.get("stuffid")) if not player.buystuff(stuff): if player.money <= stuff.price: doo.makealert(player, "Hey Mcfly, you don't have enough money to purchase this item") else: doo.makealert(player, "Darn it, something went wrong with that purchase.") self.response.out.write("0") # fail else: self.response.out.write("1") # success
def get(self): user = users.get_current_user() if not user: self.redirect("/") player = doo.getplayerbyuser(user) if not player: player = doo.makeplayer(user.nickname(), user=user) stuff = doo.getstuffbyid(self.request.get('stuffid')) owner = doo.getplayer(stuff.ownerid) template_values = { 'stuff': stuff, 'player': player, 'owner': owner, } path = os.path.join(os.path.dirname(__file__), 'storebuystuff.html') self.response.out.write(template.render(path, template_values))
def post(self): user = users.get_current_user() if not user: self.redirect("/") player = doo.getplayerbyuser(user) if not player: player = doo.makeplayer(user.nickname(), user=user) stuff = doo.getstuffbyid(self.request.get("stuffid")) if self.request.get("stuffforsale") == "on": forsale = True else: forsale = False description = str(self.request.get("stuffdescription")) price = round(float(self.request.get("stuffprice")), 2) if price < 0: doo.makealert(player, "sale price must be greater than zero") stuff.update(stuff.price, forsale, description) else: stuff.update(price, forsale, description)