• The Defenders

 

Hello,

I have problem with mission The Defenders. On checks i have recived strange errors (see attached screen).

My Code:

class Army:
    def __init__(self):
        self.units = []

    def add_units(self,unit,count):
        self.units.extend([unit() for i in range(count)])

    def unit_die(self):
        self.units.remove(self.units[0])

    def getUnit(self):
        return self.units[0]

    @property
    def has_warriors(self):
        return len(self.units) > 0 


class Warrior:

    def __init__(self, health=50, strange=5, defense=0):
        self.health = health
        self.strange = strange
        self.defense = defense

    def attack(self, opponent):
        hit_points = self.strange - opponent.defense
        if hit_points > 0:
            opponent.health -= hit_points


    @property
    def is_alive(self):
        return self.health > 0



class Knight(Warrior):
    def __init__(self, health=50, strange=7, defense=0):
        super().__init__(health, strange, defense)

class Defender(Warrior):
    def __init__(self, health=60, strange=3, defense = 2):
        super().__init__(health, strange, defense)

class Rookie(Warrior):
    def __init__(self, health=50, strange=1, defense = 0):
        super().__init__(health, strange, defense)

class Battle():

    def fight(self,army_1: Army,army_2: Army):
        while army_1.has_warriors and army_2.has_warriors:
            if fight(army_1.getUnit(),army_2.getUnit()):
                army_2.unit_die()
            else:
                army_1.unit_die()
        return army_1.has_warriors

def fight(unit_1, unit_2):
    while unit_1.is_alive and unit_2.is_alive:
        unit_1.attack(unit_2)
        if unit_2.is_alive:
            unit_2.attack(unit_1)
        else:
            return True
    return False
.