Use directly equipped items outside the inventory

This commit is contained in:
Yohann D'ANELLO
2020-12-18 17:57:42 +01:00
parent 9475725228
commit 9aa684fb77
3 changed files with 15 additions and 2 deletions

View File

@ -75,6 +75,17 @@ class Player(InventoryHolder, FightingEntity):
self.current_xp += xp
self.level_up()
def remove_from_inventory(self, obj: Item) -> None:
"""
Remove the given item from the inventory, even if the item is equipped.
"""
if obj == self.equipped_item:
self.equipped_item = None
elif obj == self.equipped_armor:
self.equipped_armor = None
else:
return super().remove_from_inventory(obj)
# noinspection PyTypeChecker,PyUnresolvedReferences
def check_move(self, y: int, x: int, move_if_possible: bool = False) \
-> bool: