Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import random
- monsters = ['dragon', 'troll', 'orc']
- empty = []
- weapon = []
- def print_pause(text):
- print(text)
- #time.sleep(1)
- def clear_list():
- empty.clear()
- weapon.clear()
- def intro():
- print_pause("You find yourself standing in an open field, "
- "filled with grass and yellow wildflowers.")
- empty.append(random.choice(monsters))
- print_pause("Rumor has it that a " + str(empty[0]) +
- " is somewhere around here, and has been terrifying the near by village.")
- print_pause("In front of you is a house")
- print_pause("To your right is a dark cave")
- print_pause("In jour hand you hold your trusty (but not very effective) dagger.\n")
- def first_dilemma():
- print_pause("Enter 1 to knock on the door of the house")
- print_pause("Enter 2 to peer into the cave")
- the_path = str(input("What would you like to do?\n(Please enter 1 or 2)\n")).lower()
- return the_path
- def second_dilemma():
- chemin = str(input("Would you like to (1) fight or (2) run away?\n")).lower()
- return chemin
- def fight():
- print_pause("You approach the door of the house")
- print_pause("You are about to knock when the door opens and out step a " + str(empty[0]) + ".")
- print_pause("Eep! This is the " + str(empty[0]) + "\'s house!")
- print_pause("The wicked" + str(empty[0]) + " attacks you!")
- #this would need to be rewritten in a manner similar to path():
- second_dilemma()
- if "1" in second_dilemma():
- print_pause("The " + str(empty[0] +" runs away!"))
- print_pause("You are victorious")
- play_again()
- if "y" in play_again:
- gaming()
- else :
- print_pause("Thanks for playing, see you next time!")
- else :
- print_pause("You run back into the field. Luckily, you don't seem to have been followed.")
- first_dilemma()
- path()
- def play_again():
- play = str(input("Would you like to play again ? (y/n)\n")).lower()
- return play
- def one_chosen_in_first_dilemma():
- #we could rewrite it like the path() method:
- secon_dilemma_answer = second_dilemma()
- if "1" in secon_dilemma_answer:
- print_pause("You do your best...\nbut your dagger is no match for the " + str(empty[0]) + ".")
- print_pause("You have been defeated")
- play_again()
- if "y" in play_again():
- gaming()
- else:
- print_pause("Thanks for playing! See you next time.")
- elif "2" in secon_dilemma_answer:
- print_pause("You run back into the field. Luckily, you don't seem to have been followed.")
- first_dilemma()
- path()
- #here we want to ask the player again for their choice:
- else:
- one_chosen_in_first_dilemma()
- def path():
- first_dilemma_answer = first_dilemma()
- if "1" in first_dilemma_answer:
- print_pause("You approach the door of the house.")
- print_pause("You are about to knock when the door opens and out step a " + str(empty[0]) + ".")
- print_pause("Eep! This is the " + str(empty[0]) + "\'s house!")
- print_pause("The " + str(empty[0]) + " attacks you!")
- print_pause("You feel a bit under-prepared for this, what with only having a tiny dagger.")
- #we could rewrite it by adding a new method call here:
- one_chosen_in_first_dilemma()
- elif "2" in first_dilemma_answer:
- print_pause("You peer cautiously into the cave.")
- print_pause("Your eye catches a glint of metal behind a rock.")
- print_pause("You have found the magical Sword of Ogoroth!")
- print_pause("You discard your silly old dagger and take the sword with you.")
- print_pause("You walk back out to the field")
- weapon.append("sword")
- two_chosen_in_first_dilemma()
- first_dilemma()
- if "2" in first_dilemma() and "sword" in str(weapon[0]):
- print_pause("You've been here before, and gotten all the good stuff. It's just empty cave now.")
- print_pause("You walk back to the field")
- first_dilemma()
- if "1" in first_dilemma():
- fight()
- else:
- print_pause("You've been here before, and gotten all the good stuff. It's just empty cave now.")
- print_pause("You walk back to the field")
- first_dilemma()
- else:
- fight()
- #we did not get either "1" or "2" as our answer - let's ask again!
- else:
- path()
- def gaming():
- clear_list()
- intro()
- path()
- gaming()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement