def resumeLoadedGame(saved_state_string): # pylint: disable=invalid-name """Called by client to when resume a loaded game.""" if fo.getEmpire() is None: fatal( "This client has no empire. Doing nothing to resume loaded game.") return if fo.getEmpire().eliminated: info("This empire has been eliminated. Ignoring resume loaded game.") return debug("Resuming loaded game") if not saved_state_string: error( "AI given empty state-string to resume from; this is expected if the AI is assigned to an empire " "previously run by a human, but is otherwise an error. AI will be set to Aggressive." ) aistate = create_new_aistate(fo.aggression.aggressive) aistate.session_start_cleanup() else: try: # loading saved state aistate = load_aistate(saved_state_string) except Exception as e: # assigning new state aistate = create_new_aistate(fo.aggression.aggressive) aistate.session_start_cleanup() error( "Failed to load the AIstate from the savegame. The AI will" " play with a fresh AIstate instance with aggression level set" " to 'aggressive'. The behaviour of the AI may be different" " than in the original session. The error raised was: %s" % e, exc_info=True, ) _pre_game_start(fo.getEmpire().empireID, aistate)
def resumeLoadedGame(saved_state_string): # pylint: disable=invalid-name """Called by client to when resume a loaded game.""" debug("Resuming loaded game") if saved_state_string == "NO_STATE_YET" and fo.currentTurn() == 1: info("AI given uninitialized state-string to resume from on turn 1.") info( "Assuming post-universe-generation autosave before any orders were sent " "and behaving as if a new game was started.") return startNewGame() if fo.getEmpire() is None: fatal( "This client has no empire. Doing nothing to resume loaded game.") return if fo.getEmpire().eliminated: info("This empire has been eliminated. Ignoring resume loaded game.") return aistate = None if saved_state_string == "NOT_SET_BY_CLIENT_TYPE": info("AI assigned to empire previously run by human.") chat_human( "We have been assigned an empire previously run by a human player. We can manage this." ) elif saved_state_string == "": error( "AI given empty state-string to resume from. " "AI can continue but behaviour may be different from the previous session." ) else: try: # loading saved state aistate = load_aistate(saved_state_string) except Exception as e: error( "Failed to load the AIstate from the savegame: %s" " AI can continue but behaviour may be different from the previous session.", e, exc_info=True, ) if aistate is None: info("Creating new ai state due to failed load.") aistate = create_new_aistate(_choose_aggression()) aistate.session_start_cleanup() _pre_game_start(fo.getEmpire().empireID)
def resumeLoadedGame(saved_state_string): # pylint: disable=invalid-name """Called by client to when resume a loaded game.""" if fo.getEmpire() is None: fatal( "This client has no empire. Doing nothing to resume loaded game.") return if fo.getEmpire().eliminated: info("This empire has been eliminated. Ignoring resume loaded game.") return turn_timer.start("Server Processing") debug("Resuming loaded game") if not saved_state_string: error( "AI given empty state-string to resume from; this is expected if the AI is assigned to an empire " "previously run by a human, but is otherwise an error. AI will be set to Aggressive." ) aistate = create_new_aistate(fo.aggression.aggressive) aistate.session_start_cleanup() else: try: # loading saved state aistate = load_aistate(saved_state_string) except Exception as e: # assigning new state aistate = create_new_aistate(fo.aggression.aggressive) aistate.session_start_cleanup() error( "Failed to load the AIstate from the savegame. The AI will" " play with a fresh AIstate instance with aggression level set" " to 'aggressive'. The behaviour of the AI may be different" " than in the original session. The error raised was: %s" % e, exc_info=True) aggression_trait = aistate.character.get_trait(Aggression) diplomatic_corp_configs = { fo.aggression.beginner: DiplomaticCorp.BeginnerDiplomaticCorp, fo.aggression.maniacal: DiplomaticCorp.ManiacalDiplomaticCorp } global diplomatic_corp diplomatic_corp = diplomatic_corp_configs.get( aggression_trait.key, DiplomaticCorp.DiplomaticCorp)() TechsListsAI.test_tech_integrity() debug('Size of already issued orders: ' + str(fo.getOrders().size))
def resumeLoadedGame(saved_state_string): # pylint: disable=invalid-name """Called by client to when resume a loaded game.""" if fo.getEmpire() is None: fatal("This client has no empire. Doing nothing to resume loaded game.") return if fo.getEmpire().eliminated: info("This empire has been eliminated. Ignoring resume loaded game.") return turn_timer.start("Server Processing") debug("Resuming loaded game") if not saved_state_string: error("AI given empty state-string to resume from; this is expected if the AI is assigned to an empire " "previously run by a human, but is otherwise an error. AI will be set to Aggressive.") aistate = create_new_aistate(fo.aggression.aggressive) aistate.session_start_cleanup() else: try: # loading saved state aistate = load_aistate(saved_state_string) except Exception as e: # assigning new state aistate = create_new_aistate(fo.aggression.aggressive) aistate.session_start_cleanup() error("Failed to load the AIstate from the savegame. The AI will" " play with a fresh AIstate instance with aggression level set" " to 'aggressive'. The behaviour of the AI may be different" " than in the original session. The error raised was: %s" % e, exc_info=True) aggression_trait = aistate.character.get_trait(Aggression) diplomatic_corp_configs = {fo.aggression.beginner: DiplomaticCorp.BeginnerDiplomaticCorp, fo.aggression.maniacal: DiplomaticCorp.ManiacalDiplomaticCorp} global diplomatic_corp diplomatic_corp = diplomatic_corp_configs.get(aggression_trait.key, DiplomaticCorp.DiplomaticCorp)() TechsListsAI.test_tech_integrity() debug('Size of already issued orders: ' + str(fo.getOrders().size))