Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
OOP solution in Clear category for The Warriors by fishsouprecipe
class Warrior:
def __init__(self):
self.hp = 50
self.damage = 5
@property
def is_alive(self) -> bool:
return self.hp > 0
class Knight(Warrior):
def __init__(self):
super().__init__()
self.damage = 7
def fight(war1, war2):
beater = war1
beat = war2
while all(war.is_alive for war in (war1, war2)):
beat.hp -= beater.damage
beat, beater = beater, beat
return war1.is_alive
March 5, 2020