Trying to get random riddle to pop up but I get an error instead

Help again! I am writing a game for my daughter and I was trying to get the game to ask a random riddle, but I get an error in the process. Please help! I will include the whole program in case the error is in another part of the code. The error is happening in the Cellar class . I went through the prcoess of testing the game: open window, climb into window, grab bone, go through doorway,
give dog the bone, grab lantern, approach dragon. Please let me know what I can do. Thanks in advance.
Here is the code:

from sys import exit
from random import randint
from textwrap import dedent

class Scene(object):
    
    def enter(self):
        print("This scene is not yet configured.")
        print("Subclass it and implement enter().")
        exit(1)

class Engine(object):

    def __init__(self, scene_map):
        self.scene_map = scene_map
    
    def play(self):
        current_scene = self.scene_map.opening_scene()
        last_scene = self.scene_map.next_scene('finished')

        while current_scene != last_scene:
            next_scene_name = current_scene.enter()
            current_scene = self.scene_map.next_scene(next_scene_name)

        current_scene.enter()

class Riddle:

    riddle = ' '

class FirstRiddle(Riddle):

    def first_riddle():
        Riddle.riddle = "What is always on its way, but never arrives?"

class SecondRiddle(Riddle):

    def second_riddle():
        Riddle.riddle = "What thrives when you feed it, but dies when you water it?"

class ThirdRiddle(Riddle):

    def third_riddle():
        Riddle.riddle = "What do you hold but never keep?  If you take your last, make it deep."

class FourthRiddle(Riddle):

    def fourth_riddle():
        Riddle.riddle = "I don't breathe flames, but I light the night, guiding sailors with my steady sight.  I stand tall on cliffs, where dragons might dwell, but I save lives with every bell.  What am I?"

class FifthRiddle(Riddle):

    def fifth_riddle():
        Riddle.riddle = "They come out at night without being asked yet lost in the day without being stolen.  What are they?"

class Location:

    location = ' '

class First(Location):
    
    def first_def():
        Location.location = 'start'

class Second(Location):

    def second_def():
        Location.location = 'dark_woods'

class Third(Location):

    def third_def():
        Location.location = 'outside_house_without_bone'

class Fourth(Location):

    def fourth_def():
        Location.location = 'outside_house_with_bone'

class Fifth(Location):

    def fifth_def():
        Location.location = 'foyer'

class Sixth(Location):

    def sixth_def():
        Location.location = 'living_room'

class Seventh(Location):

    def seventh_def():
        Location.location = 'cellar'

class Death(Scene):
    
    def enter(self):
        
        if  Location.location in ('start', 'dark_woods', 'outside_house_without_bone', 'outside_house_with_bone'):
            print("Day becomes night and you're devoured by wolves.")
            
        elif Location.location in ('foyer', 'living_room'):
            print("The dog chews your leg off and you bleed to death.")
            
        elif Location.location == 'cellar':
            print("The dragon burns you to a crisp.")
            
        else:
            print("You are turned into a rodent and eaten by an owl.")
            
        print("You're dead!  Better luck next time!") 
        exit(1)        

class Start(Scene):
      
    def enter(self):
        First.first_def()
        print(dedent("""
                    Welcome to Arcamadius, where magic and creatures exist.
                    You come to a house in the dark woods.
                    There is a window on the east wall and a door on the
                    South wall.  The house is surrounded by woods. What
                    would you like to do?
                     """))
        action = input("> ")

        if action == 'open window':
            print(dedent("""
                        You open the window.  It makes a squeaking noise.
                        What do you wnat to do now?
                        """ ))
            action = input("> ")

            if action == 'climb into window':
                print("You enter the window into the kitchen.")
                return 'kitchen'
            else:
                print("You just stand there!")
                return 'death'
            
        elif action == 'open door':
            print("You enter the door into the Foyer")
            return 'foyer'
        else:
            return 'death'

class OutsideHouseWithoutBone(Scene):

    def enter(self):
        Third.third_def()
        have_bone = False
        print(dedent("""
                    You are at a house in the dark woods.
                    There is a window on the east wall and a door on the
                    South wall.  The house is surrounded by woods. What
                    would you like to do?
                     """)) 
        action = input("> ")

        if action == 'open window':
            print(dedent("""
                        You open the window.  It makes a squeaking noise.
                        What do you wnat to do now?
                        """ ))
            action = input("> ")

            if action == 'climb into window':
                print("You enter the window into the kitchen.")
                return 'kitchen'
            else:
                print("You just stand there!")
                return 'death'
        elif action == 'open door':
            print("You enter the door into the Foyer")
            return 'foyer'
        else:
            return 'death'
        
class OutsideHouseWithBone(Scene):
    
    def enter(self):
        Fourth.fourth_def()
        have_bone = True
        print(dedent("""
                    You are at a house in the dark woods.
                    There is an open window on the east wall and a door on the
                    South wall.  The house is surrounded by woods. You are 
                    carrying a bone.  What would you like to do?
                    """)) 
        action = input("> ")

        if action == 'climb into window':
                print("You enter the window into the kitchen.")
                return 'kitchen_with_bone'
        elif action == 'open door':
            print("You enter the door into the Foyer")
            return 'foyer_with_bone'
        else:
            return 'death'

        
class Kitchen (Scene):

    def enter(self):
        have_bone = False
        print(dedent("""
                     There is a doorway ahead.  There is also a table
                     with a bone on it.  What do you wnat to do?
                     """))
        action = input("> ")

        if action == "go through doorway" and have_bone == True:
            return 'living_room'
        elif action == "grab bone" and have_bone == False:
            print("You grab the bone")
            return 'kitchen_with_bone'
        elif action == "climb out window":
            return 'outside_house_without_bone'
        else:
            print("I'm not sure what you are saying.")
            self.enter(self) 
            
class KitchenWithBone(Scene):

    def enter(self):
        have_bone = True
        print(dedent("""
                     There is a doorway ahead.  There is also an empty
                     table.  What do you wnat to do?
                     """))
        action = input("> ")

        if action == "go through doorway" and have_bone == True:
            return 'living_room'
        elif action == "climb out window":
            return 'outside_house_with_bone'
        else:
            print("I'm not sure what you are saying.")
            self.enter(self)    

class Foyer(Scene):
    
    def enter(self):
        Fifth.fifth_def()
        have_bone = False
        print(dedent("""
                     A huge dog is staring and growling at you
                     What do you do?
                     """))
        action = input("> ")

        if action == "flee":
            print(dedent("""
                         You managed to get away from the dog chasing you and the
                         dog goes back into the house.
                         """))
            return 'outside_house_without_bone'
        elif action == "give dog the bone" and have_bone == False:
            print("you have no bone.")
            return 'death'
        else:
            print("I have no idea what that means.")
            return 'foyer'

