Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.55 KB | None | 0 0
  1. import time
  2. import random
  3. monsters = ['dragon', 'troll', 'orc']
  4. empty = []
  5. weapon = []
  6. def print_pause(text):
  7. print(text)
  8. #time.sleep(1)
  9.  
  10. def clear_list():
  11. empty.clear()
  12. weapon.clear()
  13.  
  14. def intro():
  15. print_pause("You find yourself standing in an open field, "
  16. "filled with grass and yellow wildflowers.")
  17. empty.append(random.choice(monsters))
  18. print_pause("Rumor has it that a " + str(empty[0]) +
  19. " is somewhere around here, and has been terrifying the near by village.")
  20. print_pause("In front of you is a house")
  21. print_pause("To your right is a dark cave")
  22. print_pause("In jour hand you hold your trusty (but not very effective) dagger.\n")
  23.  
  24.  
  25. def first_dilemma():
  26. print_pause("Enter 1 to knock on the door of the house")
  27. print_pause("Enter 2 to peer into the cave")
  28. the_path = str(input("What would you like to do?\n(Please enter 1 or 2)\n")).lower()
  29. return the_path
  30.  
  31. def second_dilemma():
  32. chemin = str(input("Would you like to (1) fight or (2) run away?\n")).lower()
  33. return chemin
  34.  
  35. def fight():
  36. print_pause("You approach the door of the house")
  37. print_pause("You are about to knock when the door opens and out step a " + str(empty[0]) + ".")
  38. print_pause("Eep! This is the " + str(empty[0]) + "\'s house!")
  39. print_pause("The wicked" + str(empty[0]) + " attacks you!")
  40. #this would need to be rewritten in a manner similar to path():
  41. second_dilemma()
  42. if "1" in second_dilemma():
  43. print_pause("The " + str(empty[0] +" runs away!"))
  44. print_pause("You are victorious")
  45. play_again()
  46. if "y" in play_again:
  47. gaming()
  48. else :
  49. print_pause("Thanks for playing, see you next time!")
  50. else :
  51. print_pause("You run back into the field. Luckily, you don't seem to have been followed.")
  52. first_dilemma()
  53. path()
  54.  
  55. def play_again():
  56. play = str(input("Would you like to play again ? (y/n)\n")).lower()
  57. return play
  58.  
  59. def one_chosen_in_first_dilemma():
  60. #we could rewrite it like the path() method:
  61. secon_dilemma_answer = second_dilemma()
  62. if "1" in secon_dilemma_answer:
  63. print_pause("You do your best...\nbut your dagger is no match for the " + str(empty[0]) + ".")
  64. print_pause("You have been defeated")
  65. play_again()
  66. if "y" in play_again():
  67. gaming()
  68. else:
  69. print_pause("Thanks for playing! See you next time.")
  70. elif "2" in secon_dilemma_answer:
  71. print_pause("You run back into the field. Luckily, you don't seem to have been followed.")
  72. first_dilemma()
  73. path()
  74. #here we want to ask the player again for their choice:
  75. else:
  76. one_chosen_in_first_dilemma()
  77.  
  78. def path():
  79. first_dilemma_answer = first_dilemma()
  80.  
  81. if "1" in first_dilemma_answer:
  82. print_pause("You approach the door of the house.")
  83. print_pause("You are about to knock when the door opens and out step a " + str(empty[0]) + ".")
  84. print_pause("Eep! This is the " + str(empty[0]) + "\'s house!")
  85. print_pause("The " + str(empty[0]) + " attacks you!")
  86. print_pause("You feel a bit under-prepared for this, what with only having a tiny dagger.")
  87.  
  88. #we could rewrite it by adding a new method call here:
  89. one_chosen_in_first_dilemma()
  90.  
  91. elif "2" in first_dilemma_answer:
  92. print_pause("You peer cautiously into the cave.")
  93. print_pause("Your eye catches a glint of metal behind a rock.")
  94. print_pause("You have found the magical Sword of Ogoroth!")
  95. print_pause("You discard your silly old dagger and take the sword with you.")
  96. print_pause("You walk back out to the field")
  97. weapon.append("sword")
  98.  
  99. two_chosen_in_first_dilemma()
  100.  
  101. first_dilemma()
  102. if "2" in first_dilemma() and "sword" in str(weapon[0]):
  103. print_pause("You've been here before, and gotten all the good stuff. It's just empty cave now.")
  104. print_pause("You walk back to the field")
  105. first_dilemma()
  106. if "1" in first_dilemma():
  107. fight()
  108. else:
  109. print_pause("You've been here before, and gotten all the good stuff. It's just empty cave now.")
  110. print_pause("You walk back to the field")
  111. first_dilemma()
  112. else:
  113. fight()
  114. #we did not get either "1" or "2" as our answer - let's ask again!
  115. else:
  116. path()
  117.  
  118.  
  119.  
  120.  
  121. def gaming():
  122. clear_list()
  123. intro()
  124. path()
  125.  
  126. gaming()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement