Save floors and visibility, fixes #61
This commit is contained in:
@ -335,14 +335,16 @@ class Game:
|
||||
"""
|
||||
Saves the game to a dictionary.
|
||||
"""
|
||||
return self.map.save_state()
|
||||
return dict(map_index=self.map_index,
|
||||
maps=[m.save_state() for m in self.maps])
|
||||
|
||||
def load_state(self, d: dict) -> None:
|
||||
"""
|
||||
Loads the game from a dictionary.
|
||||
"""
|
||||
try:
|
||||
self.map.load_state(d)
|
||||
self.map_index = d["map_index"]
|
||||
self.maps = [Map().load_state(map_dict) for map_dict in d["maps"]]
|
||||
except KeyError:
|
||||
self.message = _("Some keys are missing in your save file.\n"
|
||||
"Your save seems to be corrupt. It got deleted.")
|
||||
@ -359,6 +361,8 @@ class Game:
|
||||
return
|
||||
|
||||
self.player = players[0]
|
||||
self.map.compute_visibility(self.player.y, self.player.x,
|
||||
self.player.vision)
|
||||
self.display_actions(DisplayActions.UPDATE)
|
||||
|
||||
def load_game(self) -> None:
|
||||
|
Reference in New Issue
Block a user