我正在制作典型的文字游戏程序而且我已经停留在重启功能上了。我想重新启动房间实例,但是当我尝试删除对象时,我得到了AttributeError:room1。这里有一些伪代码:
class Room:
inventory = []
__init__(self, itemsInRoom, doors):
#makes a room instance and puts some items and doors into the room
self.roomItems = []
self.roomDoor = []
for item in itemsInRoom:
#puts initial items into the room
self.roomItems.append(item)
for eachDoor in doors:
#tells the instance what doors there are
self.roomDoor.append[doors]
Def functionsBlahBlah():
Pass
class RoomNumber:
room1 = Room(['stool', 'tavern wench', 'bar keep'], ['north', 'east'])
room2 = Room(so on and so forth)
def functionsBlahBlah():
Pass
def restartFunction():
del RoomNumber.room1
del RoomNumber.room2
startGame()
def startGame():
RoomNum()#initializes rooms
main()
startGame()
所以无论如何,我尝试在重启功能中删除RoomNumber.room1,这样我就可以转身并用它的原始项目和东西重新初始化它。正如我所说,我得到一个错误。关于我哪里出错的任何想法?