Linting
This commit is contained in:
@@ -54,31 +54,32 @@ class Sunflower(FriendlyEntity):
|
||||
"""
|
||||
return [_("Flower power!!"), _("The sun is warm today")]
|
||||
|
||||
|
||||
class Familiar(FightingEntity):
|
||||
"""
|
||||
A friendly familiar that helps the player defeat monsters.
|
||||
"""
|
||||
def __init__(self, maxhealth: int = 25,
|
||||
def __init__(self, maxhealth: int = 25,
|
||||
*args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
super().__init__(maxhealth=maxhealth, *args, **kwargs)
|
||||
self.target = None
|
||||
def act(self, p: Player, m : Map) :
|
||||
|
||||
def act(self, p: Player, m: Map) -> None:
|
||||
"""
|
||||
By default, the familiar tries to stay at distance at most 2 of the
|
||||
player and if a monster comes in range 3, it focuses on the monster
|
||||
and attacks it.
|
||||
"""
|
||||
if self.target == None:
|
||||
if self.target is None:
|
||||
self.target = p
|
||||
if self.target == p:
|
||||
for entity in m.entities:
|
||||
if (self.y - entity.y) ** 2 + (self.x - entity.x) ** 2 <= 9 and \
|
||||
if (self.y - entity.y) ** 2 + (self.x - entity.x) ** 2 <= 9 and\
|
||||
isinstance(entity, Monster):
|
||||
self.target = entity
|
||||
entity.paths = dict() #Allows the paths to be calculated.
|
||||
entity.paths = dict() # Allows the paths to be calculated.
|
||||
break
|
||||
|
||||
|
||||
|
||||
# Familiars move according to a Dijkstra algorithm
|
||||
# that targets their target.
|
||||
# If they can not move and are already close to their target,
|
||||
@@ -90,9 +91,9 @@ class Familiar(FightingEntity):
|
||||
if moved:
|
||||
break
|
||||
if self.distance_squared(self.target) <= 1 and \
|
||||
not isinstance(self.target, Player):
|
||||
not isinstance(self.target, Player):
|
||||
self.map.logs.add_message(self.hit(self.target))
|
||||
if self.target.dead :
|
||||
if self.target.dead:
|
||||
self.target.paths = None
|
||||
self.target = None
|
||||
break
|
||||
@@ -106,7 +107,8 @@ class Familiar(FightingEntity):
|
||||
if move():
|
||||
break
|
||||
|
||||
class Trumpet(Familiar) :
|
||||
|
||||
class Trumpet(Familiar):
|
||||
"""
|
||||
A class of familiars.
|
||||
"""
|
||||
|
Reference in New Issue
Block a user