A normal gameIn this game you can play a normal game!
13
1
0
AaravGoel11import random
print("Welcome to the battle with computer game!\n")
print("In this game you have three choices! Attack, Defense and Heal. \nBy Default, you can only heal three times in one game!\nTo win, you have to kill the computer!\nThe computer is merciless so, only your luck can save you!")
list = ["attack","defense","heal"]
list1 = ["attack","defense"]
print("To select your attack please write 1 for attack, 2 for defense and 3 for heal!\n")
print("By default, you both only have 100 hp each!\n\nIf you attack and the computer attacks too, you both will lose 10 hp.\n\nWhen you will use defense and the computer will use attack, you will lose 5 hp!\n\nBy healing you can regain 20 hp points!\n")
print("Note: If you enter a wrong input, the previous input which you entered will be displayed!\n")
print("Good luck!\n")
php = 100
chp = 100
heal = 3
cheal = 3
x = "The computer chose to attack!"
y = "The computer chose to defend!"
z = "The computer chose to heal!"
a = "You chose to attack!"
b = "You chose to defend!"
c = "You chose to heal!"
yn = input("Do you want to know that what the computer is gonna choose everytime?Yes/No:")
yn = yn.lower()
print("Ok!")
player = 0
while True:
if chp == 100 or cheal == 0:
bot = random.choice(list1)
else:
bot = random.choice(list)
if yn == "yes":
print("The computer is gonna choose ... {} ...".format(bot))
try:
player = int(input("What do you wanna do?\nAttack = 1 / Defense = 2 / Heal = 3:"))
except ValueError:
print("Invalid Input!")
while True:
if heal == 0 and player == 3:
print("You cannot heal as you have run out of heals!")
try:
print("Enter your input again!")
player = int(input("What do you wanna do?\nAttack = 1 / Defense = 2 / Heal = 3:"))
if player != 3:
break
except ValueError:
print("Invalid input!")
elif php == 100 and player == 3:
print("You cannot heal as you already have full hp!")
try:
print("Enter your input again!")
player = int(input("What do you wanna do?\nAttack = 1 / Defense = 2 / Heal = 3:"))
if player != 3:
break
except ValueError:
print("Invalid input!")
else:
break
if player == 1:
print("You chose to attack")
if bot == "attack":
print("The computer chose to attack!")
print("Both chose to attack because of which you and the computer lost 10 hp!")
php -= 10
chp -= 10
elif bot == "defense":
print("The computer chose to defend!")
print("The computer lost 5 hp!")
chp -= 5
elif bot == "heal":
print("The computer chose to heal!")
print("The computer regained 10 hp")
cheal -= 1
chp += 10
print("The computer have {} heals left!".format(cheal))
elif player == 2:
print("The player chose to defend!")
if bot == "attack":
print("The computer chose to attack!")
print("You lost 5 hp!")
php -= 5
elif bot == "defense":
print(y)
print("Both chose to defend therefore nothing happened!")
elif bot == "heal":
print(z)
print("The computer regained 20 hp!")
cheal -=1
chp += 20
print("The computer have {} heals left!".format(cheal))
elif player == 3:
print(c)
heal -= 1
print("You have {} heal(s) left!".format(heal))
if bot == "attack":
print(x)
print("You regained 10 hp!")
php+=10
elif bot == "defense":
print(y)
print("You regained 20 hp!")
php+=20
elif bot == "heal":
print(z)
print("Both computer and you regained 20 hp!")
php+=20
chp+=20
cheal-=1
if php <= 0 and chp <= 0:
print("You and the computer fainted!")
print("It's a draw!")
break
elif chp <= 0:
print("The computer fainted!")
print("You won the game with {} hp left!".format(php))
break
elif php <= 0:
print("You fainted...")
print("The computer won the game with {} hp left...".format(chp))
break
else:
print("\nThe computer have {} hp left and you have {} hp left!\n".format(chp,php))
print("Thanks for playing the game!\n")
print("Made by Aarav with almost 150 lines of code!")1 month ago
50/50Welcome to 50/50
You are trying to survive the most rounds possible in this game.
At the beginning of every round you will randomly have a chance of surving the round. Your chances of surviving is 50% each time a new round begins.
4
2
0
boston2029Instead of "type anything", you should just say "Press Enter" or "Press any key"2 months ago