squirrel-battle/dungeonbattle/entities/monsters.py

23 lines
609 B
Python
Raw Normal View History

from random import choice
2020-11-06 14:33:26 +00:00
from ..interfaces import FightingEntity, Map
2020-10-23 14:51:48 +00:00
class Monster(FightingEntity):
2020-11-06 15:13:28 +00:00
def act(self, m: Map) -> None:
"""
By default, a monster will move randomly where it is possible
And if a player is close to the monster, the monster run on the player.
"""
# TODO If a player is close, move to the player
while True:
if choice([self.move_up, self.move_down,
self.move_left, self.move_right])():
break
2020-10-23 14:51:48 +00:00
2020-11-06 14:33:26 +00:00
2020-11-10 20:47:36 +00:00
class Hedgehog(Monster):
name = "hedgehog"
maxhealth = 10
strength = 3