我正在尝试编写文字冒险。我为房间中的对象创建了一个类。在以下代码中,
self.door = Object("Door", "There is an {} door in the north.".format("closed" if self.door.openstate == False else "open"), True, False, door_text, True, False)
我希望立即检测门是打开还是关闭,并相应地更改描述。我知道上面的代码肯定是错误的,但是有办法吗?
我不确定是否能回答您的问题,但是我认为您需要为门创建一个单独的类,但我不确定100%。我假设您在这样的教室里上课:
class Room:
def __init__(self):
self.door = your_code_here