Add items in inventory
This commit is contained in:
parent
f11fb31c28
commit
d35331fdb0
|
@ -7,6 +7,7 @@ from ..interfaces import Entity, FightingEntity, Map
|
|||
class Item(Entity):
|
||||
held: bool
|
||||
hold_by: Optional["Player"]
|
||||
can_be_in_inventory: bool = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
@ -22,10 +23,13 @@ class Item(Entity):
|
|||
self.held = True
|
||||
self.hold_by = player
|
||||
self.map.remove_entity(self)
|
||||
if self.can_be_in_inventory:
|
||||
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:
|
||||
|
|
|
@ -15,6 +15,7 @@ class Player(FightingEntity):
|
|||
level: int = 1
|
||||
current_xp: int = 0
|
||||
max_xp: int = 10
|
||||
inventory: list = list()
|
||||
paths: Dict[Tuple[int, int], Tuple[int, int]]
|
||||
|
||||
def move(self, y: int, x: int) -> None:
|
||||
|
|
Loading…
Reference in New Issue