Test heart healing

This commit is contained in:
Yohann D'ANELLO
2020-11-11 17:15:28 +01:00
parent 8db00bcaa6
commit 61714a5129
2 changed files with 16 additions and 8 deletions

View File

@ -7,9 +7,6 @@ from ..interfaces import Entity, FightingEntity, Map
class Item(Entity):
held: bool
held_by: Optional["Player"]
# When it is False, items disappear when they are hold.
# Action is done when the item is picked up.
can_be_in_inventory: bool = True
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@ -25,13 +22,11 @@ class Item(Entity):
self.held = True
self.held_by = player
self.map.remove_entity(self)
if self.can_be_in_inventory:
player.inventory.append(self)
player.inventory.append(self)
class Heart(Item):
name: str = "heart"
can_be_in_inventory: bool = False
healing: int = 5
def hold(self, player: "Player") -> None:
@ -39,7 +34,7 @@ class Heart(Item):
When holding a heart, heal the player and don't put item in inventory.
"""
player.health = min(player.maxhealth, player.health + self.healing)
return super().hold(player)
self.map.remove_entity(self)
class Bomb(Item):