def fight(self, enemy) -> int: damage = 0 if enemy.location == self.location: if enemy.strength > self.strength or enemy.health_points > self.health_points: damage = (self.strength + self.human_pride) else: damage = Actor.fight(self, enemy) return damage
def test_fight(): actor = Actor(0) actor.strength = 25 enemy = Actor(1) enemy.health_points = enemy.unit_max() actor.location[0] = 50 actor.location[1] = 50 enemy.location[0] = 50 enemy.location[1] = 50 assert actor.fight(enemy) == 25
def move_actor(self, enemy): if self.runs >= self.max_runs( ): # Limit how often a hobbit can run away self.runs = 0 Actor.move_actor(self, enemy) elif self.fear > enemy.strength and self.strength < enemy.health_points and self.dependence > 50: # X Movement if enemy.location[0] > self.location[0]: self.location[0] = self.location[0] - self.speed elif enemy.location[0] < self.location[0]: self.location[0] = self.location[0] + self.speed # Y Movement if enemy.location[1] > self.location[1]: self.location[1] = self.location[1] - self.speed elif enemy.location[1] < self.location[1]: self.location[1] = self.location[1] + self.speed self.runs += 1 else: Actor.move_actor(self, enemy) # Actor.keep_in(self) # If a hobbit runs out off the battlefield they are considered dead to us self.seppuku() enemy.take_damage(Actor.fight(self, enemy))