#------------------------------------------------------------- # Name : Endgame # Purpose : 11DGT # Author : Cody Smeed # created : 19/02/2024 # Copyright : Cody Smeed and 19/02/2024 #------------------------------------------------------------- # Import Libraries import random import time # Set starting variables ------------------------------------- # Staring Health START_HP_THANOS = 100 #players health levels player_health = 0 thanos_health = 0 # Damage presets thanos_sword = 0 player_damage = 0 # Deflect Preset deflect = 0 # Player Decision preset player_choice = " " play_again = "y" #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, to finish this. this 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 a iron sword in the other.") time.sleep(4) print("will your strength be enough....") time.sleep(3) print("You are in the ENDGAME now") time.sleep(1) #start of play again loop while play_again == "y": #reset health levels for characters 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 ") thanos_health = START_HP_THANOS while True: try: print() player_health = int(input("slect 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") #start the game loop while thanos_health > 0 : #print current health levels time.sleep(1) print() print("Current Health") print(player_name + " has {} HP...".format(player_health)) print("Thanos has {} HP...".format(thanos_health)) time.sleep(2) #Player selects their action print() print("what do you choose?..") print("[a]ttack with mjolnir") print("or") print("[D]efend with your 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_damage = random.randint(1,20) print("you attack back with your sword in hand dealing {} damage in return".format(player_damage )) thanos_health = thanos_health - player_damage time.sleep(1) else: print("Thanos attacks you with his double bladed sword...") print("You raise your 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 your 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 player iron shield and he deals himself {} damage".format(thanos_sword)) thanos_health = thanos_health - thanos_sword time.sleep(1) # end the game loop. checking health values tp determine a winner 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...") #option to play again 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) #option to play again play_again = input("do you want to play again? [Y]es or [n]o...") #Game End time.sleep(2) print("Thanks for playing my game!") time.sleep(2)