Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Warriors by s1337
class Warrior:
def __init__(self):
self.attack = 5
self.health = 50
@property
def is_alive(self):
return self.health > 0
def decrease_health(self, damage):
self.health -= damage
class Knight(Warrior):
def __init__(self):
super().__init__()
self.attack = 7
def fight(unit_1, unit_2):
attacker, victim = unit_1, unit_2
while (attacker.is_alive and victim.is_alive):
victim.decrease_health(attacker.attack)
victim, attacker = attacker, victim
return unit_1.is_alive
Aug. 2, 2018
Comments: