I am working on a text-based adventure game. Essentially I want to return the correct event depending on what the user types. Right now, it gives the same event no matter what the user types (EVENT_DRAGON is returned every time). The majority of the game, the user had choices between 1, 2, or 3. Which works perfectly fine and well, but I wanted to switch it up and ask the user for a word input. This hasn't been working correctly.. Clarification on why it would work with numbered input but not word input would be appreciated. Thank you.
def main():
import sys
def run_event(event):
text, choices = event
text_lines = text.split("\n")
for line in text_lines:
print('' + line)
print("")
choices = choices.strip("\n")
choices_lines = choices.split("\n")
for num, line in enumerate(choices_lines):
print('' + line)
print("")
print ("")
print ("You have found yourself stuck within a dark room, inside this room are 5 doors.. Your only way out..")
print ("")
print ("Do you want to enter door 1,2,3,4, or 5?")
print ("")
EVENT_DOOR3 = ("""
A dragon awaits you
""","""
'Welcome' remarks the dragon. 'Do you wish to escape?""")
EVENT_DRAGON = ("""
'Good choice' says the dragon. Where would you like to escape to?
""","""
1. Just get me out of here!
2. Where should I escape to?
""")
EVENT_DRAGON2 = ("""
Interesting..
""","""
Test..
""")
door = input("> ")
if door == "3":
run_event(EVENT_DOOR3)
dragon = input()
if dragon in ['yes','Yes']:
run_event(EVENT_DRAGON)
elif dragon in ['no','No']:
run_event(EVENT_DRAGON2)
main()