Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Warriors by tokiojapan55
class Warrior:
def __init__(self, hp=50, atk=5):
self._hp = hp
self._atk = atk
@property
def is_alive(self):
return self._hp > 0
def attackedBy(self, unit):
self._hp -= unit._atk
return self.is_alive
class Knight(Warrior):
def __init__(self, hp=50, atk=7):
super().__init__(hp, atk)
def fight(unit_1, unit_2):
while True:
if not unit_2.attackedBy(unit_1):
return True
if not unit_1.attackedBy(unit_2):
return False
return not unit_2.is_alive
June 22, 2020