我正在创建一个基于文本的冒险游戏。角色正在导航由城市街区组成的地图。我有一个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)