Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Warriors by DeCooper
class Warrior:
def __init__(self):
self.health = 50
self.attack = 5
@property
def is_alive(self):
return self.health > 0
class Knight(Warrior):
def __init__(self):
self.health = 50
self.attack = 7
def fight(a, b):
while True:
if a.is_alive == False:
return False
b.health -= a.attack
if b.is_alive == False:
return True
a.health -= b.attack
Aug. 31, 2018