I am making an escape room text adventure game and for each instance of my Room
class I have a dictionary containing instances of my Door
class. The class looks like this:
class Door:
def __init__(self, to, open=False):
self.to = to
self.open = open
The to
variable references another instance of my Room
class. I cannot for the life of me figure out how to define the rooms whilst referencing other ones in the doors. For example, there is a door that goes from room A
to room B
and is defined in each of the rooms doors (the door in A
has a .to
of class B
and vice versa). But I can't give the door in room A
a .to
of room B
as it isn't defined yet. The same goes the other way around. Is there a way to do this that i'm not seeing?