Don't fill the inventory of a chest or a Merchant if it is empty, fixes #73

This commit is contained in:
Yohann D'ANELLO 2021-01-10 20:46:01 +01:00
parent 3758cb1336
commit 67a9bda6e1
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 8 additions and 5 deletions

View File

@ -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.