Example #1
0
 def run(self, speed=config.speed):
     if self.record_replay:
         self.create_replay()
     self.world = World(self.default_triggers, self.seed)
     if self.world.load_and_build_map(self.map):
         style.load(res.get_text("ui/style", append=True, locale=True),
                    self.map.campaign_style,
                    self.map.additional_style)
         sounds.enter_map(self.map.mapfile)
         update_orders_list() # when style has changed
         self.pre_run()
         self.interface = clientgame.GameInterface(self.me, speed=speed)
         self.interface.load_bindings(
             res.get_text("ui/bindings", append=True, locale=True) + "\n" +
             self.map.get_campaign("ui/bindings.txt") + "\n" +
             self.map.get_additional("ui/bindings.txt"))
         self.world.populate_map(self.players, self.alliances, self.races)
         self.nb_human_players = self.world.current_nb_human_players()
         t = threading.Thread(target=self.world.loop)
         t.daemon = True
         t.start()
         self.interface.loop()
         self._record_stats(self.world)
         self.post_run()
         sounds.exit_map()
         self.world.clean()
     else:
         voice.alert([1029]) # hostile sound
         voice.alert([self.world.map_error])
     if self.record_replay:
         self._replay_file.close()
Example #2
0
 def run(self, speed=config.speed):
     if self.record_replay:
         self.create_replay()
     self.world = World(self.default_triggers, self.seed)
     if self.world.load_and_build_map(self.map):
         style.load(res.get_text("ui/style", append=True, locale=True),
                    self.map.campaign_style, self.map.additional_style)
         sounds.enter_map(self.map.mapfile)
         update_orders_list()  # when style has changed
         self.pre_run()
         self.interface = clientgame.GameInterface(self.me, speed=speed)
         self.interface.load_bindings(
             res.get_text("ui/bindings", append=True, locale=True) + "\n" +
             self.map.get_campaign("ui/bindings.txt") + "\n" +
             self.map.get_additional("ui/bindings.txt"))
         self.world.populate_map(self.players, self.alliances,
                                 self.factions)
         self.nb_human_players = self.world.current_nb_human_players()
         t = threading.Thread(target=self.world.loop)
         t.daemon = True
         t.start()
         self.interface.loop()
         self._record_stats(self.world)
         self.post_run()
         sounds.exit_map()
         self.world.clean()
     else:
         voice.alert([1029])  # hostile sound
         voice.alert([self.world.map_error])
     if self.record_replay:
         self._replay_file.close()
Example #3
0
 def run_on(self):
     if self.record_replay:
         self._replay_file = open(
             os.path.join(REPLAYS_PATH, "%s.txt" % int(time.time())), "w")
         self._replay_file.write(self._replay_file_content)
     sounds.enter_map(self.map.mapfile)
     self.world.restore_links_for_savegame()
     rules.copy(self._rules)
     definitions._ai = self._ai
     style.copy(self._style)
     update_orders_list()  # when style has changed
     self.interface.set_self_as_listener()
     t = threading.Thread(target=self.world.loop)
     t.daemon = True
     t.start()
     # Because the simulation is in a different thread,
     # sometimes the interface "forgets" to ask for an
     # update. Maybe a better communication protocol
     # between interface and simulation would solve
     # this problem ("update" and "no_end_of_update_yet"
     # should contain the simulation time, maybe). Maybe
     # some data in a queue has been lost.
     self.interface.asked_to_update = False
     self.interface.loop()
     self._record_stats(self.world)
     self.post_run()
     self.world.clean()
Example #4
0
 def run_on(self):
     if self.record_replay:
         self._replay_file = open(os.path.join(REPLAYS_PATH, "%s.txt" % int(time.time())), "w")
         self._replay_file.write(self._replay_file_content)
     sounds.enter_map(self.map.mapfile)
     self.world.restore_links_for_savegame()
     rules.copy(self._rules)
     definitions._ai = self._ai
     style.copy(self._style)
     update_orders_list() # when style has changed
     self.interface.set_self_as_listener()
     t = threading.Thread(target=self.world.loop)
     t.daemon = True
     t.start()
     # Because the simulation is in a different thread,
     # sometimes the interface "forgets" to ask for an
     # update. Maybe a better communication protocol
     # between interface and simulation would solve
     # this problem ("update" and "no_end_of_update_yet"
     # should contain the simulation time, maybe). Maybe
     # some data in a queue has been lost.
     self.interface.asked_to_update = False
     self.interface.loop()
     self._record_stats(self.world)
     self.post_run()
     self.world.clean()
Example #5
0
 def run_on(self):
     if self.record_replay:
         self._replay_file = open(os.path.join(REPLAYS_PATH, "%s.txt" % int(time.time())), "w")
         self._replay_file.write(self._replay_file_content)
     sounds.enter_map(self.map.mapfile)
     self.world.restore_links_for_savegame()
     rules.copy(self._rules)
     definitions._ai = self._ai
     style.copy(self._style)
     update_orders_list() # when style has changed
     self.interface.set_self_as_listener()
     t = threading.Thread(target=self.world.loop)
     t.daemon = True
     t.start()
     self.interface.loop()
     self._record_stats(self.world)
     self.post_run()
     self.world.clean()
Example #6
0
 def load_resources(self):
     from clientmedia import sounds, res
     sounds.enter_map(res, self.path)
Example #7
0
 def load_resources(self):
     from clientmedia import sounds, res
     sounds.enter_map(res, self.path)