def get(self, map_name, location_id): location = Location.get_by_id(location_id) if not location: return "Invalid location", 404 tiles = ndb.get_multi(location.tiles) player = Player.get_by_id("Travis Reed") print player.organized_resources return render_template('map.html', location=location, player=player, tiles=tiles)
def put(self, location_id, tile_index, building_name): try: location = Location.get_by_id(location_id) tile = location.tiles[int(tile_index)].get() tile.build_building(building_name) player = Player.get_by_id("Travis Reed") player.put() return "success" except: print traceback.format_exc() return "Failed", 500
def put(self, tool_name): clicks = int(request.args.get('clicks')) try: player = Player.get_by_id("Travis Reed") action = "resource.%s.build(player, count=clicks)" % tool_name gained_resources, used_resources = eval(action) print gained_resources, used_resources player.put() except: print traceback.format_exc() return "Failed", 500 return json.dumps({ 'gained_resources': {r.name: r.count for r in gained_resources}, 'used_resources': {r.name: r.count for r in used_resources} })
def put(self, location_id, tile_index, action_name): clicks = int(request.args.get('clicks')) location = Location.get_by_id(location_id) if not location: return "Invalid location", 404 tile = location.tiles[int(tile_index)].get() try: player = Player.get_by_id("Travis Reed") gained_resources, used_resources = tile.perform_action( action_name, player, clicks) player.put() except: print traceback.format_exc() return "Failed", 500 return json.dumps({ 'gained_resources': {r.name: r.count for r in gained_resources}, 'used_resources': {r.name: r.count for r in used_resources} })
def get(self): player = Player.get_by_id("Travis Reed") return render_template('build_tools.html', player=player)