# Name : Endgame # Purpose : 11DGT # Author: Shay McDonald # Created : 19/02/2024 # Copyright : © Shay McDonald 19/02/2024 import random import time player_health = 0 thanos_health = 100 thanos_sword = 0 player_damage = 0 deflect = 0 player_choice = " " play_again = input("Would you like to play? (y/n): ") while play_again.lower() == "y": player_name = input("What do you want your name to be?: ") while True: if player_name.isalpha(): break else: print("Please enter a valid name!") player_health = random.randint(50, 80) print() print("Hello {}, your current health is {}.".format(player_name, player_health)) print("The sky grows darker as the army of Thanos moves closer.") print(" ") time.sleep(2) print("Thor and Tony lie battered and motionless on the ground from the previous encounter.") print(" ") time.sleep(3) print("It is up to you, Cap, to finish this. The fate of the universe is your weight to bear.") print(" ") time.sleep(3.5) print("You stand there, hurt. But you have your shield in one hand and wield Mjolnir in the other.") print(" ") time.sleep(4) print("You are worthy, but will the power of Thor be enough....") print(" ") time.sleep(3) print("You are in the ENDGAME now") print(" ") time.sleep(1) print("Current Health") print("Caps Health = {}".format(player_health)) print("Thanos Health = {}".format(thanos_health)) print(" ") time.sleep(2) while thanos_health > 0: cap_choice = input("You are Cap do you want to: Attack or Defend? (a/d): ") if cap_choice.lower() == "a": print(" ") print("Attack!") time.sleep(1) print(" ") print("Thanos is attacking...") thanos_sword = random.randint(1, 20) player_health -= thanos_sword time.sleep(1) print(" ") print("Thanos has attacked!") time.sleep(1) print(" ") print("Cap took", thanos_sword, "damage") time.sleep(1) print(" ") print("Current Health") print("Caps Health = {}".format(player_health)) print("Thanos Health = {}".format(thanos_health)) print(" ") time.sleep(2) if player_health <= 0: print(" ") print("Game Over") print(" ") print("Cap Health = 0") print(" ") print("THANOS WINS!") break time.sleep(1) print("Cap is attacking...") cap_mjolnir = random.randint(1, 20) thanos_health -= cap_mjolnir time.sleep(1) print(" ") print("Cap has attacked!") time.sleep(1) print(" ") print("Thanos took", cap_mjolnir, "damage") time.sleep(1) print(" ") print("Current Health") print("Caps Health = {}".format(player_health)) print("Thanos Health = {}".format(thanos_health)) print(" ") time.sleep(2) elif cap_choice.lower() == "d": print(" ") print("Defend!") time.sleep(1) print(" ") print("Cap is defending...") time.sleep(1) deflect = random.randint(1, 2) if deflect == 1: print(" ") print("Attack Deflected!") time.sleep(1) cap_mjolnir = random.randint(1, 20) thanos_health -= cap_mjolnir print(" ") print("Thanos took", cap_mjolnir, "damage!") time.sleep(1) print(" ") print("Current Health") print("Caps Health = {}".format(player_health)) print("Thanos Health = {}".format(thanos_health)) print(" ") if thanos_health <= 0: print(" ") print("Thanos has fallen!") time.sleep(1) print(" ") print("It is safe...") time.sleep(1) print(" ") print("Game Over") print(" ") print("Thanos Health = 0") time.sleep(1) print(" ") print("CAP WINS!") print(" ") break elif deflect == 2: print(" ") print("Attack was not deflected!") time.sleep(1) thanos_sword = random.randint(1, 20) player_health -= thanos_sword print(" ") print("Cap took", thanos_sword, "damage!") time.sleep(1) print(" ") print("Current Health") print("Caps Health = {}".format(player_health)) print("Thanos Health = {}".format(thanos_health)) print(" ") if player_health <= 0: print(" ") print("Game Over") print(" ") print("Cap Health = 0") print(" ") print("THANOS WINS!") print(" ") break play_again = input("Would you like to play again? (y/n): ") if play_again.lower() != "y": print("Thanks for playing!")