示例#1
0
文件: map.py 项目: travisreed-wf/bitz
 def get():
     location1 = Location.get_by_id("E0000x0000")
     return [
         [
             location1
         ]
     ]
示例#2
0
文件: map.py 项目: travisreed-wf/bitz
 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)
示例#3
0
    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
示例#4
0
文件: map.py 项目: travisreed-wf/bitz
 def create():
     tile1 = Trees.get_trees_dense().put()
     tile2 = Trees.get_trees_dense().put()
     tile3 = Trees.get_trees_dense().put()
     tile4 = Trees.get_trees().put()
     tile5 = Trees.get_trees().put()
     tile6 = Trees.get_trees().put()
     tile7 = Trees.get_trees_sparse().put()
     tile8 = River.get_river().put()
     tile9 = Plains.get_plains().put()
     tiles = [tile1, tile2, tile3, tile4, tile5, tile6, tile7, tile8, tile9]
     location = Location.get_or_insert("E0000x0000",type="Woods", tiles=tiles)
     location.put()
示例#5
0
    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}
        })