我相对较新的Python,并且在创建基本的python RPG wordquest类型游戏的过程中。我在def showInstructions():
上一直收到无效的语法。
rooms = {
1 : { "name" : "Hall" },
2 : { "name" : "Bedroom" },
3 : { "name" : "Kitchen" },
4 : { "name" : "Bathroom" }
def showInstructions():
#The Main Menu
print ("Mr Bailey's Nightmare!")
print ("======================")
print ("Commands:")
print ("go [direction]'")
def showStatus
#shows player stats, essentially current room
print ("---------------------------------------------------------")
print ("You are in the " + rooms[currentRoom]["name"]
print ("---------------------------------------------------------")
答案 0 :(得分:3)
您需要关闭rooms
字典:
rooms = {
1 : { "name" : "Hall" },
2 : { "name" : "Bedroom" },
3 : { "name" : "Kitchen" },
4 : { "name" : "Bathroom" }
需要
}
所以
rooms = {
1 : { "name" : "Hall" },
2 : { "name" : "Bedroom" },
3 : { "name" : "Kitchen" },
4 : { "name" : "Bathroom" }
}
您的语法也在showStatus
def showStatus(currentRoom): # is this the right argument?
#shows player stats, essentially current room
print ("---------------------------------------------------------")
print ("You are in the " + rooms[currentRoom]["name"])
print ("---------------------------------------------------------")