class FoyerWithBone(Scene):

    def enter(self):
        have_bone = True
        print(dedent("""
                     A huge dog is staring and growling at you and you are
                     carrying a bone.  What do you do?
                     """))
        action = input("> ")

        if action == "flee":
            print(dedent("""
                         You managed to get away from the dog chasing you and the
                         dog goes back into the house.
                         """))
            return 'outside_house_with_bone'
        elif action == "give dog the bone" and have_bone == True:
            print(dedent("""
                        You give the dog the bone.
                        The dog wants to play.  You play with the dog for awhile.
                        Now back to business. The entrance to the living room
                        is ahead.
                        """))
            return 'living_room'
        else:
            print("I have no idea what that means.")
            return 'foyer_with_bone'

class LivingRoom(Scene):

    def enter(self):
        Sixth.sixth_def()
        have_bone = True
        print(dedent("""
                     You are in the living room.  There is a trap door in the floor.
                     There is a mantle with an electric lantern on it.  A huge dog
                     is staring and growling at you.  You are carrying a bone.  What
                     would you like to do?
                     """))
        action = input("> ")

        if action == "give dog the bone" and have_bone == True:
            print(dedent("""
                        You give the dog the bone.
                        The dog wants to play.  You play with the dog for awhile.
                        The dog goes asleep. You are in the living room.  There is
                        a trap door in the floor.  There is a mantle with an electric
                        lantern on it.  What would you like to do?
                        """))
            action = input("> ")

            if  action == "grab lantern":
                print(dedent("""
                             You grab the lantern and turn it on. You are in the
                             living room.  There is a trap door in the floor.
                             There is an empty mantle.  You open the trap door.
                             """))
                return 'cellar'
            else:
                print(dedent("""
                             The dog wakes up from its slumber and is hungry.  It 
                             growls and snarls at you.
                             """))
                return 'death'
        else:
            return 'death'

class DarkWoods(Scene):
    
    def enter(self):
        pass

class Cellar(Scene):

    def enter(self):
        Seventh.seventh_def()
        print(dedent("""
                     You open the open the door to the cellar and a foul
                     stench is coming from the darkness.  You head into 
                     the cellar.  In the corner, you see a dragon laying
                     on a bed of gold.  On top of the gold is a nest and
                     in the nest is five dragon eggs What would you like
                     to do?
                     """))
        action = input("> ")

        if action == "grab some gold":
            print(dedent("""
                         The dragon awakens in a fury and says, 'How dare 
                         thee take my gold!  For that you will perish!'
                         """))
            return 'death'
        elif action == "grab an egg":
            print(dedent("""
                         The dragon awakens in a fury and says, 'How dare 
                         thee take one of my eggs!  For that you will perish!'
                         """))
            return 'death'
        elif action == "approach dragon":
            print(dedent("""
                         You approach the dragon and ask the dragon, 'How may I
                         obtain an egg from you?'  The dragon says, '
                         You must first answer a riddle.  Then you will get an egg'
                         """))
        else:
            print("I'm not sure what you mean.")
            return 'cellar'
        
            riddle_number = f"{randint(1,5)}"
            guesses = 1

            if riddle_number == 1:
                print(FirstRiddle.first_riddle())
                guess = input("[your answer]> ")
                answer = "Tomorrow"
            elif riddle_number == 2:
                print(SecondRiddle.second_riddle())
                guess = input("[your answer]> ")
                answer = "Fire"
            elif riddle_number == 3:
                print(ThirdRiddle.third_riddle())
                guess = input("[your answer]> ")
                answer = "A breath of air"
            elif riddle_number == 4:
                print(FourthRiddle.fourth_riddle())
                guess = input("[your answer]> ")
                answer = "A lighthouse"
            else:
                print(FifthRiddle.fifth_riddle())
                guess = input("[your answer]> ")
                answer = "Stars"

            while guess != answer and guesses < 3:
                print("Try again!")
                guesses += 1
                guess = input("[your answer]> ")

            if guess == answer:
                print(dedent("""
                             You have answered correctly.  You carefully chooose
                             an egg.  The dragon speaks some magic words and you 
                             are teleported to the Dark Woods.
                             """))
                return 'dark_woods'

class WitchHouse(Scene):

    def enter(self):
        pass

class Finished(Scene):

    def enter(self):
        pass

class Map(object):
    scenes = {
        'start': Start(),
        'outside_house_without_bone': OutsideHouseWithoutBone(),
        'outside_house_with_bone': OutsideHouseWithBone(),
        'kitchen': Kitchen(),
        'kitchen_with_bone': KitchenWithBone(),
        'foyer': Foyer(),
        "foyer_with_bone": FoyerWithBone(),
        'living_room': LivingRoom(),
        'dark_woods': DarkWoods(),
        'cellar': Cellar(),
        'witch_house': WitchHouse(),
        'death': Death(),
        'finished': Finished(),
    }

    def __init__(self, start_scene):
        self.start_scene = start_scene

    def next_scene(self, scene_name):
        val = Map.scenes.get(scene_name)
        return val
    
    def opening_scene(self):
        have_bone = False
        return self.next_scene(self.start_scene)

a_map = Map('start')
a_game = Engine (a_map)
a_game.play()

Hello,

I noticed that you included the test script from my last response into your program. This is not what I meant … atleast not verbatim. The classes named First ... Third in my response from your previous query were meant to represent the classes in your script and were not meant to be added to it. What I meant was that instead of using a return, you can simply use the global variable update.

For example, in your class Start(Scene), instead of doing this:

return 'kitchen'

and

return 'foyer'

you can do this:

Location.location = 'kitchen'

and

Location.location = 'foyer'

Notice how the compare variable Location.location is being updated depending on the circumstance. The value of this variable is visible throughout the other classes including the Death class where the comparison is made to determine which message to display.

The same logic can be applied to the other "return"s. In other words, delete the First ... Seventh classes from your script and only keep the new Location class.

Okay, I apologize for the misunderstanding!

You can redesign the Riddle classes. Instead of creating a class for each riddle method, you can create one Riddles class that includes all of the riddle methods. This should simplify the code a bit more by making it less verbose than it needs to be.

class Riddle:

    riddle = ' '

class Riddles(Riddle):

    @staticmethod
    def first_riddle():
        Riddle.riddle = "What is always on its way, but never arrives?"

    @staticmethod
    def second_riddle():
        Riddle.riddle = "What thrives when you feed it, but dies when you water it?"

    @staticmethod
    def third_riddle():
        Riddle.riddle = "What do you hold but never keep?  If you take your last, make it deep."

    @staticmethod
    def fourth_riddle():
        Riddle.riddle = "I don't breathe flames, but I light the night, guiding sailors with my steady sight.  I stand tall on cliffs, where dragons might dwell, but I save lives with every bell.  What am I?"

    @staticmethod
    def fifth_riddle():
        Riddle.riddle = "They come out at night without being asked yet lost in the day without being stolen.  What are they?"


