我正在制作一个基于文本的游戏,这是我用来建立房间属性的文件。每当我尝试通过打印 room3 的房间描述(打印 Room3.desc)来测试此文件时,我都会收到错误消息:AttributeError: type object 'Room3' has no attribute 'desc'
class Room:
def __init__(self, x, y, desc):
self.x=x
self.y=y
self.desc=desc
class Room1(Room):
def __init__(self, x, y, desc):
super(Room1, self).__init__()
self.x=0
self.y=0
self.desc="""
A Metal Hallway
This place is dimly lit and cool
----------------------------------------------------
You stand in the middle of an intersection in a metal room.
There are blue glowing lamps lighting this area up. There
is a sign on the wall.
----------------------------------------------------
Obvious exits:East, North"""
class Room2(Room):
def __init__(self, x, y, desc):
super(Room2, self).__init__()
self.x=1
self.y=0
self.desc="""
Thacker's Main Control Room
This place is well lit and cool
----------------------------------------------------
There are multiple panels throughout with a variety of levers and buttons.
People stand in uniforms infront of computers, which are scattered throughout the room.
There is a glass window here revealing space.
Thacker is sitting here in the back of the room in a large chair.
----------------------------------------------------
Obvious exits:West"""
class Room3(Room):
def __init__(self, x, y, desc):
super(Room3, self).__init__()
self.x=0
self.y=1
self.desc== """
Large Hanger Bay
This place is well lit and cool
----------------------------------------------------
There are a variety of mobile suits here
----------------------------------------------------
Obvious exits:South"""
print("%s" % Room3.desc)