예제 #1
0
 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)
예제 #2
0
 def select(self):
     item = self.items[self.cursor_index]
     item.use()
예제 #3
0
 def use(self, item):
     if item.ammo <= 0:
         ui.message("You don't have enough ammo!")
         return False
     else:
         return item.use(self)
예제 #4
0
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))