Interact with items

This commit is contained in:
Yohann D'ANELLO
2020-11-11 16:47:19 +01:00
parent 2b5d82db57
commit f11fb31c28
3 changed files with 35 additions and 9 deletions

View File

@ -47,6 +47,7 @@ class Player(FightingEntity):
self.current_xp += xp
self.level_up()
# noinspection PyTypeChecker,PyUnresolvedReferences
def check_move(self, y: int, x: int, move_if_possible: bool = False) \
-> bool:
"""
@ -58,12 +59,14 @@ class Player(FightingEntity):
if self.dead:
return False
for entity in self.map.entities:
if entity.y == y and entity.x == x and \
isinstance(entity, FightingEntity):
self.hit(entity)
if entity.dead:
self.add_xp(randint(3, 7))
return True
if entity.y == y and entity.x == x:
if entity.is_fighting_entity():
self.hit(entity)
if entity.dead:
self.add_xp(randint(3, 7))
return True
elif entity.is_item():
entity.hold(self)
return super().check_move(y, x, move_if_possible)
def recalculate_paths(self, max_distance: int = 8) -> None: