Example being: I am trying to get the print statement from Hero.checkLife to print when I input 1. I did a little testing and it seems like it correctly gets the input but just skips the if/elif statements. Not sure why, any tips would be greatly appreciated. The formatting is correct in python but copying into here didn't go super smoothly.
class Hero:
life = 200
def checkLife(self):
if self.life <= 0:
print("Oh no! Hero has fallen")
else:
print("Hero has " + str(self.life)+ " life!")
def attackedByEnemy(self):
self.life -= 45
class Enemy:
life = 115
def checkLife(self):
if self.life <= 0:
print("Enemy has fallen!")
else:
print("Enemy has " + str(self.life)+ " life!")
def attakedByHero(self):
self.life -= 55
hero = Hero()
enemy = Enemy()
while Enemy.life > 0:
action = input("Enter attack. \n 1. Check Hero life \n 2. Check
Enemy life \n 3. Attack the enemy \n 4. Attack the hero \n")
if action == 1:
hero.checkLife()
elif action == 2:
enemy.checkLife()
elif action == 3:
enemy.attakedByHero()
elif action == 4:
hero.attackedByEnemy()