We can equip items

This commit is contained in:
Yohann D'ANELLO
2020-12-18 17:30:03 +01:00
parent 330d78702a
commit fe769c4488
5 changed files with 47 additions and 15 deletions

View File

@ -496,10 +496,10 @@ class InventoryHolder(Entity):
"""
for i in range(len(inventory)):
if isinstance(inventory[i], dict):
inventory[i] = self.dict_to_inventory(inventory[i])
inventory[i] = self.dict_to_item(inventory[i])
return inventory
def dict_to_inventory(self, item_dict: dict) -> Entity:
def dict_to_item(self, item_dict: dict) -> Entity:
"""
Translate a dict object that contains the state of an item
into an item object.
@ -522,13 +522,15 @@ class InventoryHolder(Entity):
"""
Adds an object to inventory
"""
self.inventory.append(obj)
if obj not in self.inventory:
self.inventory.append(obj)
def remove_from_inventory(self, obj: Any) -> None:
"""
Removes an object from the inventory
"""
self.inventory.remove(obj)
if obj in self.inventory:
self.inventory.remove(obj)
def change_hazel_balance(self, hz: int) -> None:
"""