我正在创造一个文本RPG的灵感来自旧的文字冒险,玩家输入英文命令;如“拿起剑”等。 我已经建立了一个简单的;输入'A'来做到这一点,并输入'B'来做到这一点,但我想扩大我的系统以获得更多的自由。 我需要创建一个系统;当玩家键入一个命令时,程序挑选出关键词。 我认为这可以通过'in'命令实现。 这里是我的代码:英文命令[文字RPG] - 蟒蛇
print "What would you like to do??"
input_loop_sleep = str('')
choice_sleep = raw_input(str('>>>'))
loop_sleep = False
table_time = False
bed_time = False
error_time = False
while loop_sleep == False:
if str('sleep') in choice_sleep or str('bed') in choice_sleep or str('goodnight') in choice_sleep or str('Sleep') in choice_sleep or str('tired') in choice_sleep:
while bed_time == False:
print "you decide to go back to sleep"
time.sleep(1)
print "..."
time.sleep(1)
print ""
time.sleep(1)
print "darkness"
time.sleep(1)
print ""
print "you wake up..."
time.sleep(1)
print "it is now 9:15am"
time == int(9.15)
time.sleep(1)
print "You are standing in your room, slightly more refreshed."
time.sleep(1)
print "there is a table with some things on it, stairs, and a wardrobe... with the doors wide open..."
time.sleep(1)
print "that's strange... you swear that they were shut when you went to sleep..."
break
else:
bed_time == True
break
bed_loop_choice = raw_input('>>>')
elif str('bedside') in choice_sleep or str('table') in str(choice_sleep):
while table_time == False:
print "You rub your eyes and pick up some belongings from a"
print "bedside table."
time.sleep(1)
print "Map added!"
time.sleep(1)
print "100 gold added!"
time.sleep(1)
print "Leather Bag added!"
cash == int(100)
time.sleep(1)
Map == str('map of', str(province))
Inventory == [str(Map)]
container == str('leather bag')
print "your", str(container), str("contains a"), str(Map), str('and'), str(cash)
break
else:
table_time == True
break
else:
print "invalid command!"
当我运行的代码
,无论我在里面输入的内容总是与“睡眠”选项进入。 我可能只是犯了一些简单的错误! 你能帮我解决我做错了什么,以及我如何解决它。
下载不公开。请尽量让您的问题自成一体。 –
请详细描述您的问题,并在此发布您的相关代码。 –
修复了问题 – Dannyboy8899