Merge branch 'fix-load' into 'master'
Fix load Closes #73 et #76 See merge request ynerant/squirrel-battle!72
This commit is contained in:
commit
b6a448b39b
|
@ -24,9 +24,11 @@ class Merchant(InventoryHolder, FriendlyEntity):
|
||||||
def __init__(self, name: str = "merchant", inventory: list = None,
|
def __init__(self, name: str = "merchant", inventory: list = None,
|
||||||
hazel: int = 75, maxhealth: int = 8, *args, **kwargs):
|
hazel: int = 75, maxhealth: int = 8, *args, **kwargs):
|
||||||
super().__init__(name=name, maxhealth=maxhealth, *args, **kwargs)
|
super().__init__(name=name, maxhealth=maxhealth, *args, **kwargs)
|
||||||
self.inventory = self.translate_inventory(inventory or [])
|
self.inventory = self.translate_inventory(inventory) \
|
||||||
|
if inventory is not None else None
|
||||||
self.hazel = hazel
|
self.hazel = hazel
|
||||||
if not self.inventory:
|
if self.inventory is None:
|
||||||
|
self.inventory = []
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
self.inventory.append(choice(Item.get_all_items())())
|
self.inventory.append(choice(Item.get_all_items())())
|
||||||
|
|
||||||
|
@ -54,9 +56,11 @@ class Chest(InventoryHolder, FriendlyEntity):
|
||||||
hazel: int = 0, *args, **kwargs):
|
hazel: int = 0, *args, **kwargs):
|
||||||
super().__init__(name=name, *args, **kwargs)
|
super().__init__(name=name, *args, **kwargs)
|
||||||
self.hazel = hazel
|
self.hazel = hazel
|
||||||
self.inventory = self.translate_inventory(inventory or [])
|
self.inventory = self.translate_inventory(inventory) \
|
||||||
|
if inventory is not None else None
|
||||||
self.annihilated = False
|
self.annihilated = False
|
||||||
if not self.inventory:
|
if self.inventory is None:
|
||||||
|
self.inventory = []
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
self.inventory.append(choice(Item.get_all_items())())
|
self.inventory.append(choice(Item.get_all_items())())
|
||||||
|
|
||||||
|
|
|
@ -419,9 +419,10 @@ class Game:
|
||||||
try:
|
try:
|
||||||
self.map_index = d["map_index"]
|
self.map_index = d["map_index"]
|
||||||
self.maps = [Map().load_state(map_dict) for map_dict in d["maps"]]
|
self.maps = [Map().load_state(map_dict) for map_dict in d["maps"]]
|
||||||
except KeyError:
|
except KeyError as error:
|
||||||
self.message = _("Some keys are missing in your save file.\n"
|
self.message = _("Some keys are missing in your save file.\n"
|
||||||
"Your save seems to be corrupt. It got deleted.")
|
"Your save seems to be corrupt. It got deleted.")\
|
||||||
|
+ f"\n{error}"
|
||||||
os.unlink(ResourceManager.get_config_path("save.json"))
|
os.unlink(ResourceManager.get_config_path("save.json"))
|
||||||
self.display_actions(DisplayActions.UPDATE)
|
self.display_actions(DisplayActions.UPDATE)
|
||||||
return
|
return
|
||||||
|
|
|
@ -662,8 +662,8 @@ class Entity:
|
||||||
"Bow": Bow,
|
"Bow": Bow,
|
||||||
"Chest": Chest,
|
"Chest": Chest,
|
||||||
"Chestplate": Chestplate,
|
"Chestplate": Chestplate,
|
||||||
"Eagle": GiantSeaEagle,
|
|
||||||
"FireBallStaff": FireBallStaff,
|
"FireBallStaff": FireBallStaff,
|
||||||
|
"GiantSeaEagle": GiantSeaEagle,
|
||||||
"Heart": Heart,
|
"Heart": Heart,
|
||||||
"Hedgehog": Hedgehog,
|
"Hedgehog": Hedgehog,
|
||||||
"Helmet": Helmet,
|
"Helmet": Helmet,
|
||||||
|
|
Loading…
Reference in New Issue