テキストベースのアドベンチャーゲームを作成しています。キャラクターは、街区で構成されたマップをナビゲートしています。キャラクターを取得してから、正しい隣接ブロックに移動する がありますdirection_function
。raw_input
ただし、ピックアップするアイテムやほとんどのブロックでやり取りする人々など、特別な機能があります。ここも私が使っraw_input
ています。適切なキーワードを入力すると対話しますが、方向を入力してそれらを無視すると、再びdirection_function
プロンプトを表示するに渡されraw_input
ます。direction_function
回答を繰り返す必要がないように、最初の回答を に渡す方法はありますか?
ここに私の方向関数があります:
def direction_function(left, right, up, down, re):
direc = raw_input(">")
if direc in west:
left()
elif direc in east:
right()
elif direc in north:
up()
elif direc in south:
down()
elif direc in inventory_list:
inventory_check()
re()
else:
print "try again"
re()
このようにブロックごとに機能を指定します
def block3_0():
print "You see a bike lying in your neighbor's yard. Not much else of interest."
direc = raw_input(">")
if direc in ("take bike", "steal bike", "ride bike", "borrow bike", "use bike"):
print "\n"
bike.remove("bike")
school_route()
else:
direction_function(block2_0, block4_0, block3_1, block3_0, block3_0)