Esempio n. 1
0
 def post(self, *args, **kwargs):
     form = Form(
         uuid="Weapon not found",
     )
     if form.validate(self.request.arguments):
         user = self.get_current_user()
         weapon = ArmoryWeapon.by_uuid(self.request.arguments['uuid'][0])
         if user == None or weapon == None:
             self.render("store/weapons.html", errors=None, weapons=ArmoryWeapon.get_all_visible())
         elif user.gold < weapon.cost:
             self.render("store/weapons.html", errors=['You cannot afford this weapon'], weapons=ArmoryWeapon.get_all_visible())
         else:
             user.gold -= weapon.cost
             new_weapon = Weapon(
                 user_id=user.id,
                 name=weapon.name,
                 description=weapon.description,
                 required_level=weapon.required_level,
                 damage=weapon.damage,
                 rating=weapon.rating,
                 advanced=weapon.advanced,
                 classification=weapon.classification,
                 avatar=weapon.avatar,
             )
             self.dbsession.add(new_weapon)
             self.dbsession.add(user)
             self.dbsession.flush()
             self.render("store/purchase.html", item=weapon.name)
     else:
         self.render("store/weapons.html", errors=form.errors, weapons=ArmoryWeapon.get_all_visible())
Esempio n. 2
0
 def get(self, *args, **kwargs):
     ''' Renders weapons store page '''
     self.render("store/weapons.html", errors=None, weapons=ArmoryWeapon.get_all_visible())