gpt4 book ai didi

python - RPG 游戏的 Python 语法无效

转载 作者:行者123 更新时间:2023-11-30 22:56:22 24 4
gpt4 key购买 nike

我对 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com