squirrel-battle/dungeonbattle/entities/monsters.py

23 lines
618 B
Python

from random import choice
from ..interfaces import FightingEntity, Map
class Monster(FightingEntity):
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
for _ in range(100):
if choice([self.move_up, self.move_down,
self.move_left, self.move_right])():
break
class Hedgehog(Monster):
name = "hedgehog"
maxhealth = 10
strength = 3