Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Warriors by erewhon
class Warrior:
def __init__(self):
self.HP = 50
self.ATK = 5
self.is_alive = True
def dead(self):
if self.HP <= 0:
self.is_alive = False
class Knight(Warrior):
def __init__(self):
self.HP = 50
self.ATK = 7
self.is_alive = True
def fight(unit_1, unit_2):
while unit_1.is_alive:
unit_2.HP -= unit_1.ATK
unit_2.dead()
if not unit_2.is_alive:
return unit_1.is_alive
unit_1.HP -= unit_2.ATK
unit_1.dead()
return unit_1.is_alive
Jan. 8, 2020
Comments: