예제 #1
0
 def post(self, *args, **kwargs):
     form = Form(
         uuid="Armor not found",
     )
     if form.validate(self.request.arguments):
         user = self.get_current_user()
         armor = ArmoryArmor.by_uuid(self.request.arguments['uuid'][0])
         if user == None or armor == None:
             self.render("store/armor.html", errors=None, armors=ArmoryArmor.get_all_visible())
         elif user.gold < armor.cost:
             self.render("store/armor.html", errors=['You cannot afford this armor'], armors=ArmoryArmor.get_all_visible())
         else:
             user.gold -= armor.cost
             new_armor = Armor(
                 user_id=user.id,
                 name=armor.name,
                 description=armor.description,
                 required_level=armor.required_level,
                 rating=armor.rating,
                 classification=armor.classification,
                 avatar=armor.avatar,
             )
             self.dbsession.add(new_armor)
             self.dbsession.add(user)
             self.dbsession.flush()
             self.render("store/purchase.html", item=armor.name)
     else:
         self.render("store/armor.html", errors=form.errors, armors=ArmoryArmor.get_all_visible())
예제 #2
0
 def get(self, *args, **kwargs):
     ''' Sends item details via ajax '''
     try:
         classification = self.get_argument("cls")
         uuid = self.get_argument("uuid")
     except:
         self.write(json.dumps({"Error": "Missing parameter"}))
         return
     if classification == "weapon":
         weapon = ArmoryWeapon.by_uuid(uuid)
         details = {
             'Name': weapon.name,
             'Description': weapon.description,
             'Avatar': weapon.avatar,
             'RequiredLevel': weapon.required_level,
             'Rating': weapon.rating,
             'Damage': weapon.damage,
             'Advanced': str(weapon.advanced),
             'Classification': weapon.classification,
         }
         self.write(json.dumps(details))
     elif classification == "armor":
         armor = ArmoryArmor.by_uuid(uuid)
         details = {
             'Name': armor.name,
             'Description': armor.description,
             'RequiredLevel': armor.required_level,
             'Avatar': armor.avatar,
             'Rating': armor.rating,
             'Classification': armor.classification,
         }
         self.write(json.dumps(details))
     else:
         self.write(json.dump({"Error": "Item not found"}))
     self.finish()
예제 #3
0
 def get(self, *args, **kwargs):
     ''' Renders armor store page '''
     self.render("store/armor.html", errors=None, armors=ArmoryArmor.get_all_visible())