def use(self, item): if self.mana < item.mana_use: ui.message("You don't have enough mana!") return False else: return item.use(self)
def select(self): item = self.items[self.cursor_index] item.use()
def use(self, item): if item.ammo <= 0: ui.message("You don't have enough ammo!") return False else: return item.use(self)
import json import cgi form = cgi.FieldStorage() import sys sys.path.append('..') import user import item id = int(form.getvalue('id')) token = str(form.getvalue('token')) inventoryid = form.getvalue('inventoryid') v = {} v['valid'] = user.check(id, token) if ( v['valid'] ): if ( item.use(inventoryid) ): v['inventory'] = item.inventory(id) else : v['error'] = "Inventory is not enough" print('Content-type: application/json\n\n') print(json.dumps(v))