# Examples of calling some of the riddles:
Riddles.first_riddle()  # Call the first riddle
Riddles.second_riddle()  # Call the second riddle
Riddles.third_riddle()  # Call the third riddle

Note that if you do not have a def __init__ constructor in your classes, this implies that you are not creating any objects for that class (also known as instances). If this is the case, there is no need to include the self in methods in those classes. In such cases, they are @staticlasses.

So, instead of this:

def my_method(self):
    # some statement(s) here (implies passing in some instance attributes)
    # those beginning with the self. prefix

You can do this:

@staticmethod
def my_method():
    # some statement(s) here

Here is a tutorial that may aid in understanding this subject:

Paul, I did like you said, but now it isn’t changing scenes like it was before

Can you please post the latest version to review.

Yes. I did change back to the returns where it was working before. Here you go:

rom sys import exit
from random import randint
from textwrap import dedent

class Scene(object):
    
    def enter(self):
        print("This scene is not yet configured.")
        print("Subclass it and implement enter().")
        exit(1)

class Engine(object):

    def __init__(self, scene_map):
        self.scene_map = scene_map
    
    def play(self):
        current_scene = self.scene_map.opening_scene()
        last_scene = self.scene_map.next_scene('finished')

        while current_scene != last_scene:
            next_scene_name = current_scene.enter()
            current_scene = self.scene_map.next_scene(next_scene_name)

        current_scene.enter()

class Riddle:

    riddle = ' '

class FirstRiddle(Riddle):

    def first_riddle():
        Riddle.riddle = "What is always on its way, but never arrives?"

class SecondRiddle(Riddle):

    def second_riddle():
        Riddle.riddle = "What thrives when you feed it, but dies when you water it?"

class ThirdRiddle(Riddle):

    def third_riddle():
        Riddle.riddle = "What do you hold but never keep?  If you take your last, make it deep."

class FourthRiddle(Riddle):

    def fourth_riddle():
        Riddle.riddle = "I don't breathe flames, but I light the night, guiding sailors with my steady sight.  I stand tall on cliffs, where dragons might dwell, but I save lives with every bell.  What am I?"

class FifthRiddle(Riddle):

    def fifth_riddle():
        Riddle.riddle = "They come out at night without being asked yet lost in the day without being stolen.  What are they?"

class Location:

    location = ' '

class Death(Location):
    
    def enter(self):
        
        if  Location.location in ('start', 'dark_woods', 'outside_house_without_bone', 'outside_house_with_bone'):
            print("Day becomes night and you're devoured by wolves.")
            
        elif Location.location in ('foyer', 'living_room'):
            print("The dog chews your leg off and you bleed to death.")
            
        elif Location.location == 'cellar':
            print("The dragon burns you to a crisp.")
            
        else:
            print("You are turned into a rodent and eaten by an owl.")
            
        print("You're dead!  Better luck next time!") 
        exit(1)        

class Start(Location):
      
    def enter(self):
        Location.location ='start'
        print(dedent("""
                    Welcome to Arcamadius, where magic and creatures exist.
                    You come to a house in the dark woods.
                    There is a window on the east wall and a door on the
                    South wall.  The house is surrounded by woods. What
                    would you like to do?
                     """))
        action = input("> ")

        if action == 'open window':
            print(dedent("""
                        You open the window.  It makes a squeaking noise.
                        What do you want to do now?
                        """ ))
            action = input("> ")

            if action == 'climb into window':
                print("You enter the window into the kitchen.")
                return 'kitchen'
            else:
                print("You just stand there!")
                return 'death'
            
        elif action == 'open door':
            print("You enter the door into the Foyer")
        else:
            return 'death'

class OutsideHouseWithoutBone(Location):

    def enter(self):
        Location.location = 'outside_house_without_bone'
        have_bone = False
        print(dedent("""
                    You are at a house in the dark woods.
                    There is a window on the east wall and a door on the
                    South wall.  The house is surrounded by woods. What
                    would you like to do?
                     """)) 
        action = input("> ")

        if action == 'open window':
            print(dedent("""
                        You open the window.  It makes a squeaking noise.
                        What do you wnat to do now?
                        """ ))
            action = input("> ")

            if action == 'climb into window':
                print("You enter the window into the kitchen.")
                return 'kitchen'
            else:
                print("You just stand there!")
                return 'death'
        elif action == 'open door':
            print("You enter the door into the Foyer")
            return 'foyer'
        else:
            return 'death'
        
class OutsideHouseWithBone(Location):
    
    def enter(self):
        Location.location = 'outside_house_with_bone'
        have_bone = True
        print(dedent("""
                    You are at a house in the dark woods.
                    There is an open window on the east wall and a door on the
                    South wall.  The house is surrounded by woods. You are 
                    carrying a bone.  What would you like to do?
                    """)) 
        action = input("> ")

        if action == 'climb into window':
                print("You enter the window into the kitchen.")
                return 'kitchen_with_bone'
        elif action == 'open door':
            print("You enter the door into the Foyer")
            return 'foyer_with_bone'
        else:
            return 'death'

        
class Kitchen (Location):

    def enter(self):
        Location.location = 'kitchen'
        have_bone = False
        print(dedent("""
                     There is a doorway ahead.  There is also a table
                     with a bone on it.  What do you wnat to do?
                     """))
        action = input("> ")

        if action == "go through doorway" and have_bone == True:
            return 'living_room'
        elif action == "grab bone" and have_bone == False:
            print("You grab the bone")
            return 'kitchen_with_bone'
        elif action == "climb out window":
            return 'outside_house_without_bone'
        else:
            print("I'm not sure what you are saying.")
            self.enter(self) 
            
class KitchenWithBone(Location):

    def enter(self):
        Location.location = 'kitchen_with_bone'
        have_bone = True
        print(dedent("""
                     There is a doorway ahead.  There is also an empty
                     table.  What do you wnat to do?
                     """))
        action = input("> ")

        if action == "go through doorway" and have_bone == True:
            return 'living_room'
        elif action == "climb out window":
            return 'outside_house_with_bone'
        else:
            print("I'm not sure what you are saying.")
            self.enter(self)    

class Foyer(Location):
    
    def enter(self):
        Location.location = 'foyer'
        have_bone = False
        print(dedent("""
                     A huge dog is staring and growling at you
                     What do you do?
                     """))
        action = input("> ")

        if action == "flee":
            print(dedent("""
                         You managed to get away from the dog chasing you and the
                         dog goes back into the house.
                         """))
            return 'outside_house_without_bone'
        elif action == "give dog the bone" and have_bone == False:
            print("you have no bone.")
            return 'death'
        else:
            print("I have no idea what that means.")
            return 'foyer'

