From 3758cb13361682922eadfba3ab6be8b6c69889cf Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 10 Jan 2021 20:20:12 +0100 Subject: [PATCH 1/3] Fix the GiantSeaEagle registration, fixes #76 --- squirrelbattle/game.py | 4 ++-- squirrelbattle/interfaces.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/squirrelbattle/game.py b/squirrelbattle/game.py index 9cfa721..f59f676 100644 --- a/squirrelbattle/game.py +++ b/squirrelbattle/game.py @@ -419,9 +419,9 @@ class Game: try: self.map_index = d["map_index"] 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" - "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")) self.display_actions(DisplayActions.UPDATE) return diff --git a/squirrelbattle/interfaces.py b/squirrelbattle/interfaces.py index 330301c..14fcc6d 100644 --- a/squirrelbattle/interfaces.py +++ b/squirrelbattle/interfaces.py @@ -662,8 +662,8 @@ class Entity: "Bow": Bow, "Chest": Chest, "Chestplate": Chestplate, - "Eagle": GiantSeaEagle, "FireBallStaff": FireBallStaff, + "GiantSeaEagle": GiantSeaEagle, "Heart": Heart, "Hedgehog": Hedgehog, "Helmet": Helmet, From 67a9bda6e180aa95907eefc0a406fc2bc6a4ab27 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 10 Jan 2021 20:46:01 +0100 Subject: [PATCH 2/3] Don't fill the inventory of a chest or a Merchant if it is empty, fixes #73 --- squirrelbattle/entities/friendly.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/squirrelbattle/entities/friendly.py b/squirrelbattle/entities/friendly.py index 57506e9..1a92392 100644 --- a/squirrelbattle/entities/friendly.py +++ b/squirrelbattle/entities/friendly.py @@ -24,9 +24,11 @@ class Merchant(InventoryHolder, FriendlyEntity): def __init__(self, name: str = "merchant", inventory: list = None, hazel: int = 75, maxhealth: int = 8, *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 - if not self.inventory: + if self.inventory is None: + self.inventory = [] for i in range(5): self.inventory.append(choice(Item.get_all_items())()) @@ -54,9 +56,11 @@ class Chest(InventoryHolder, FriendlyEntity): hazel: int = 0, *args, **kwargs): super().__init__(name=name, *args, **kwargs) 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 - if not self.inventory: + if self.inventory is None: + self.inventory = [] for i in range(3): self.inventory.append(choice(Item.get_all_items())()) @@ -84,7 +88,6 @@ class Chest(InventoryHolder, FriendlyEntity): """ return self.annihilated - class Sunflower(FriendlyEntity): """ A friendly sunflower. From d2af345c0ca4e8cce2182482d32ee357ba96f2f0 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 10 Jan 2021 21:01:43 +0100 Subject: [PATCH 3/3] Fix linting --- squirrelbattle/entities/friendly.py | 1 + squirrelbattle/game.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/squirrelbattle/entities/friendly.py b/squirrelbattle/entities/friendly.py index 1a92392..9b149de 100644 --- a/squirrelbattle/entities/friendly.py +++ b/squirrelbattle/entities/friendly.py @@ -88,6 +88,7 @@ class Chest(InventoryHolder, FriendlyEntity): """ return self.annihilated + class Sunflower(FriendlyEntity): """ A friendly sunflower. diff --git a/squirrelbattle/game.py b/squirrelbattle/game.py index f59f676..44c1f48 100644 --- a/squirrelbattle/game.py +++ b/squirrelbattle/game.py @@ -421,7 +421,8 @@ class Game: self.maps = [Map().load_state(map_dict) for map_dict in d["maps"]] except KeyError as error: self.message = _("Some keys are missing in your save file.\n" - "Your save seems to be corrupt. It got deleted.") + f"\n{error}" + "Your save seems to be corrupt. It got deleted.")\ + + f"\n{error}" os.unlink(ResourceManager.get_config_path("save.json")) self.display_actions(DisplayActions.UPDATE) return