• cant check were is a problem

 

From: https://py.checkio.org/mission/the-defenders/solve/

In 8 test is a fight with rookie and i dont know why, but my defender lose health after fight with him, i even cant check where is a problem coz i dont know what is rookie is, it try create my own rookie but it do nothing. Please help.

HTTP_USER_AGENT:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
       class Warrior:
            damage=5
            health=50
            is_alive=True
            def __init__(self):
                self.damage=5
                self.health=50
            def damaged_on(self,enemy_damage):
                self.health-=enemy_damage
                if self.health<=0:
                    self.is_alive=False
        class Rookie(Warrior):
            def __init__(self):
                self.damage=0
                self.health=1
        class Knight(Warrior):
            def __init__(self):
                self.damage=7
                self.health=50

        class Defender(Warrior):
            def __init__(self):
                self.damage=3
                self.health=60
                self.defense=2
            def damaged_on(self,enemy_damage):
                self.health-=(0,enemy_damage-self.defense)[enemy_damage and enemy_damage>self.defense]
                print(self.health)
                if self.health<=0:
                    self.is_alive=False
        class Rookie(Warrior):
            def __init__(self):
                self.damage=0
        class Army:
            def __init__(self):
                self.arrayWithUnits=[]
            def add_units(self,type,count):
                for i in range(count):
                    self.arrayWithUnits.append(type())
            def pop(self):
                if len(self.arrayWithUnits)>0:
                    return self.arrayWithUnits.pop()
                else:
                    return False

    class Battle:
        def fight(self,army1,army2):
            fighter1=army1.pop()
            fighter2=army2.pop()
            if not fighter2:
                return True
            if not fighter1:
                return False
            while True:
                if(fight(fighter1,fighter2)):
                    fighter2=army2.pop()
                    if  not fighter2:
                        return True
                else:
                    fighter1=army1.pop()
                    if not fighter1:
                        return False


    def round(f1,f2):
            f2.damaged_on(f1.damage)
            if f2.is_alive:
                f1.damaged_on(f2.damage)


    def fight(f1,f2):
        while True:
            if not f1.health:return False
            if not f2.health:return True
            round(f1,f2)
            if not f2.is_alive:
                return True
            elif not f1.is_alive:
                return False