class FoyerWithBone(Location):

    def enter(self):
        Location.location = 'foyer_with_bone'
        have_bone = True
        print(dedent("""
                     A huge dog is staring and growling at you and you are
                     carrying a bone.  What do you do?
                     """))
        action = input("> ")

        if action == "flee":
            print(dedent("""
                         You managed to get away from the dog chasing you and the
                         dog goes back into the house.
                         """))
            return 'outside_house_with_bone'
        elif action == "give dog the bone" and have_bone == True:
            print(dedent("""
                        You give the dog the bone.
                        The dog wants to play.  You play with the dog for awhile.
                        Now back to business. The entrance to the living room
                        is ahead.
                        """))
            return 'living_room'
        else:
            print("I have no idea what that means.")
            return 'foyer_with_bone'

class LivingRoom(Location):

    def enter(self):
        Location.location = 'living_room'
        have_bone = True
        print(dedent("""
                     You are in the living room.  There is a trap door in the floor.
                     There is a mantle with an electric lantern on it.  A huge dog
                     is staring and growling at you.  You are carrying a bone.  What
                     would you like to do?
                     """))
        action = input("> ")

        if action == "give dog the bone" and have_bone == True:
            print(dedent("""
                        You give the dog the bone.
                        The dog wants to play.  You play with the dog for awhile.
                        The dog goes asleep. You are in the living room.  There is
                        a trap door in the floor.  There is a mantle with an electric
                        lantern on it.  What would you like to do?
                        """))
            action = input("> ")

            if  action == "grab lantern":
                print(dedent("""
                             You grab the lantern and turn it on. You are in the
                             living room.  There is a trap door in the floor.
                             There is an empty mantle.  You open the trap door.
                             """))
                return 'cellar'
            else:
                print(dedent("""
                             The dog wakes up from its slumber and is hungry.  It 
                             growls and snarls at you.
                             """))
                return 'death'
        else:
            return 'death'

class DarkWoods(Location):
    
    def enter(self):
        pass

class Cellar(Location):

    def enter(self):
        Location.location = 'cellar'
        print(dedent("""
                     You open the open the door to the cellar and a foul
                     stench is coming from the darkness.  You head into 
                     the cellar.  In the corner, you see a dragon laying
                     on a bed of gold.  On top of the gold is a nest and
                     in the nest is five dragon eggs What would you like
                     to do?
                     """))
        action = input("> ")

        if action == "grab some gold":
            print(dedent("""
                         The dragon awakens in a fury and says, 'How dare 
                         thee take my gold!  For that you will perish!'
                         """))
            return 'death'
        elif action == "grab an egg":
            print(dedent("""
                         The dragon awakens in a fury and says, 'How dare 
                         thee take one of my eggs!  For that you will perish!'
                         """))
            return 'death'
        elif action == "approach dragon":
            print(dedent("""
                         You approach the dragon and ask the dragon, 'How may I
                         obtain an egg from you?'  The dragon says, '
                         You must first answer a riddle.  Then you will get an egg'
                         """))
        else:
            print("I'm not sure what you mean.")
            return 'cellar'
        
            riddle_number = f"{randint(1,5)}"
            guesses = 1

            if riddle_number == 1:
                print(FirstRiddle.first_riddle())
                guess = input("[your answer]> ")
                answer = "Tomorrow"
            elif riddle_number == 2:
                print(SecondRiddle.second_riddle())
                guess = input("[your answer]> ")
                answer = "Fire"
            elif riddle_number == 3:
                print(ThirdRiddle.third_riddle())
                guess = input("[your answer]> ")
                answer = "A breath of air"
            elif riddle_number == 4:
                print(FourthRiddle.fourth_riddle())
                guess = input("[your answer]> ")
                answer = "A lighthouse"
            else:
                print(FifthRiddle.fifth_riddle())
                guess = input("[your answer]> ")
                answer = "Stars"

            while guess != answer and guesses < 3:
                print("Try again!")
                guesses += 1
                guess = input("[your answer]> ")

            if guess == answer:
                print(dedent("""
                             You have answered correctly.  You carefully chooose
                             an egg.  The dragon speaks some magic words and you 
                             are teleported to the Dark Woods.
                             """))
                return 'dark_woods'

class WitchHouse(Location):

    def enter(self):
        pass

class Finished(Location):

    def enter(self):
        pass

class Map(object):
    scenes = {
        'start': Start(),
        'outside_house_without_bone': OutsideHouseWithoutBone(),
        'outside_house_with_bone': OutsideHouseWithBone(),
        'kitchen': Kitchen(),
        'kitchen_with_bone': KitchenWithBone(),
        'foyer': Foyer(),
        "foyer_with_bone": FoyerWithBone(),
        'living_room': LivingRoom(),
        'dark_woods': DarkWoods(),
        'cellar': Cellar(),
        'witch_house': WitchHouse(),
        'death': Death(),
        'finished': Finished(),
    }

    def __init__(self, start_scene):
        self.start_scene = start_scene

    def next_scene(self, scene_name):
        val = Map.scenes.get(scene_name)
        return val
    
    def opening_scene(self):
        have_bone = False
        return self.next_scene(self.start_scene)

