I am making a text adventure game. I'm using a named tuple to define locations.
Location = namedtuple('Location', ['desc', 'ldesc', 'func', 'dirloc'])
entrance = foyer = None
entrance = Location('Dungeon Entrance', (
'You are in a small clearing in a forest. '
'To the north, a large iron-studded door is visible, '
'embedded in a small hill that rises up in the middle of the clearing. '
'The sun shines down upon you and birds sing.'), None,
{'north':foyer, 'south':None, 'east':None, 'west':None, 'up':None, 'down':None})
foyer = Location('Foyer', ('You are in a medium-sized room made of stone. '
'Alcoves are carved along the wall at all angles. '
'One passage leads west. Another leads north. '
'Footsteps on the ground lead towards the west passage.'),
None,
{'north':None, 'south':entrance, 'east':None, 'west':None, 'up':None, 'down':None})
I need the foyer variable in the dictionary dictloc
in the entrance location to automatically update when the real foyer location is defined. How can I do this? I have scoured the internet for articles but found nothing that was related.
I have tried over and over using different data structures to see if I could find one that worked. Unfortunately, none did.