def __init__(self, gui, db, rng_seed=None): super(Session, self).__init__() assert isinstance(gui, Gui) assert isinstance(db, horizons.util.uhdbaccessor.UhDbAccessor) self.log.debug("Initing session") self.gui = gui # main gui, not ingame gui self.db = db # main db for game data (game.sql) # this saves how often the current game has been saved self.savecounter = 0 self.is_alive = True self.message_bus = MessageBus() # misc WorldObject.reset() NamedComponent.reset() AIPlayer.clear_caches() #game self.random = self.create_rng(rng_seed) assert isinstance(self.random, Random) self.timer = self.create_timer() Scheduler.create_instance(self.timer) self.manager = self.create_manager() self.view = View(self) Entities.load(self.db) self.scenario_eventhandler = ScenarioEventHandler(self) # dummy handler with no events self.campaign = {} #GUI self.gui.session = self self.ingame_gui = IngameGui(self, self.gui) self.keylistener = IngameKeyListener(self) self.coordinates_tooltip = None self.display_speed() LastActivePlayerSettlementManager.create_instance(self) self.status_icon_manager = StatusIconManager(self) self.selected_instances = set() self.selection_groups = [set()] * 10 # List of sets that holds the player assigned unit groups.
def __init__(self, db, rng_seed=None): """ Unfortunately, right now there is no other way to setup Dummy versions of the GUI, View etc., unless we want to patch the references in the session module. """ super(LivingObject, self).__init__() self.gui = Dummy() self.db = db self.savecounter = 0 # this is a new game. self.is_alive = True WorldObject.reset() NamedComponent.reset() AIPlayer.clear_caches() # Game self.random = self.create_rng(rng_seed) self.timer = self.create_timer() Scheduler.create_instance(self.timer) ExtScheduler.create_instance(Dummy) self.manager = self.create_manager() self.view = Dummy() self.view.renderer = Dummy() Entities.load(self.db) self.scenario_eventhandler = Dummy() self.campaign = {} self.message_bus = MessageBus() self.status_icon_manager = StatusIconManager(self) # GUI self.gui.session = self self.ingame_gui = Dummy() LastActivePlayerSettlementManager.create_instance(self) self.selected_instances = set() self.selection_groups = [set()] * 10 # List of sets that holds the player assigned unit groups. GAME_SPEED.TICKS_PER_SECOND = 16
def _clear_caches(self): WorldObject.reset() NamedComponent.reset() AIPlayer.clear_caches()
def tearDown(self): NamedComponent.reset()
def _clear_caches(self): """Clear all data caches in global namespace related to a session""" WorldObject.reset() NamedComponent.reset() AIPlayer.clear_caches() SelectableBuildingComponent.reset()