#-------------------------------------------------------------------------- # Name : Endgame # Purpose : 11DGT # Author: Max Warrender # Created : 18/02/25 # Copyright : © Max 18/02/25 #-------------------------------------------------------------------------- # Import libraries import random import time #Starting Variables #Starting HP (Constant) cap_health_start = 50 thanos_health_start = 100 #Player Health levels cap_health = 0 thanos_health = 0 #Damage Presets cap_damage = 0 thanos_damage = 0 #Deflect preset deflect = 0 # Player Decision Preset cap_choice = "" play_again = "y" or "Y" while play_again == "y" : cap_health = cap_health_start thanos_health = thanos_health_start while thanos_health > 0: #Print current HP time.sleep(1) print() print("Current Health") time.sleep(1) print("Cap has {} HP...".format(cap_health)) time.sleep(1) print("Thanos has {} HP...".format(thanos_health)) time.sleep(2) #Player selects their next action. print() print("What do you choose to do..?") time.sleep(1) print("[a]ttack with Mjolnir") time.sleep(1) print("or") time.sleep(1) print("[d]efend") time.sleep(1) cap_choice = input (("Your choice...? ")) print() #Player Choices #Choice A if cap_choice == "a" or cap_choice == "A": thanos_damage = random.randint(1,20) print("Thanos attacks you with his double bladed sword and deals {} damage".format(thanos_damage)) cap_health = cap_health - thanos_damage if cap_health < 1: break time.sleep(1) cap_mjolnir = random.randint(1, 20) print("You attack back with Mjolnir in hand dealing {} damage in return".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 your shield and deflect to deflect the blow...") time.sleep(1) deflect = random.randint(1, 2) if deflect == 1 : thanos_damage = random.randint(1, 20) print("You were to slow in raising your shield and Thanos strikes you with his sword for {} damage".format(thanos_damage)) cap_health = cap_health - thanos_damage if cap_health < 1: break time.sleep(1) else: thanos_damage = random.randint(1, 20) print("Thanos' sword rebounds off Caps vibranium shield and he deals himself {} damage".format(thanos_damage)) thanos_health = thanos_health - thanos_damage time.sleep(1) # End of game loop. Checking health values to determine a winner if cap_health < 1: print() time.sleep(1) 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 option 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 option play_again = input("Do you want to play again. [y]es or [n]o... ") #End game time.sleep(2) print("Thanks for playing...") time.sleep(2)