a_map = Map('start')
a_game = Engine (a_map)
a_game.play()```

Paul, here’s the error when I try to bring up a riddle at random. Again this is while in the Cellar class.
You approach the dragon and ask the dragon, ‘How may I
obtain an egg from you?’ The dragon says, ’
You must first answer a riddle. Then you will get an egg’

Traceback (most recent call last):
File “/home/roberto-padilla/mystuff/ella_game.py”, line 409, in
a_game.play()
File “/home/roberto-padilla/mystuff/ella_game.py”, line 22, in play
next_scene_name = current_scene.enter()
^^^^^^^^^^^^^^^^^^^
AttributeError: ‘NoneType’ object has no attribute ‘enter’
Here’s a copy of the code.

from sys import exit
from random import randint
from textwrap import dedent

class Scene(object):
    
    def enter(self):
        print("This scene is not yet configured.")
        print("Subclass it and implement enter().")
        exit(1)

class Engine(object):

    def __init__(self, scene_map):
        self.scene_map = scene_map
    
    def play(self):
        current_scene = self.scene_map.opening_scene()
        last_scene = self.scene_map.next_scene('finished')

        while current_scene != last_scene:
            next_scene_name = current_scene.enter()
            current_scene = self.scene_map.next_scene(next_scene_name)

        current_scene.enter()

class Riddle:

    riddle = ' '

class Riddles(Riddle):

    def first_riddle():
        Riddle.riddle = "What is always on its way, but never arrives?"

    def second_riddle():
        Riddle.riddle = "What thrives when you feed it, but dies when you water it?"

    def third_riddle():
        Riddle.riddle = "What do you hold but never keep?  If you take your last, make it deep."

    def fourth_riddle():
        Riddle.riddle = "I don't breathe flames, but I light the night, guiding sailors with my steady sight.  I stand tall on cliffs, where dragons might dwell, but I save lives with every bell.  What am I?"

    def fifth_riddle():
        Riddle.riddle = "They come out at night without being asked yet lost in the day without being stolen.  What are they?"

class Location:

    location = ' '

class Death(Location):
    
    def enter(self):
        
        if  Location.location in ('start', 'dark_woods', 'outside_house_without_bone', 'outside_house_with_bone'):
            print("Day becomes night and you're devoured by wolves.")
            
        elif Location.location in ('foyer', 'living_room'):
            print("The dog chews your leg off and you bleed to death.")
            
        elif Location.location == 'cellar':
            print("The dragon burns you to a crisp.")
            
        else:
            print("You are turned into a rodent and eaten by an owl.")
            
        print("You're dead!  Better luck next time!") 
        exit(1)        

class Start(Location):
      
    def enter(self):
        Location.location ='start'
        print(dedent("""
                    Welcome to Arcamadius, where magic and creatures exist.
                    You come to a house in the dark woods.
                    There is a window on the east wall and a door on the
                    South wall.  The house is surrounded by woods. What
                    would you like to do?
                     """))
        action = input("> ")

        if action == 'open window':
            print(dedent("""
                        You open the window.  It makes a squeaking noise.
                        What do you want to do now?
                        """ ))
            action = input("> ")

            if action == 'climb into window':
                print("You enter the window into the kitchen.")
                return 'kitchen'
            else:
                print("You just stand there!")
                return 'death'
            
        elif action == 'open door':
            print("You enter the door into the Foyer")
        else:
            return 'death'

class OutsideHouseWithoutBone(Location):

    def enter(self):
        Location.location = 'outside_house_without_bone'
        have_bone = False
        print(dedent("""
                    You are at a house in the dark woods.
                    There is a window on the east wall and a door on the
                    South wall.  The house is surrounded by woods. What
                    would you like to do?
                     """)) 
        action = input("> ")

        if action == 'open window':
            print(dedent("""
                        You open the window.  It makes a squeaking noise.
                        What do you wnat to do now?
                        """ ))
            action = input("> ")

            if action == 'climb into window':
                print("You enter the window into the kitchen.")
                return 'kitchen'
            else:
                print("You just stand there!")
                return 'death'
        elif action == 'open door':
            print("You enter the door into the Foyer")
            return 'foyer'
        else:
            return 'death'
        
class OutsideHouseWithBone(Location):
    
    def enter(self):
        Location.location = 'outside_house_with_bone'
        have_bone = True
        print(dedent("""
                    You are at a house in the dark woods.
                    There is an open window on the east wall and a door on the
                    South wall.  The house is surrounded by woods. You are 
                    carrying a bone.  What would you like to do?
                    """)) 
        action = input("> ")

        if action == 'climb into window':
                print("You enter the window into the kitchen.")
                return 'kitchen_with_bone'
        elif action == 'open door':
            print("You enter the door into the Foyer")
            return 'foyer_with_bone'
        else:
            return 'death'

        
class Kitchen (Location):

    def enter(self):
        Location.location = 'kitchen'
        have_bone = False
        print(dedent("""
                     There is a doorway ahead.  There is also a table
                     with a bone on it.  What do you wnat to do?
                     """))
        action = input("> ")

        if action == "go through doorway" and have_bone == True:
            return 'living_room'
        elif action == "grab bone" and have_bone == False:
            print("You grab the bone")
            return 'kitchen_with_bone'
        elif action == "climb out window":
            return 'outside_house_without_bone'
        else:
            print("I'm not sure what you are saying.")
            self.enter(self) 
            
class KitchenWithBone(Location):

    def enter(self):
        Location.location = 'kitchen_with_bone'
        have_bone = True
        print(dedent("""
                     There is a doorway ahead.  There is also an empty
                     table.  What do you wnat to do?
                     """))
        action = input("> ")

        if action == "go through doorway" and have_bone == True:
            return 'living_room'
        elif action == "climb out window":
            return 'outside_house_with_bone'
        else:
            print("I'm not sure what you are saying.")
            self.enter(self)    

class Foyer(Location):
    
    def enter(self):
        Location.location = 'foyer'
        have_bone = False
        print(dedent("""
                     A huge dog is staring and growling at you
                     What do you do?
                     """))
        action = input("> ")

        if action == "flee":
            print(dedent("""
                         You managed to get away from the dog chasing you and the
                         dog goes back into the house.
                         """))
            return 'outside_house_without_bone'
        elif action == "give dog the bone" and have_bone == False:
            print("you have no bone.")
            return 'death'
        else:
            print("I have no idea what that means.")
            return 'foyer'

class FoyerWithBone(Location):

    def enter(self):
        Location.location = 'foyer_with_bone'
        have_bone = True
        print(dedent("""
                     A huge dog is staring and growling at you and you are
                     carrying a bone.  What do you do?
                     """))
        action = input("> ")

        if action == "flee":
            print(dedent("""
                         You managed to get away from the dog chasing you and the
                         dog goes back into the house.
                         """))
            return 'outside_house_with_bone'
        elif action == "give dog the bone" and have_bone == True:
            print(dedent("""
                        You give the dog the bone.
                        The dog wants to play.  You play with the dog for awhile.
                        Now back to business. The entrance to the living room
                        is ahead.
                        """))
            return 'living_room'
        else:
            print("I have no idea what that means.")
            return 'foyer_with_bone'

class LivingRoom(Location):

    def enter(self):
        Location.location = 'living_room'
        have_bone = True
        print(dedent("""
                     You are in the living room.  There is a trap door in the floor.
                     There is a mantle with an electric lantern on it.  A huge dog
                     is staring and growling at you.  You are carrying a bone.  What
                     would you like to do?
                     """))
        action = input("> ")

        if action == "give dog the bone" and have_bone == True:
            print(dedent("""
                        You give the dog the bone.
                        The dog wants to play.  You play with the dog for awhile.
                        The dog goes asleep. You are in the living room.  There is
                        a trap door in the floor.  There is a mantle with an electric
                        lantern on it.  What would you like to do?
                        """))
            action = input("> ")

            if  action == "grab lantern":
                print(dedent("""
                             You grab the lantern and turn it on. You are in the
                             living room.  There is a trap door in the floor.
                             There is an empty mantle.  You open the trap door.
                             """))
                return 'cellar'
            else:
                print(dedent("""
                             The dog wakes up from its slumber and is hungry.  It 
                             growls and snarls at you.
                             """))
                return 'death'
        else:
            return 'death'

class DarkWoods(Location):
    
    def enter(self):
        pass

class Cellar(Location):

    def enter(self):
        Location.location = 'cellar'
        print(dedent("""
                     You open the open the door to the cellar and a foul
                     stench is coming from the darkness.  You head into 
                     the cellar.  In the corner, you see a dragon laying
                     on a bed of gold.  On top of the gold is a nest and
                     in the nest is five dragon eggs What would you like
                     to do?
                     """))
        action = input("> ")

        if action == "grab some gold":
            print(dedent("""
                         The dragon awakens in a fury and says, 'How dare 
                         thee take my gold!  For that you will perish!'
                         """))
            return 'death'
        elif action == "grab an egg":
            print(dedent("""
                         The dragon awakens in a fury and says, 'How dare 
                         thee take one of my eggs!  For that you will perish!'
                         """))
            return 'death'
        elif action == "approach dragon":
            print(dedent("""
                         You approach the dragon and ask the dragon, 'How may I
                         obtain an egg from you?'  The dragon says, '
                         You must first answer a riddle.  Then you will get an egg'
                         """))
        else:
            print("I'm not sure what you mean.")
            return 'cellar'
        
            riddle_number = f"{randint(1,5)}"
            guesses = 1

            if riddle_number == 1:
                print(Riddles.first_riddle())
                guess = input("[your answer]> ")
                answer = "Tomorrow"
            elif riddle_number == 2:
                print(Riddles.second_riddle())
                guess = input("[your answer]> ")
                answer = "Fire"
            elif riddle_number == 3:
                print(Riddles.third_riddle())
                guess = input("[your answer]> ")
                answer = "A breath of air"
            elif riddle_number == 4:
                print(Riddles.fourth_riddle())
                guess = input("[your answer]> ")
                answer = "A lighthouse"
            else:
                print(Riddles.fifth_riddle())
                guess = input("[your answer]> ")
                answer = "Stars"

            while guess != answer and guesses < 3:
                print("Try again!")
                guesses += 1
                guess = input("[your answer]> ")

            if guess == answer:
                print(dedent("""
                             You have answered correctly.  You carefully chooose
                             an egg.  The dragon speaks some magic words and you 
                             are teleported to the Dark Woods.
                             """))
                return 'dark_woods'

class WitchHouse(Location):

    def enter(self):
        pass

class Finished(Location):

    def enter(self):
        pass

class Map(object):
    scenes = {
        'start': Start(),
        'outside_house_without_bone': OutsideHouseWithoutBone(),
        'outside_house_with_bone': OutsideHouseWithBone(),
        'kitchen': Kitchen(),
        'kitchen_with_bone': KitchenWithBone(),
        'foyer': Foyer(),
        "foyer_with_bone": FoyerWithBone(),
        'living_room': LivingRoom(),
        'dark_woods': DarkWoods(),
        'cellar': Cellar(),
        'witch_house': WitchHouse(),
        'death': Death(),
        'finished': Finished(),
    }

    def __init__(self, start_scene):
        self.start_scene = start_scene

    def next_scene(self, scene_name):
        val = Map.scenes.get(scene_name)
        return val
    
    def opening_scene(self):
        have_bone = False
        return self.next_scene(self.start_scene)

a_map = Map('start')
a_game = Engine (a_map)
a_game.play()```

