class Room: def __init__(self,name,monsters=[],north_room=None,east_room=None,south_room=None,west_room=None,required_keys=[]): self.name = name self.monsters = monsters self.north_room = north_room self.east_room = east_room self.south_room = south_room self.west_room = west_room self.required_keys = required_keys def get_room(self,direction): match direction: case "W": return self.north_room or self case "D": return self.east_room or self case "S": return self.south_room or self case "A": return self.west_room or self case _: return self def __str__(self): return self.name Hall = Room("Hall") Foyer = Room("Foyer") Kitchen = Room("Kitchen") Garden = Room("Garden") ArtGallery = Room("Art Gallery") GreatHall = Room("Great Hall") DiningHall = Room("Dining Hall") Bedroom = Room("Bedroom") Cellar = Room("Cellar") Library = Room("Library") Hall.north_room = Foyer Foyer.north_room = Kitchen Kitchen.north_room = Garden Library.north_room = Bedroom DiningHall.north_room = ArtGallery Bedroom.north_room = Cellar Foyer.east_room = ArtGallery Bedroom.east_room = ArtGallery Garden.south_room = Kitchen Kitchen.south_room = Foyer Foyer.south_room = Hall Cellar.south_room = Bedroom Bedroom.south_room = Library GreatHall.south_room = ArtGallery ArtGallery.south_room = DiningHall ArtGallery.west_room = Foyer Foyer.west_room = Bedroom curr_room = Hall while True: print(curr_room.name) print( "[W]",curr_room.north_room,"\n"+ "[A]",curr_room.west_room,"\n"+ "[S]",curr_room.south_room,"\n"+ "[D]",curr_room.east_room,"\n" ) move_to = input("Dir: ") if move_to == "x": quit() curr_room = curr_room.get_room(move_to.upper())