Ok、
だから私は現在 (Python で) シンプルなテキスト RPG に取り組んでいます。しかし、何らかの理由で、私の関数の 1 つが入力を奇妙に読み取っています。
現在、ダンジョン内の各部屋は個別の機能です。動かない部屋はこちら
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 ステートメントは実行されません。その上で、左、右、および前後のコマンドのみが正しく機能します。私が入力した他のものは、「フロント」/「フォワード」が実行する必要があるcrypt_room()関数のみを実行します。
ありがとう。