When I run the script, I don’t get an error. This shows up:

Welcome to Arcamadius, where magic and creatures exist.
You come to a house in the dark woods.
There is a window on the east wall and a door on the
South wall.  The house is surrounded by woods. What
would you like to do?

Here, you should actually give the user options as to what is an expected response. For example, you can create a menu of options and have the user select A, B, or C, etc. Otherwise, the responses are open-ended. How then will your script handle open-ended responses. (responses should be deterministic)

At the bottom, where you instantiate the classes and start the script, rewrite like this so that when you manually stop the script, you don’t get the KeyboardInterrupt error:

a_map = Map('start')
a_game = Engine(a_map)

try:
    a_game.play()
except KeyboardInterrupt:
    pass

If you run the script, yes that comes up until you get to the cellar and approach the dragon. You’re right as far as having a menu. Thanks. Here were my responses in order if you want to see what I’m talking about: open window, climb into wiindow, grab bone, go through doorway, give dog the bone, grab lantern, and approach dragon. If you enter these responses in this order, you shall see what error I"m referring to. Thanks.

Per my previous response, you should update your script so that you don’t need to use the return statement. Just use the Location.location variable as shown here for a few samples.

For example:

Location.location = 'cellar'
# return 'cellar'

Location.location = 'death'
# return 'death'

Location.location = 'dark_woods'
# return 'dark_woods'

I tried doing that and the first scene I come to I obtain an error.

That is because the way that your code is currently set up using the return statement, you’re returning a value to the caller. With the Location.location global variable, a value does not need to be returned because it is visible everywhere because it is global.

Thus, you need to modify the code such that the caller does not expect a value to be returned.

Apparently, it is missing a return statement. I have added it here:

        elif action == "approach dragon":
            print(dedent("""
                         You approach the dragon and ask the dragon, 'How may I
                         obtain an egg from you?'  The dragon says, '
                         You must first answer a riddle.  Then you will get an egg'
                         """))
            return 'death'  # added this *******************

Note that once a script comes upon a return statement in a function (method), it immediately exits that function. So, just below the subscript that I just pointed out, you have this:

        else:
            print("I'm not sure what you mean.")
            return 'cellar'  # ***** Once it gets here, it exits the function

            # Everything starting from here is ignored            
            riddle_number = f"{randint(1, 5)}"
            guesses = 1

            if riddle_number == 1:
                print(Riddles.first_riddle())
                guess = input("[your answer]> ")
                answer = "Tomorrow"
            elif riddle_number == 2:
                print(Riddles.second_riddle())
                guess = input("[your answer]> ")
.
.
.

Everything below the return statement, is ignored, ALWAYS.

Clean up your script such that you don’t have this bug.

Does this mean to get rid of the Engine and Map clases? Also will the script go to the appropriate scene if I add: Location.location = ‘cellar’ .

Here’s what I have so far revised:

from sys import exit
from random import randint
from textwrap import dedent

class Scene(object):
    
    def enter(self):
        print("This scene is not yet configured.")
        print("Subclass it and implement enter().")
        exit(1)

class Engine(object):

    def __init__(self, scene_map):
        self.scene_map = scene_map
    
    def play(self):
        current_scene = self.scene_map.opening_scene()
        last_scene = self.scene_map.next_scene('finished')

        while current_scene != last_scene:
            next_scene_name = current_scene.enter()
            current_scene = self.scene_map.next_scene(next_scene_name)

        current_scene.enter()

class Riddle:

    riddle = ' '

