#-------------------------------------------------------------------------- # Name : Endgame # Purpose : 11DGT # Author: Julius Mahara # Created : Date # Copyright : © Julius Mahara 22/02/2024 #-------------------------------------------------------------------------- #import libraries import random import time play_again = "y" # Set Starting variable ----------------------------------- # Starting health (CONSTANT) START_HP_CAP = 50 START_HP_THANOS = 100 #Player health levels cap_health = 0 thanos_health = 0 # Damage Preset thanos_sword = 0 cap_mjolnir = 0 # Deflect preset deflect = 0 #Player Decision Preset cap_choice = " " #Start of play again loop while play_again == "y" : #Start of game loop while thanos_health > 0 : #---------------------------------------------------------- #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 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(1) print () print ("Current HP") print ("Cap has {} HP...").format(cap_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 sheild") cap_choice = input("Your choice?") print() #Player Choice #Choice A if cap_choice == "a": thanos_sword = random.randint (1, 20) print("Thanos attacks you with his double bladed sword and deals {} damage").format(thanos_sword) cap_health = cap_health - thanos_sword while cap_health <1: break time.sleep(1) cap_mjolnir = random.randint(1, 20) print("You attack back with mjolnir in hand dealing {} damage in retun").format(cap_mjolnir) thanos_health = thanos_health - cap_mjolnir time.sleep(1) #Choice D else: print ("Thanos attacks you with his double bladed sword") print ("You raise you sheild and get ready to deflect the blow..") time.sleep(1) deflect = random.randint(1, 2) if deflect == 1 : print ("You wre too slow for thanos. He strikes you hard and deals {} damage").format(thanos_sword) cap_health = cap_health - thanos_sword while cap_health <1: break time.sleep(1) else: thanos_sword = random.randint (1, 20) print ("Thanos' sword rebounds off caps big old sheild and he deals himself {} damage.").format(thanos_sword) thanos_health = thanos_health - thanos_sword time.sleep(1) # End of game loop. checking health values to determine a winner. if cap_health < 1: print() print("Thanos is too stong. he has destroyed your sheild and beat you up and down. This is the end of the world as known.") else: print () print("Thanos is defeated!") time.sleep(5) print ("You take a seat.. just to catch a breather...") time.sleep(5) print ("You take a great look out towards the battlefield.") time.sleep(3) print("Victoy is yours.") time.sleep(3) print(" Or is it..") time.sleep(3) #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)