import sys, time, random print('you arent the first') print(' you are one of many trying to link the fire, your journy starts now') damage_done_by_hit = 1 def start(): print('You are standing at the door of a large castle.') choice = input('Press E to enter or R to run away ') if choice == 'r': print ('you ran away') print ('YOU LOSE') sys.exit(0) elif choice == 'e': print ('You enter the castle') entered_castle() else: print('please read the instructions you silly person.') def entered_castle(): print('as you enter the castle you notice the walls are lined with torches') choice = input ('Press E to continue or press R to take a torch ') if choice == 'r': print ('you hear mechanical whiring and the floor drops out from under you') print ('candles on the walls slowly ilumanate the room') print ('"WHO DARES ENTER MY CHAMBER" a voice shrieks from above') print (' the dancer of the boral valey drops down from the celing') print ('the dancer pulls to flaming simitars from the ground') choice = input ( 'press E to stand your ground or press R to die ' ) if choice == 'r': dead() if choice == 'e': boss_fight() elif choice == 'e': continue_into_castle() else: dead('read the instructions. Bet you dab a lot.') def boss_fight(): while True: time_lunged = time.time() choice = input ('the dancer lunges, press any key to dodge ') time_dodged = time.time() time_taken_to_dodge = time_dodged - time_lunged # print(time_taken_to_dodge) if time_taken_to_dodge < 1: print('you dodged fast enough. you did not get hit') else: print('toooooooo slow. you were impaled and die a gorey painful death. bummer.') dead() def continue_into_castle(): print('''you walk for a few minutes in absolute darkness until you see a light you walk out into a small room not much bigger than the corridor a sword the looks rusty lays next to a large chest ''') choice = input (' Press E to open the chest or press R to take the sword ') if choice == 'e': print ('''you open the chest to see a shining sabre, and a row of teeth emerge from the chest ''') print ('the mimic bit you in half') dead() if choice == 'r': print ('you pick up the sword and find that its made of fine steel') print ('you conntinue down the hallway, out of the castle') print ('youre in a courtyard with a large knight') print ('the knight raises his sword') choice = input ('press e to continue') if choice == 'e': knight_boss_fight() def knight_boss_fight(): knight_health = 5 while True: time_lunged = time.time() choice = input ('the knight swings his sword, press enter key to dodge ') time_dodged = time.time() time_taken_to_dodge = time_dodged - time_lunged if time_taken_to_dodge < 3: print('you dodged fast enough. you did not get hit') time_lunged = time.time() choice = input ('the knight swings his sword again, press enter key to dodge ') time_dodged = time.time() time_taken_to_dodge = time_dodged - time_lunged if time_taken_to_dodge < 1.5: print('you dodged fast enough. you did not get hit') else: dead() did_swing_sword = input('press E to swing your sword ') if did_swing_sword == 'e': knight_health = knight_health - damage_done_by_hit print('you hit the knight, knight health is now ', knight_health) if knight_health == 0: print ('the knight is dead') break else: print('toooooooo slow. you were sliced in two.') dead() take_sword_or_not = input('press e to take the knights sword. press r to leave. ') if take_sword_or_not == 'e': take_sword() if take_sword == 'r': leave_knight() else: print('you died of unabletoreadtheinstructionsitis.') dead() def take_sword(): global damage_done_by_hit print('You now have a better sword. On with the adventure, flashypants. ') damage_done_by_hit = 2 leave_knight() def leave_knight(): print('''you continue onto a flight of stairs leading to a tower that soars above the clouds. as you finish your ascent, a figure in golden armor stands atop the stairs "I AM THE NAMELESS KING, ALL WHO ENTER MUST FALL, THY SHALL NOT LINK THE FIRE."''') choice = input ('press enter to fight') NAMELESS_KING() def NAMELESS_KING(): king_health = 20 while king_health > 0: you_hit = random.randint(0, 1) if you_hit: swing = input('The Nameless King pauses. Press E to slash. ') if swing == 'e': king_health = king_health - damage_done_by_hit print ('you hit the Nameless King. You did ', damage_done_by_hit, 'damage. his health is', king_health) else: time_doge = time.time() dodge = input('Nameless_King swings at you. press enter to dodge ') time_doged = time.time() time_taken_to_doge = time_doged - time_doge if time_taken_to_doge < 2: print('you dodged rolled out of the way') else: print('. you were impaled and die a gorey painful death.') dead() print (' you killed the Nameless king, conglaturation') print(' You WIN') def dead(): print('YOU DIED') sys.exit(0) start()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question