class Riddles(Riddle):

    def first_riddle():
        Riddle.riddle = "What is always on its way, but never arrives?"

    def second_riddle():
        Riddle.riddle = "What thrives when you feed it, but dies when you water it?"

    def third_riddle():
        Riddle.riddle = "What do you hold but never keep?  If you take your last, make it deep."

    def fourth_riddle():
        Riddle.riddle = "I don't breathe flames, but I light the night, guiding sailors with my steady sight.  I stand tall on cliffs, where dragons might dwell, but I save lives with every bell.  What am I?"

    def fifth_riddle():
        Riddle.riddle = "They come out at night without being asked yet lost in the day without being stolen.  What are they?"

class Location:

    location = ' '

class Death(Location):
    
    def enter(self):
        
        if  Location.location in ('start', 'dark_woods', 'outside_house_without_bone', 'outside_house_with_bone'):
            print("Day becomes night and you're devoured by wolves.")
            
        elif Location.location in ('foyer', 'living_room'):
            print("The dog chews your leg off and you bleed to death.")
            
        elif Location.location == 'cellar':
            print("The dragon burns you to a crisp.")
            
        else:
            print("You are turned into a rodent and eaten by an owl.")
            
        print("You're dead!  Better luck next time!") 
        exit(1)        

class Start(Location):
      
    def enter(self):
        Location.location ='start'
        print(dedent("""
                    Welcome to Arcamadius, where magic and creatures exist.
                    You come to a house in the dark woods.
                    There is a window on the east wall and a door on the
                    South wall.  The house is surrounded by woods. What
                    would you like to do?
                     """))
        action = input("> (open window, open door) ")

        if action == 'open window':
            print(dedent("""
                        You open the window.  It makes a squeaking noise.
                        What do you want to do now?
                        """ ))
            action = input("> (climb into window) ")

            if action == 'climb into window':
                print("You enter the window into the kitchen.")
                Location.location = 'kitchen'
            else:
                print("You just stand there!")
                Location.location = 'death'
            
        elif action == 'open door':
            print("You enter the door into the Foyer")
        else:
            Location.location = 'death'

class OutsideHouseWithoutBone(Location):

    def enter(self):
        Location.location = 'outside_house_without_bone'
        have_bone = False
        print(dedent("""
                    You are at a house in the dark woods.
                    There is a window on the east wall and a door on the
                    South wall.  The house is surrounded by woods. What
                    would you like to do?
                     """)) 
        action = input("> (open window, open door) ")

        if action == 'open window':
            print(dedent("""
                        You open the window.  It makes a squeaking noise.
                        What do you wnat to do now?
                        """ ))
            action = input("> (climb into window) ")

            if action == 'climb into window':
                print("You enter the window into the kitchen.")
                Location.location = 'kitchen'
            else:
                print("You just stand there!")
                Location.location = 'death'
        elif action == 'open door':
            print("You enter the door into the Foyer")
            Location.location = 'foyer'
        else:
            Location.location = 'death'
        
class OutsideHouseWithBone(Location):
    
    def enter(self):
        Location.location = 'outside_house_with_bone'
        have_bone = True
        print(dedent("""
                    You are at a house in the dark woods.
                    There is an open window on the east wall and a door on the
                    South wall.  The house is surrounded by woods. You are 
                    carrying a bone.  What would you like to do?
                    """)) 
        action = input("> (climb into window, open door) ")

        if action == 'climb into window':
                print("You enter the window into the kitchen.")
                Location.location = 'kitchen_with_bone'
        elif action == 'open door':
            print("You enter the door into the Foyer")
            Location.location = 'foyer_with_bone'
        else:
            Location.location = 'death'

        
class Kitchen (Location):

    def enter(self):
        Location.location = 'kitchen'
        have_bone = False
        print(dedent("""
                     There is a doorway ahead.  There is also a table
                     with a bone on it.  What do you wnat to do?
                     """))
        action = input("> (go through doorway, grab bone, climb out window) ")

        if action == "go through doorway" and have_bone == True:
            Location.location = 'living_room'
        elif action == "grab bone" and have_bone == False:
            print("You grab the bone")
            Location.location = 'kitchen_with_bone'
        elif action == "climb out window":
            Location.location = 'outside_house_without_bone'
        else:
            print("I'm not sure what you are saying.")
            self.enter(self) 
            
class KitchenWithBone(Location):

    def enter(self):
        Location.location = 'kitchen_with_bone'
        have_bone = True
        print(dedent("""
                     There is a doorway ahead.  There is also an empty
                     table.  What do you wnat to do?
                     """))
        action = input("> (go through doorway, climb out window)")

        if action == "go through doorway" and have_bone == True:
            Location.location = 'living_room'
        elif action == "climb out window":
            Location.location = 'outside_house_with_bone'
        else:
            print("I'm not sure what you are saying.")
            self.enter(self)    

class Foyer(Location):
    
    def enter(self):
        Location.location = 'foyer'
        have_bone = False
        print(dedent("""
                     A huge dog is staring and growling at you
                     What do you do?
                     """))
        action = input("> (flee, give dog the bone) ")

        if action == "flee":
            print(dedent("""
                         You managed to get away from the dog chasing you and the
                         dog goes back into the house.
                         """))
            Location.location = 'outside_house_without_bone'
        elif action == "give dog the bone" and have_bone == False:
            print("you have no bone.")
            Location.location = 'death'
        else:
            print("I have no idea what that means.")
            Location.location = 'foyer'

class FoyerWithBone(Location):

    def enter(self):
        Location.location = 'foyer_with_bone'
        have_bone = True
        print(dedent("""
                     A huge dog is staring and growling at you and you are
                     carrying a bone.  What do you do?
                     """))
        action = input("> (flee, give dog the bone) ")

        if action == "flee":
            print(dedent("""
                         You managed to get away from the dog chasing you and the
                         dog goes back into the house.
                         """))
            Location.location = 'outside_house_with_bone'
        elif action == "give dog the bone" and have_bone == True:
            print(dedent("""
                        You give the dog the bone.
                        The dog wants to play.  You play with the dog for awhile.
                        Now back to business. The entrance to the living room
                        is ahead.
                        """))
            Location.location = 'living_room'
        else:
            print("I have no idea what that means.")
            Location.location = 'foyer_with_bone'

class LivingRoom(Location):

    def enter(self):
        Location.location = 'living_room'
        have_bone = True
        print(dedent("""
                     You are in the living room.  There is a trap door in the floor.
                     There is a mantle with an electric lantern on it.  A huge dog
                     is staring and growling at you.  You are carrying a bone.  What
                     would you like to do?
                     """))
        action = input("> (give dog the bone) ")

        if action == "give dog the bone" and have_bone == True:
            print(dedent("""
                        You give the dog the bone.
                        The dog wants to play.  You play with the dog for awhile.
                        The dog goes asleep. You are in the living room.  There is
                        a trap door in the floor.  There is a mantle with an electric
                        lantern on it.  What would you like to do?
                        """))
            action = input("> ( grab lantern)")

            if  action == "grab lantern":
                print(dedent("""
                             You grab the lantern and turn it on. You are in the
                             living room.  There is a trap door in the floor.
                             There is an empty mantle.  You open the trap door.
                             """))
                Location.location = 'cellar'
            else:
                print(dedent("""
                             The dog wakes up from its slumber and is hungry.  It 
                             growls and snarls at you.
                             """))
                Location.location = 'death'
        else:
            Location.location = 'death'

