#-------------------------------------------------------------------------- # Name : Endgame # Purpose : 11DGT # Author: Daniel # Created : Date 19/02/2024 # Copyright : © Daniel Bruton 2024 #-------------------------------------------------------------------------- #Import libraries import time import random START_THANOS_HEALTH = 100 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 ") player_health = 0 while True: try: player_health = int(input("Select a health amount for {} between 50 and 80... ".format(player_name))) if player_health < 50 or player_health > 80 : print() print("Please select an amount between 50 and 80") else: break except: print() print("That is not a number... you may need some additional tutoring from Mr Stark or Banner") playagain = "y" healtht = START_THANOS_HEALTH player_damage = 0 damaget = 0 deflectchance = 0 choicep = "" #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,", player_name, "to finish this. The fate of the universe is your weight to bare.") time.sleep(3.5) print("You stand there, hurt. But you have your 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(3) print("You are in the ENDGAME now") time.sleep(2) while playagain == "y" : while healtht > 0 : player_damage = random.randint(1, 20) damaget = random.randint(1, 20) print("Health points:") print(player_name, player_health) print(" Thanos", healtht) time.sleep(2) print("") print("Possible actions:") print(" (a)ttack with Mjolnir") print(" (d)efend with your shield") print("") choicep = str(input("What do you choose?.. ")) print("") if choicep == "a" : print("Thanos attacks with his sword...") print("He deals you",damaget,"damage") player_health -= damaget print("You swing Mjolnir...") print("You deal Thanos", player_damage, "damage") healtht -= player_damage if player_health < 1 : break else: print("Thanos attacks with his sword...") deflectchance = random.randint(1,2) if deflectchance == 1 : print("You raise your shield and deflect the blow") print("The rebounding blow deal Thanos", damaget, "damage") healtht -= damaget if player_health < 1: break else: print("Thanos attacks with his sword...") print("You were to slow to raise your shield and Thanos strikes you with his sword for", damaget) player_health -= damaget if player_health < 1: break if player_health < 1: print() print("Thanos is too strong. He has broken your 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]es or [n]o...") else: 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(1) print("It is safe...") time.sleep(3) print(" ..For now...") time.sleep(5) play_again = input("Do you want to play again [y]es or [n]o...") if play_again == "n": break time.sleep(2) print("Thanks for playing my game!") time.sleep(2)