Item owners are correctly set
This commit is contained in:
parent
e233243b81
commit
87e896bd06
@ -848,7 +848,6 @@ class InventoryHolder(Entity):
|
||||
for i in range(len(inventory)):
|
||||
if isinstance(inventory[i], dict):
|
||||
inventory[i] = self.dict_to_item(inventory[i])
|
||||
inventory[i].held_by = self
|
||||
return inventory
|
||||
|
||||
def dict_to_item(self, item_dict: dict) -> Entity:
|
||||
@ -859,7 +858,9 @@ class InventoryHolder(Entity):
|
||||
entity_classes = self.get_all_entity_classes_in_a_dict()
|
||||
|
||||
item_class = entity_classes[item_dict["type"]]
|
||||
return item_class(**item_dict)
|
||||
item = item_class(**item_dict)
|
||||
item.held_by = self
|
||||
return item
|
||||
|
||||
def save_state(self) -> dict:
|
||||
"""
|
||||
@ -875,6 +876,7 @@ class InventoryHolder(Entity):
|
||||
Adds an object to the inventory.
|
||||
"""
|
||||
if obj not in self.inventory:
|
||||
obj.held_by = self
|
||||
self.inventory.append(obj)
|
||||
|
||||
def remove_from_inventory(self, obj: Any) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user