Hi, can someone tell me how to decrease strength and live in game.

0 votes
asked Feb 29 by anonymous
class Hero:
  live=3
  strength=100
  attack=""
  while live!=0:
    print("Ready to attack")
    attack=input("Attack!!!:  ")
    if attack=='punch':
      print("Nice")
      strength -=20
    elif attack=='kick':
      print("cool")
      strength -=25
    elif attack=="double_kick":
      print("Nice kick")
      strength -=40
    elif attack== 'punch' and 'kick' and 'double_kick':
      print("you won!!!")
      strength -=100
      self.live -=1
    else:
      print('invalid')
      
      
exit()

1 Answer

0 votes
answered Mar 2 by Jacob Alawashez (160 points)
print("A beast appeared")
print("Tour health is 350")
print("The beast's health is 500")
class Hero:
  hero_health = 350
  hero_strength = 45
  beast_health = 500
  beast_damage = 20
  attack = ""
  while beast_health > 0:
    print("Ready to attack")
    attack = input("(A)ttack!!!:  ")
    if attack == 'A':
        beast_health = beast_health - hero_strength
        print("The beast is at",beast_health)
    else:
      print('Invalid')
      
    import random
    for x in range(1, 5):
        beast_attack = random.randint(1)
        if beast_attack > 1:
            hero_health = hero_health - beast_damage
            print("Your at",hero_health)
        else:
            print("The beast missed")

if hero_health < 1:
    print("Game Over")
elif beast_health < 1:
    print("Congrats, You win!!!")

#This code will let you choose to attack or not, and the beast attacks back based on a random number generator.

#I've got the victory done, but the code continues after you die, if you can figure out how to stop the program after you die let me know.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...