def start(self): logging.debug("starting game...") # Splash game consoles console.get_root_console().clear() console.get_root_console().render() # Game self._game_loop()
def _take_actors_turn(self, actor): logging.debug("next actor [%r]" % actor) # Error checking if actor.time_to_act == 0: # CONSIDER: this could be used to check for removed Actors logging.error("[%r] time_to_act illegal value [%d]" % (actor, actor.time_to_act)) raise ValueError # Actor takes turn turn_summary = Game.TurnSummary() while not turn_summary.turn_taken: logging.debug("creating new TurnSummary instance...") new_turn_summary = Game.TurnSummary() turn_summary = actor.take_turn(new_turn_summary) # Check for exit request logging.debug("checking [TurnSummary.exit_request]...") if turn_summary.exit_request: logging.debug("[%r] exit_request [%r]" % (turn_summary, turn_summary.exit_request)) self.exit_game = True turn_summary.turn_taken = True break # Send messages to MessageConsole logging.debug("checking [TurnSummary.messages]...") if len(turn_summary.messages): logging.debug("[%d] message(s) found in [TurnSummary.messages]" % len(turn_summary.messages)) msg_console = console.get_root_console().get_subscriber_by_class(MESSAGE_CONSOLE_CLASS) for m in turn_summary.messages: msg_console.add_message(text=m) # Consoles logging.debug("checking [TurnSummary.to_refresh_game_map_console]...") if turn_summary.to_refresh_game_map_console: game_map_console = console.get_root_console().get_subscriber_by_class(GAME_MAP_CONSOLE_CLASS) game_map_console.to_refresh = True logging.debug("setting [%s] to refresh" % game_map_console.__class__.__name__) logging.debug("rendering [RootConsole]...") console.get_root_console().render()
def __init__(self): self.root_console = console.get_root_console() logging.debug("%s initialized" % self.__class__.__name__)