Test loading wrong saves

This commit is contained in:
Yohann D'ANELLO
2020-11-27 18:16:54 +01:00
parent 5faebfe556
commit b0e352444b
2 changed files with 32 additions and 1 deletions

View File

@ -139,7 +139,15 @@ class Game:
"""
Loads the game from a dictionary
"""
self.map.load_state(d)
try:
self.map.load_state(d)
except KeyError:
self.message = "Some keys are missing in your save file.\n" \
"Your save seems to be corrupt. It got deleted."
os.unlink(ResourceManager.get_config_path("save.json"))
self.display_actions(DisplayActions.UPDATE)
return
players = self.map.find_entities(Player)
if not players:
self.message = "No player was found on this map!\n" \