from sys import exit
def dead(why):
print why, "Better luck next time in the next life!"
exit(0)
def strange_man():
print """As you take way on to your adventure... You meet this strange man.
He tells you that he can not be trusted. He tells you that the door on the
right is going to be good. He also tells you that the left door will lead you to good
as well. But you cannot trust him... Which door do you pick?"""
next = raw_input("Do you choose the left door or right? \n >")
if next == "left" or "Left":
good_door()
elif next == "right" or "Right":
evil_door()
else:
dead("You are drunk and can't seem to choose a door. Bye.")
def good_door():
print """You seem to have chosen a door that has three distinct routes. You still do not know
whether or not your choice of doors were correct... You hesitate to choose which route you take
but you have to choose..."""
next = raw_input("Which route do you choose? You have an option between Route 1, Route 2, or Route 3 \n >")
if "Route 1" in next:
print "Wow! You can't believe it! You are in heaven! You seem to have chosen the right door."
exit(0)
elif "Route 2" in next:
desert()
else:
dead("You walk ahead into this route and then you suddenly fall and then a log hits your head, it seems like it was a trap. You're left a bloody mess.")
def desert():
print """You walk into a desert and it's unbearably hot... You have two options... You stay here and hope
that somebody will save you, or you keep walking... Which one do you choose?"""
next = raw_input("Do you choose to stay or move? \n >")
if "stay" in next:
dead("You die of thirst")
elif "move" in next:
good_door()
def evil_door():
print """You enter this door and you see two routes, which one do you choose?"""
next = raw_input("You choose from the left route or the right route. \n >")
if next == "left":
good_door()
else:
dead("The route you chose seems to only go to Hell... You see satan and he eats you.")
strange_man()
我的问题出在奇怪的曼函数中,当我选择“正确”时,它会回到 good_door 函数而不是应该的 evil_door 函数......我不知道它为什么这样做!我似乎是对的:/
这是为我们制作自己的 CLI 文本游戏的 Learn Python The Hard Way 中的 ex36...