Interact with items
This commit is contained in:
@ -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:
|
||||
|
Reference in New Issue
Block a user