def load_game(): with open('save_game.json') as save_file: data = json.load(save_file) player_index = data['player_index'] entities_json = data['entities'] game_map_json = data['game_map'] message_log_json = data['message_log'] game_state_json = data['game_state'] entities = [Entity.from_json(entity_json) for entity_json in entities_json] player = entities[player_index] game_map = GameMap.from_json(game_map_json) message_log = MessageLog.from_json(message_log_json) game_state = GameStates(game_state_json) return player, entities, game_map, message_log, game_state
def load_game(): with ZipFile(save_filename, 'r') as savezip: json_bytes = savezip.read('savegame.json') json_data = json_bytes.decode('utf-8') data = json.loads(json_data) player_index = data['player_index'] entities_json = data['entities'] game_map_json = data['game_map'] message_log_json = data['message_log'] game_state_json = data['game_state'] entities = [Entity.from_json(entity_json) for entity_json in entities_json] player = entities[player_index] game_map = GameMap.from_json(game_map_json) message_log = MessageLog.from_json(message_log_json) game_state = GameStates(game_state_json) return player, entities, game_map, message_log, game_state