class DarkWoods(Location):
    
    def enter(self):
        pass

class Cellar(Location):

    def enter(self):
        Location.location = 'cellar'
        print(dedent("""
                     You open the open the door to the cellar and a foul
                     stench is coming from the darkness.  You head into 
                     the cellar.  In the corner, you see a dragon laying
                     on a bed of gold.  On top of the gold is a nest and
                     in the nest is five dragon eggs What would you like
                     to do?
                     """))
        action = input("> (grab some gold, grab an egg, approach dragon) ")

        if action == "grab some gold":
            print(dedent("""
                         The dragon awakens in a fury and says, 'How dare 
                         thee take my gold!  For that you will perish!'
                         """))
            Location.location = 'death'
        elif action == "grab an egg":
            print(dedent("""
                         The dragon awakens in a fury and says, 'How dare 
                         thee take one of my eggs!  For that you will perish!'
                         """))
            Location.location = 'death'
        elif action == "approach dragon":
            print(dedent("""
                         You approach the dragon and ask the dragon, 'How may I
                         obtain an egg from you?'  The dragon says, '
                         You must first answer a riddle.  Then you will get an egg'
                         """))
            Location.location = 'cellar'
        else:
            print("I'm not sure what you mean.")
            Location.location = 'cellar'
        
            riddle_number = f"{randint(1,5)}"
            guesses = 1

            if riddle_number == 1:
                print(Riddles.first_riddle())
                guess = input("[your answer]> ")
                answer = "Tomorrow"
            elif riddle_number == 2:
                print(Riddles.second_riddle())
                guess = input("[your answer]> ")
                answer = "Fire"
            elif riddle_number == 3:
                print(Riddles.third_riddle())
                guess = input("[your answer]> ")
                answer = "A breath of air"
            elif riddle_number == 4:
                print(Riddles.fourth_riddle())
                guess = input("[your answer]> ")
                answer = "A lighthouse"
            else:
                print(Riddles.fifth_riddle())
                guess = input("[your answer]> ")
                answer = "Stars"

            while guess != answer and guesses < 3:
                print("Try again!")
                guesses += 1
                guess = input("[your answer]> ")

            if guess == answer:
                print(dedent("""
                             You have answered correctly.  You carefully chooose
                             an egg.  The dragon speaks some magic words and you 
                             are teleported to the Dark Woods.
                             """))
                Location.location = 'dark_woods'

class WitchHouse(Location):

    def enter(self):
        pass

class Finished(Location):

    def enter(self):
        pass

class Map(object):
    scenes = {
        'start': Start(),
        'outside_house_without_bone': OutsideHouseWithoutBone(),
        'outside_house_with_bone': OutsideHouseWithBone(),
        'kitchen': Kitchen(),
        'kitchen_with_bone': KitchenWithBone(),
        'foyer': Foyer(),
        "foyer_with_bone": FoyerWithBone(),
        'living_room': LivingRoom(),
        'dark_woods': DarkWoods(),
        'cellar': Cellar(),
        'witch_house': WitchHouse(),
        'death': Death(),
        'finished': Finished(),
    }

    def __init__(self, start_scene):
       self.start_scene = start_scene

    def next_scene(self, scene_name):
       val = Map.scenes.get(scene_name)
       return val
    
    def opening_scene(self):
       have_bone = False
       return self.next_scene(self.start_scene)

a_map = Map('start')
a_game = Engine (a_map)
try:
    a_game.play()
except KeyboardInterrupt:
    pass

The Location.location global variable is to let the program know where the death occured for the Death method enter conditional statement. Just a small suggestion, try naming this method with a name that has more meaning as to what it is actually doing (i.e., death_reason, for example) since it prints out how the user died.

You should actually have two global variables.

  1. Reason for death (Location.death_location) # previously Location.location
  2. Next location to go to (Location.next_location)

The first variable, as mentioned before, keeps track of where the death occured.

The second variable would tell the script where to go to next as the user is playing the game depending on the responses.

By the way, on some of your classes I noticed that you used object as an inherited class. This is related to v2.x Python related scripts. You no longer have to do that for v3.x. You can delete them along with the parantheses.

Nope. Notice that you’re instantiating the classes by passing in an argument. This initializes your script.

This is the output when I run the script:
Welcome to Arcamadius, where magic and creatures exist.
You come to a house in the dark woods.
There is a window on the east wall and a door on the
South wall. The house is surrounded by woods. What
would you like to do?

(open window, open door) open window

You open the window. It makes a squeaking noise.
What do you want to do now?

(climb into window) climb into window
You enter the window into the kitchen.
Traceback (most recent call last):
File “/home/roberto-padilla/mystuff/ella_game.py”, line 412, in
a_game.play()
File “/home/roberto-padilla/mystuff/ella_game.py”, line 22, in play
next_scene_name = current_scene.enter()
^^^^^^^^^^^^^^^^^^^
AttributeError: ‘NoneType’ object has no attribute ‘enter’

My question is How do I update the script so that when I call Location.next_location it goes to the appropriate class?

Like I stated previously, the caller expects a returned value. If you do not provide it, then an exception will be raised. For this particular error, notice how the first if statement shown has no return value. This is the problem. If you enter the first if statement, it implies that action is equal to open window. But if you go through the rest of the script in this function, you will see that it never "return"s a value back to the caller, which is expecting a returned value, hence the error…

Here is the script that I am referring to (it is in the Start class):

        if action == 'open window':
            print(dedent("""
                        You open the window.  It makes a squeaking noise.
                        What do you want to do now?
                        """))
            action = input("> ")

            if action == 'climb into window':
                print("You enter the window into the kitchen.")
                return 'kitchen'

If you add a line to return a value right after the action = input(">") line, then that error should go away.

Also note that as written, none of the code meant to process the riddle chosen will ever get executed because of the return 'caller' at the beginning of the else conditional statement - it exits the function immediately - kind of like an interception in football.

Update:
I made a mistake. I was looking at the wrong conditional.

It is this one:

        elif action == 'open door':
            print("You enter the door into the Foyer")

Notice how it is missing a return statement. Add a return statement right after the print statement to return back to the caller.

Here is a thread that explains potential reasons for generating the AttributeError: NoneType exeption: