#-------------------------------------------------------------------------- # Name : Endgame Task # Purpose : 11DGT # This code by : Aesir #-------------------------------------------------------------------------- import random import time START_HP_THANOS = 100 player_health = 0 thanos_health = 0 thanos_sword = 0 player_mjolnir = 0 deflect = 0 player_choice = " " player_name = " " play_again = "y" while True : player_name = input("Before we start, what is your hero's name? ") if player_name.isalpha() == True : break else : print("Please enter a string input, JARVIS error") while True : try : print() player_health = int(input("Choose a health level for {} between 50-80: ".format(player_name))) if player_health < 50 or player_health > 80 : print() print("Please select an amount between 50-80.") else : break except : print() print("That isn't a number, you may need some more lessons with Tony or Bruce.") START_HP_PLAYER = player_health print("The sky grows darker as the armys of Thanos move 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, {}, to finish this. The fate of the universe is your weight to bare.".format(player_name)) time.sleep(3.5) print("You stand there, hurt. But you have Cap's shield in arm hand and wield Mjolnir in the other.") time.sleep(4) print("You are worthy, but will the power of Thor be enough....") time.sleep(1) while play_again == "y" : player_health = START_HP_PLAYER thanos_health = START_HP_THANOS while thanos_health > 0 : time.sleep(1) print() print("Current Health") print("{}".format(player_name)) print("has {} HP...".format(player_health)) print() print("Thanos") print("has {} HP...".format(thanos_health)) time.sleep(2) print() print("What do you choose?..") print("[a]ttack with Mjolnir") print("or") print("[d]efend with Cap's shield") player_choice = input(("Your choice?... ")) print() if player_choice == "a" : thanos_sword = random.randint(1, 20) print("Thanos attacks you with his double bladed sword and deals {} damage".format(thanos_sword)) player_health = player_health - thanos_sword if player_health < 1: break time.sleep(1) player_mjolnir = random.randint(1, 20) print("You attack back with Mjolnir in hand dealing {} damage in return".format(player_mjolnir)) thanos_health = thanos_health - player_mjolnir time.sleep(1) else: print("Thanos attacks you with his double bladed sword...") print("You raise Cap's shield and deflect to deflect the blow...") time.sleep(1) deflect = random.randint(1, 2) if deflect == 1 : thanos_sword = random.randint(1, 20) print("You were to slow in raising Cap's shield and Thanos' strikes you with his sword for {} damage".format(thanos_sword)) player_health = player_health - thanos_sword if player_health < 1: break time.sleep(1) else: thanos_sword = random.randint(1, 20) print("Thanos' sword rebounds off Cap's shield and he deals himself {} damage".format(thanos_sword)) thanos_health = thanos_health - thanos_sword time.sleep(1) if player_health < 1: time.sleep(1) print() print("Thanos is too strong. He has broken Cap's shield and cut you down. This is the end of all life in our universe...") play_again = input("Do you want to play again? (y/n) ") else: time.sleep(1) print() 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(3) print("It is safe...") time.sleep(3) print("...For now...") time.sleep(5) play_again = input("Do you want to play again? (y/n) ") if play_again == "n" : break