#-------------------------------------------------------------------------- # Name : Endgame # Purpose : 11DGT # Author: Tyson Allerby # Created : 26/2/2024 # Copyright : © Tyson Allerby 26/2/2024 #-------------------------------------------------------------------------- # Import libraries import random import time #Set starting health (constant) start_hp_player=50 start_hp_than=100 #Basic varibles #Captain America varibles player_health = 50 player_dam = 20 player_choice = " " #Thanos varibles Than_health = 100 Than_dam = 20 #Deflection deflect = 0 play_again="y" #Intro #I got the slow writing online then put it through AI while True : player_name = input("What is your super hero name? ") if player_name.isalpha() == True : break else : print("Please enter a string input. J.A.R.V.I.S error ") while True : try: print() player_health = int(input("Select 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 lessons from the other avengers. ") def slowWriting(txt, speed=0.075): for c in txt: print(c, end='', flush=True) # Replace '\r' with '', and add flush=True time.sleep(speed) print("\n") # Move the sentence outside the fctunion slowWriting("The sky grows darker as Thanos and his army move closer.") # Call the function directly without . slowWriting("Thor and Ironman have been knocked out after a previous encounter. ") slowWriting("It is up to you, Cap, to finish this. The fate of the universe is your weight to bare.") slowWriting("You stand there, hurt. But you have your shield in one hand and wield Mjolnir in the other.") slowWriting("You are worthy, but will the power of Thor be enough....") time.sleep(2) slowWriting("You are in the ENDGAME now") #Damage #Health #start of play again loop while play_again == "y" : #reset health player_health = start_hp_player Than_health = start_hp_than while Than_health > 0: print( ) slowWriting("Current health is:") time.sleep(2) print("Cap has {} Hp...".format(player_health)) print("Thanos has {} Hp...".format(Than_health)) time.sleep(2) #Player Choice 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() #Choice A if player_choice == "a" : Than_dam = random.randint(1,20) print("Thanos attacks you with his double bladed sword and deals damage".format(Than_dam)) player_health = player_health - Than_dam if player_health < 1 : break time.sleep(2) player_dam = random.randint(1,20) slowWriting("You attack, dealing {} damage in return ".format(player_dam)) Than_health = Than_health - player_dam time.sleep #Choice D else : slowWriting("Thanos raises his weapon and attacks ") slowWriting("You raise your sheild to deflect the attack ") time.sleep(2) deflect = random.randint(1,2) if deflect == 1 : Than_dam = random.randint(1,20) print("You were to slow to raise youyr sheild and got striked with thanos's sword dealing {} damage. " .format(Than_dam)) player_health = player_health - Than_dam if player_health < 1: break time.sleep(2) else: Than_dam = random.randint(1,20) slowWriting("Thanos sword rebounds off captian Americas sheild and he hits himself dealing {}. ".format(Than_dam)) Than_health = Than_health - Than_dam time.sleep(1) #END if player_health < 1: print( ) slowWriting("Thanos is too strong. He has broken your shield and cut you down. This is the end of all life in our universe...") else : slowWriting("Thanos has fallen!") time.sleep(2) slowWriting("You drop to your knees, exhausted. ") time.sleep(2) slowWriting("It is safe...") time.sleep(2) print(" For Now...") #play again play_again = input("Do you want to play again? [y]es or [n]o...") slowWriting("Thanks for playing.")