行,
所以我目前正在研究一个简单的文本 rpg(在 Python 中)。但由于某种原因,我的一个功能是读取奇怪的输入。
现在,地牢中的每个房间都是一个独立的功能。这是不工作的房间:
def strange_room():
global fsm
global sword
global saw
if not fsm:
if not saw:
print "???..."
print "You're in an empty room with doors on all sides."
print "Theres a leak in the center of the ceiling... strange."
print "In the corner of the room, there is an old circular saw blade leaning against the wall."
print "What do you want to do?"
next6 = raw_input("> ")
print "next6 = ", next6
if "left" in next6:
zeus_room()
elif "right" in next6:
hydra_room()
elif "front" or "forward" in next6:
crypt_room()
elif ("back" or "backwad" or "behind") in next6:
start()
elif "saw" in next6:
print "gothere"
saw = True
print "Got saw."
print "saw = ", saw
strange_room()
else:
print "What was that?"
strange_room()
if saw:
print "???..."
print "You're in an empty room with doors on all sides."
print "Theres a leak in the center of the ceiling... strange."
print "What do you want to do?"
next7 = raw_input("> ")
if "left" in next7:
zeus_room()
elif "right" in next7:
hydra_room()
elif "front" or "forward" in next7:
crypt_room()
elif ("back" or "backwad" or "behind") in next7:
start()
else:
print "What was that?"
strange_room()
我的问题是获得我的意见。这个函数一直执行到第 17 行。似乎第一次需要输入,但是打印输入的 print 语句没有执行。然后,除此之外,只有左、右和前/前命令正常工作。我输入的任何其他内容都只会执行“front”/“forward”应该执行的 crypt_room() 函数。
谢谢。