Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Warriors by martin_b
class Warrior:
def __init__(self):
self.is_alive = True
self.health = 50
self.attack = 5
def attacked(self, attack):
self.health -= attack
self.is_alive = self.health > 0
return self.is_alive
class Knight(Warrior):
def __init__(self):
super().__init__()
self.attack = 7
def fight(u1, u2):
while True:
if not u2.attacked(u1.attack):
return True
if not u1.attacked(u2.attack):
return False
Aug. 2, 2019