Test heart healing
This commit is contained in:
@ -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):
|
||||
|
Reference in New Issue
Block a user