#-------------------------------------------------------------------------- # Name : Endgame # Purpose : 11DGT # Author: Alex # Created : 17/02/2025 # Copyright : © Your name and Date #-------------------------------------------------------------------------- import random import time START_HP_THANOS = 100 player_health = 0 thanos_health = 0 player_mjolnir = random.randint(1,20) thanos_sword = random.randint(1,20) player_shield = random.randint(1,2) 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" ) print() print( "Thanos stands calmly above you." ) time.sleep(1) print( "You are alone." ) time.sleep(1) print( "However," ) time.sleep(1) print( "Mjolnir deems you worthy to lift it." ) time.sleep(1) print( "Time appears to stop as once again you stand up with hammer and shield ready." ) time.sleep(1) print( "You're in the Endgame now..." ) while play_again == "y": thanos_health = START_HP_THANOS while True: try: print() player_health = int( input( "Set {} health between 50 and 80: ".format(player_name) ) ) if player_health < 50 or player_health > 80: break except: print() print( "That is not a number..." ) break while thanos_health > 0: print() print( "Current Health" ) print( "{} has {} health".format(player_name, player_health) ) print( "Thanos has {} health".format(thanos_health) ) time.sleep(1) print() print( "[a]ttack" ) print( "[d]efend" ) player_choice = input( "Your choice...? " ) print() if player_choice == "a" or player_choice == "A": thanos_sword = random.randint(1,20) print( "Thanos attacks you with his 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 return his attack with a swing from Mjolnir that deals {} damage".format(player_mjolnir) ) thanos_health = thanos_health - player_mjolnir time.sleep(1) else: print("Thanos attacks you with his double bladed sword...") time.sleep(1) print("You raise your shield and deflect to deflect the blow...") time.sleep(2) player_shield = random.randint(1,2) if player_shield == 1: thanos_sword = random.randint(1,20) print( "You were slow to lift you shield and Thanos strikes you 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 of the sturdy vibranium shield and deals {} back to him".format(thanos_sword) ) thanos_health = thanos_health - thanos_sword time.sleep(1) if player_health < 1: print() print( "Thanos is too strong. He has broken your shield and cut you down. Thus is the end of all life in our universe..." ) time.sleep(2) print() play_again = input( "Do you wish to play again? [y] or [n]: " ) 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 greateful universe." ) time.sleep(1) print( "It is safe..." ) time.sleep(3) print( " ..For now..." ) time.sleep(5) print() play_again = input( "Do you wish to play again? [y] or [n]: " ) time.sleep(1) print( "Thanks for playing" ) time.sleep(2)