diff --git a/_helper_functions.py b/_helper_functions.py index ae8faf8..0b467aa 100644 --- a/_helper_functions.py +++ b/_helper_functions.py @@ -29,6 +29,10 @@ def load_game(world): world._next_entity_id = data_file['next_entity_id'] world._components = data_file['components'] world._entities = data_file['entities'] + world.messages = data_file['log'] + world.state_stack = data_file['state'] + world.ticker = data_file['ticker'] + world.map = data_file['map'] def loot_algorithm(chance, monster, item, floor): net_rarity = (1 + (monster)*5 - (item - 3)*5 + (floor)*5) @@ -36,8 +40,12 @@ def loot_algorithm(chance, monster, item, floor): return True return False -def save_game(next_entity_id, components, entities): +def save_game(world): with shelve.open('savegame', 'n') as data_file: - data_file['next_entity_id'] = next_entity_id - data_file['components'] = components - data_file['entities'] = entities \ No newline at end of file + data_file['next_entity_id'] = world._next_entity_id + data_file['components'] = world._components + data_file['entities'] = world._entities + data_file['log'] = world.messages + data_file['state'] = world.state_stack + data_file['ticker'] = world.ticker + data_file['map'] = world.map \ No newline at end of file diff --git a/processors/event.py b/processors/event.py index 76dcff2..56a8b7c 100644 --- a/processors/event.py +++ b/processors/event.py @@ -84,7 +84,7 @@ def process(self): if _save_game: self.world.messages.append({'game_saved': True}) - save_game(self.world._next_entity_id, self.world._components, self.world._entities) + save_game(self.world) if _scroll: self.world.messages_offset += _scroll