diff --git a/squirrelbattle/entities/friendly.py b/squirrelbattle/entities/friendly.py index 94b1b8a..ff40d8b 100644 --- a/squirrelbattle/entities/friendly.py +++ b/squirrelbattle/entities/friendly.py @@ -55,7 +55,7 @@ class Sunflower(FriendlyEntity): return [_("Flower power!!"), _("The sun is warm today")] -class Familiar(FightingEntity): +class Familiar(FriendlyEntity): #FightingEntity """ A friendly familiar that helps the player defeat monsters. """ @@ -64,6 +64,13 @@ class Familiar(FightingEntity): super().__init__(maxhealth=maxhealth, *args, **kwargs) self.target = None +## @property +## def dialogue_option(self) -> list: +## """ +## Debug function (to see if used in the real game) +## """ +## return [_("My target is"+str(self.target))] + def act(self, p: Player, m: Map) -> None: """ By default, the familiar tries to stay at distance at most 2 of the @@ -71,10 +78,16 @@ class Familiar(FightingEntity): and attacks it. """ if self.target is None: + #If the previous target is dead(or if there was no previous target) + #the familiar tries to get closer to the player. + self.target = p + elif self.target.dead: self.target = p if self.target == p: + #Look for monsters around the player to kill TOFIX : if monster is out + #of range, continue targetting player. for entity in m.entities: - if (self.y - entity.y) ** 2 + (self.x - entity.x) ** 2 <= 9 and\ + if (p.y - entity.y) ** 2 + (p.x - entity.x) ** 2 <= 9 and\ isinstance(entity, Monster): self.target = entity entity.paths = dict() # Allows the paths to be calculated. @@ -93,9 +106,6 @@ class Familiar(FightingEntity): if self.distance_squared(self.target) <= 1 and \ not isinstance(self.target, Player): self.map.logs.add_message(self.hit(self.target)) - if self.target.dead: - self.target.paths = None - self.target = None break else: # Moves in a random direction