# Import libraries import random import time # Set starting variables ----------------------------------- # Starting Health Player_health = 50 thanos_health = 100 Player_choice = "" play_again = "y" while True : player_name = input("What is your superhero name? ") if player_name.isalpha() == True : break else: print("Please enter a string input. J.A.R.V.I.S error") # Intro print("The sky grows darker as the army of Thanos moves closer.") time.sleep(2) print("Thor and Tony lie battered and motionless on the ground from the previous encounter.") time.sleep(3) print("It is up to you, Cap, to finish this. The fate of the universe is your weight to bear.") time.sleep(3.5) print("You stand there, hurt. But you have your shield in one hand and wield Mjolnir in the other.") time.sleep(4) print("You are worthy, but will the power of Thor be enough....") time.sleep(3) print("You are in the ENDGAME now") time.sleep(1) while thanos_health > 0 and Player_health > 0: # Print current health levels time.sleep(1) print("\nCurrent Health") print("Cap has {} HP...".format(Player_health)) print("Thanos has {} HP...".format(thanos_health)) time.sleep(2) # Player selects their action print("\nWhat do you choose?..") print("[a]ttack with Mjolnir") print("or") print("[d]efend with your shield") Player_choice = input("Your choice?... ").lower() # Player choice if Player_choice == "a": # Thanos attacks thanos_sword = random.randint(1, 20) print("Thanos attacks you with his double-bladed sword and deals {} damage.".format(thanos_sword)) Player_health -= thanos_sword if Player_health <= 0: continue time.sleep(1) # Cap attacks cap_mjolnir = random.randint(1, 20) print("You attack back with Mjolnir in hand, dealing {} damage in return.".format(cap_mjolnir)) thanos_health -= cap_mjolnir elif Player_choice == "d": print("Thanos attacks you with his double-bladed sword...") print("You raise your shield to deflect the blow...") time.sleep(1) deflect = random.randint(1, 2) if deflect == 1: thanos_sword = random.randint(1, 20) print("You were too slow in raising your shield, and Thanos strikes you with his sword for {} damage.".format(thanos_sword)) Player_health -= thanos_sword else: thanos_sword = random.randint(1, 20) print("Thanos' sword rebounds off Cap's vibranium shield, and he deals himself {} damage.".format(thanos_sword)) thanos_health -= thanos_sword time.sleep(1) # Check for end of loop condition if Player_health <= 0 or thanos_health <= 0: break # End of game loop. Checking health values to determine a winner if Player_health <= 0: print("Thanos is too strong. He has broken your shield and cut you down. This is the end of all life in our universe...") else: print("Thanos has fallen!") time.sleep(.5) print("You drop to your knees, exhausted.") time.sleep(.5) print("You stare out into a grateful universe.") time.sleep(1) print("It is safe...") time.sleep(3) print(" ..For now...") time.sleep(5) play_again = input("Do you want ot play again? [y] yes or [n] no") time.sleep(2) print("thanks for playing my game") time.sleep(2)