我觉得我已经尝试了一切来使这个工作,它只是不会运行... 我还在学习python,我的课程在几个月前就开始了秋天的开始。
长话短说,我正在使用Python制作基于文本的“逃离房间”游戏。玩家选择要与之交互的对象,结果会让他们使用项目,直到他们找到解锁门的钥匙。为了节省我的理智,它非常简短和线性。
我认为这是我的代码中没有运行的部分,它是一个包含所有4个对象的类似代码的大函数(对不起,如果它有点长。
这基本上都是这样,“当他们选择这幅画时,如果他们想要搜索它们,请描述它,(1 =是,2 =否)。
如果有,请描述搜索结果。 因为这是故事的最后一个对象(绘画背后的安全有门钥匙),一旦打开保险箱并且他们有钥匙,我不希望它再次向他们询问主要问题,但确实如此!?< / p>
重复的主要问题是;
def main_choice_input():
main_choice = input("""
What would you like to check out? (1=Bed, 2=Desk, 3=Dresser, 4=Painting): """)
return main_choice;
#code for describing the objects, the inputs for the player to search them
#and the search results, if tried to name them as self-explanatory as
#possible
以前的格式用于其他对象,这是一个很大的功能。
while main_choice == "4":
painting_description()
#painting_input is the "search this?" question
painting_input = painting_interaction()
if painting_input =="1":
painting_search(painting_input,dresser_input)
if use_key=="1" and painting_input =="1":
#If they 'used the key' on the desk to get the code:
painting_search(painting_input,dresser_input)
unlock = input("""
Would you like to unlock the safe? [1=Yes/2=No]: """)
if unlock == "1":
#print (story for opening the safe)
safe=1 #for ending the game- checking if the safe is open
if unlock == "2":
print("""
That's too bad, let's try again...""")
main_choice = main_choice_input()
main_route(main_choice,bed_input,desk_input,dresser_input,
painting_input,use_key,)
if painting_input =="2":
print("""
The code must be around here somewhere... Let's keep looking!
""")
#main_route is the name of this whole function
main_choice = main_choice_input()
main_route(main_choice,bed_input,desk_input,
dresser_input,painting_input,use_key,)
#I had it re-ask and re-run here too, so if they dont have the code/choose not to search or whatever, they can go back and get it
break
while main_choice != "1" or main_choice != "2" or main_choice != "3" or
main_choice != "4":
main_choice = main_choice_input()
main_route(main_choice,bed_input,desk_input,dresser_input,painting_input,use_key,)
return;
我的问题是这个程序甚至没有运行unlock = input函数,它会播放搜索描述然后询问主要的“你想要签出什么”这样的问题;
Take a look? [1=Yes/2=No]
1
You walk up and inspect the painting as if it were displayed in a museum.
It's clearly just a copy of the painting, not even trying to be the real thing.
You begin to notice that the painting is hanging a couple inches off the wall...
You grab the painting on either side of the frame, and gently place it on
the floor, revealing a safe built into the wall!
What would you like to check out? (1=Bed, 2=Desk, 3=Dresser, 4=Painting):
而不是最后一个问题,应该问我是否要打开保险箱,因为我得到了代码,但事实并非如此?为什么?请帮忙,我很失落和沮丧。