Save the inventory of the player when saving the game, fixes #33

This commit is contained in:
Yohann D'ANELLO
2020-12-05 14:35:59 +01:00
parent f887a1f0aa
commit c38f8cdc53
2 changed files with 15 additions and 2 deletions

View File

@ -32,6 +32,9 @@ class TestGame(unittest.TestCase):
"""
Save a game and reload it.
"""
bomb = Bomb()
self.game.map.add_entity(bomb)
bomb.hold(self.game.player)
old_state = self.game.save_state()
self.game.handle_key_pressed(KeyValues.DOWN)
@ -45,6 +48,9 @@ class TestGame(unittest.TestCase):
new_state = self.game.save_state()
self.assertEqual(old_state, new_state)
# Ensure that the bomb is loaded
self.assertTrue(self.game.player.inventory)
# Error on loading save
with open(ResourceManager.get_config_path("save.json"), "w") as f:
f.write("I am not a JSON file")