我对 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 ("---------------------------------------------------------")
最佳答案
您需要关闭房间
字典:
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 ("---------------------------------------------------------")
关于python - RPG 游戏的 Python 语法无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37039810/