本文整理汇总了Python中horizons.world.disaster.disastermanager.DisasterManager.load方法的典型用法代码示例。如果您正苦于以下问题:Python DisasterManager.load方法的具体用法?Python DisasterManager.load怎么用?Python DisasterManager.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizons.world.disaster.disastermanager.DisasterManager
的用法示例。
在下文中一共展示了DisasterManager.load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: World
# 需要导入模块: from horizons.world.disaster.disastermanager import DisasterManager [as 别名]
# 或者: from horizons.world.disaster.disastermanager.DisasterManager import load [as 别名]
class World(BuildingOwner, WorldObject):
"""The World class represents an Unknown Horizons map with all its units, grounds, buildings, etc.
It inherits from BuildingOwner, among other things, so it has building management capabilities.
There is always one big reference per building, which is stored in either the world, the island,
or the settlement.
The main components of the world are:
* players - a list of all the session's players - Player instances
* islands - a list of all the map's islands - Island instances
* grounds - a list of all the map's groundtiles
* ground_map - a dictionary that binds tuples of coordinates with a reference to the tile:
{ (x, y): tileref, ...}
This is important for pathfinding and quick tile fetching.
* island_map - a dictionary that binds tuples of coordinates with a reference to the island
* ships - a list of all the ships ingame - horizons.world.units.ship.Ship instances
* ship_map - same as ground_map, but for ships
* session - reference to horizons.session.Session instance of the current game
* trader - The world's ingame free trader player instance (can control multiple ships)
* pirate - The world's ingame pirate player instance
TUTORIAL: You should now check out the _init() function.
"""
log = logging.getLogger("world")
def __init__(self, session):
"""
@param session: instance of session the world belongs to.
"""
self.inited = False
if False:
assert isinstance(session, horizons.session.Session)
self.session = session
super(World, self).__init__(worldid=GAME.WORLD_WORLDID)
def end(self):
# destructor-like thing.
super(World, self).end()
# let the AI players know that the end is near to speed up destruction
for player in self.players:
if hasattr(player, 'early_end'):
player.early_end()
for ship in self.ships[:]:
ship.remove()
for island in self.islands:
island.end()
for player in self.players:
player.end() # end players after game entities, since they usually depend on players
self.session = None
self.properties = None
self.players = None
self.player = None
self.ground_map = None
self.fake_tile_map = None
self.full_map = None
self.island_map = None
self.water = None
self.ships = None
self.ship_map = None
self.fish_indexer = None
self.ground_units = None
if self.pirate is not None:
self.pirate.end()
self.pirate = None
if self.trader is not None:
self.trader.end()
self.trader = None
self.islands = None
self.diplomacy = None
self.bullets = None
def _init(self, savegame_db, force_player_id=None, disasters_enabled=True):
"""
@param savegame_db: Dbreader with loaded savegame database
@param force_player_id: the worldid of the selected human player or default if None (debug option)
"""
"""
All essential and non-essential parts of the world are set up here, you don't need to
know everything that happens.
"""
# load properties
self.properties = {}
for (name, value) in savegame_db("SELECT name, value FROM map_properties"):
self.properties[name] = json.loads(value)
if not 'disasters_enabled' in self.properties:
# set on first init
self.properties['disasters_enabled'] = disasters_enabled
# create playerlist
self.players = []
self.player = None # player sitting in front of this machine
self.trader = None
self.pirate = None
self._load_players(savegame_db, force_player_id)
#.........这里部分代码省略.........
示例2: World
# 需要导入模块: from horizons.world.disaster.disastermanager import DisasterManager [as 别名]
# 或者: from horizons.world.disaster.disastermanager.DisasterManager import load [as 别名]
class World(BuildingOwner, LivingObject, WorldObject):
"""The World class represents an Unknown Horizons map with all its units, grounds, buildings, etc.
It inherits amongst others from BuildingOwner, so it has building management capabilities.
There is always one big reference per building. It is stored either in the world, the island
or the settlement.
The world comprises amongst others:
* players - a list of all the session's players - Player instances
* islands - a list of all the map's islands - Island instances
* grounds - a list of all the map's groundtiles
* ground_map - a dictionary that binds tuples of coordinates with a reference to the tile:
{ (x, y): tileref, ...}
This is important for pathfinding and quick tile fetching.
* island_map - a dictionary that binds tuples of coordinates with a reference to the island
* ships - a list of all the ships ingame - horizons.world.units.ship.Ship instances
* ship_map - same as ground_map, but for ships
* session - reference to horizons.session.Session instance of the current game
* trader - The world's ingame free trader player instance (can control multiple ships)
* pirate - The world's ingame pirate player instance
TUTORIAL: You should now check out the _init() function.
"""
log = logging.getLogger("world")
def __init__(self, session):
"""
@param session: instance of session the world belongs to.
"""
self.inited = False
if False:
assert isinstance(session, horizons.session.Session)
self.session = session
super(World, self).__init__(worldid=GAME.WORLD_WORLDID)
def end(self):
# destructor-like thing.
self.session = None
self.properties = None
self.players = None
self.player = None
self.ground_map = None
self.full_map = None
self.island_map = None
self.water = None
self.ships = None
self.ship_map = None
self.fish_indexer = None
self.ground_units = None
self.trader = None
self.pirate = None
self.islands = None
self.diplomacy = None
self.bullets = None
super(World, self).end()
def _init(self, savegame_db, force_player_id=None, disasters_enabled=True):
"""
@param savegame_db: Dbreader with loaded savegame database
@param force_player_id: the worldid of the selected human player or default if None (debug option)
"""
"""
All essential and non-essential parts of the world are set up here, you don't need to
know everything that happens.
"""
#load properties
self.properties = {}
for (name, value) in savegame_db("SELECT name, value FROM map_properties"):
self.properties[name] = value
# create playerlist
self.players = []
self.player = None # player sitting in front of this machine
self.trader = None
self.pirate = None
# load player
human_players = []
for player_worldid, client_id in savegame_db("SELECT rowid, client_id FROM player WHERE is_trader = 0 and is_pirate = 0 ORDER BY rowid"):
player = None
# check if player is an ai
ai_data = self.session.db("SELECT class_package, class_name FROM ai WHERE client_id = ?", client_id)
if len(ai_data) > 0:
class_package, class_name = ai_data[0]
# import ai class and call load on it
module = __import__('horizons.ai.'+class_package, fromlist=[class_name])
ai_class = getattr(module, class_name)
player = ai_class.load(self.session, savegame_db, player_worldid)
else: # no ai
player = HumanPlayer.load(self.session, savegame_db, player_worldid)
self.players.append(player)
if client_id == horizons.main.fife.get_uh_setting("ClientID"):
self.player = player
elif client_id is not None and len(ai_data) == 0:
# possible human player candidate with different client id
human_players.append(player)
self.owner_highlight_active = False
self.health_visible_for_all_health_instances = False
if self.player is None:
# we have no human player.
#.........这里部分代码省略.........