#------------------------------------------------------------- # Name : final boss # 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_demonking = 500 #players health levels player_health = 0 demonking_health = 0 # Damage presets demon_firesword = 0 player_damage = 0 # Deflect Preset deflect = 0 dodge = 0 # Player Decision preset player_choice = " " play_again = "y" #Intro print("your time has come ") time.sleep(2) print("you arrived at the castle.") time.sleep(3) print("you slam the door open ready for battle.") time.sleep(3.5) print("the demon king sit on his throme waiting for you.") time.sleep(4) print("he stands up and holds his sword ready for battle") time.sleep(3) print("the world in your hands now 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 hero name?") if player_name.isalpha() == True: break else: print("please enter a string input.") demonking_health = START_HP_demonking while True: try: print() player_health = int(input("slect a health amount for {} between 150 and 200...".format(player_name))) if player_health < 150 or player_health > 200 : print() print("please select an amount between 150 and 200") else: break except: print() print("That is not a number your not strong enough to have that much health") #start the game loop while demonking_health > 0 : #print current health levels time.sleep(1) print() print("Current Health") print(player_name + " has {} HP...".format(player_health)) print("demon king has {} HP...".format(demonking_health)) time.sleep(2) #Player selects their action print() print("what do you choose?..") print("[a]ttack with your holy sword") print("or") print("[D]efend with your magic shield") player_choice = input("your choice?...") print() if player_choice == "a" : dodge = random.randint(1,3) if dodge == 1: print("the demon king attack but you were quick enough to get out of the way") time.sleep(1) player_damage = random.randint(20,70) print("you attack back with your holy sword in hand dealing {} damage in return".format(player_damage )) demonking_health = demonking_health - player_damage time.sleep(1) else: demon_firesword = random.randint(20,30) print("demon king attacks you with his fire sword and deals {} damage".format(demon_firesword)) player_health = player_health - demon_firesword if player_health < 1: break time.sleep(1) player_damage = random.randint(20,70) print("you attack back with your holy sword in hand dealing {} damage in return".format(player_damage )) demonking_health = demonking_health - player_damage time.sleep(1) else: print("demon king attacks you with his fire sword...") print("You cast your magic shield and deflect to deflect the blow...") time.sleep(1) deflect = random.randint(1,2) if deflect == 1 : demon_firesword = random.randint(20,30) print("You were to slow in casting your shield and demon king strikes you with his sword for {} damage".format(demon_firesword)) player_health = player_health - demon_firesword if player_health < 1: break time.sleep(1) else: demon_firesword = random.randint(20,50) print("demon king' fire sword rebounds off player magic shield and he deals himself {} damage".format(demon_firesword)) demonking_health = demonking_health - demon_firesword time.sleep(1) # end the game loop. checking health values tp determine a winner if player_health <1: print() print("you failed, your life hit 0 as your body falls to the floor as he raises his sword to deal the final blow") #option to play again play_again = input("do you want to play again? [Y]es or [n]o...") else: print() print("you did it the demon king is dead") time.sleep(.5) print("You drop to your knees, exhausted") time.sleep(.5) print("you look at the towns in city now safe from the evil") time.sleep(1) print("you pick up your sword and walks over to the body") time.sleep(3) print("to claim your trophy") 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)