Ex43 been stuck for hours

so my problem is a little strange…
when i run the code it works … for thr corridor room but when it moves to the armory i get the error of:

Traceback (most recent call last):
  File "/Users/EddieHome/Desktop/Game/Game.py", line 210, in <module>
    a_game.play()
  File "/Users/EddieHome/Desktop/Game/Game.py", line 27, in play
    next_scene_name = current_scene.enter()
AttributeError: 'NoneType' object has no attribute 'enter'

so i have changed the starting room to armory and it works and will progress to the escape pod room and will work.

ive googled and read throught the responces on the forum but i still cannot for the life of me figure out why it wont move from the corridor to the armory but it will move from the armory to the escape pod …

i started off by making the corridor class work with the engine but then i got the error… so i thought oh maybe if i complete the rest of the code the issue may be in something ive missed. hopefully it is something simple or something that is staring straight at me but i guess ive been staring at my code for too long.

Thank you in advance

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


class Scene(object):

    def enter(self):
        print("THIS IS A SCENE THAT 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')
        #print("current scene before while: ", current_scene)
        
        while current_scene != last_scene:
            #print(">>>>> TOP OF WHILE: current scene: ", current_scene, "last scene: ", last_scene)
            #print(">>> SCENE", next_scene_name)
            next_scene_name = current_scene.enter()
            #print(">>> SCENE", next_scene_name)
            current_scene = self.scene_map.next_scene(next_scene_name)

            #print("BOTTOM OF WHILE: current scene: ", current_scene, "last scene: ", last_scene)

        current_scene.enter()


class Death(Scene):

    quips = [
        "ENTER RANDOM DEATH MESSAGES, 1"
        "ENTER RANDOM DEATH MESSAGES, 2"
        "ENTER RANDOM DEATH MESSAGES, 3"
        "ENTER RANDOM DEATH MESSAGES, 4"
    ]

    def enter(self):
        print(Death.quips[randint(0, len(self.quips)-1)])
        exit(1)


class CentralCorridor(Scene):
    def enter(self):

        print(dedent("""
        TEXT FOR THE CENTRAL CORRIDOR
        _____________________________
        3 options
        shoot, dodge! and tell a joke
        
        """))

        action = input(">  ")
    
        if action == "shoot":
            print(dedent("""
            TEXT FOR THE SHOOT OPTION OF INPUT FROM ABOVE
            """))
            return 'death'
        elif action == "dodge!":
            print(dedent("""
            TEXT FOR THE DODGE OPTION OF INPUT FROM ABOVE
            """))
            return 'death'
        elif action == "tell a joke":
            print(dedent("""
            TEXT FOR THE TELL A JOKE OPTION OF INPUT FROM ABOVE
            """))
            #print("will this print")
            return 'Armory'
    
        else:
            print("DOES NOT COMPUTE")
            return 'central_corridor'


class Armory(Scene):
    def enter(self):

        print(dedent("""
        TEXT FOR THE ARMORY .........
        _____________________________
        
        """))

        #code = f"{randint(1,9)}{randint(1,9)}{randint(1,9)}"
        code = '123'
        guess = input("[KEYPAD]> ")
        guesses = 0

        while guess != code and guesses <10:
            print("ERROR 404: PASSWORD NOT FOUND")
            guesses += 1
            guess = input("[KEYPAD]> ")
    
        if guess == code:
            print(dedent("""
            TEXT FOR CORRECT ARMORY CODE 
            _____________________________
        
            """))
            return 'the_bridge'
    
        else:
            print(dedent("""
            TEXT FOR INCORRECT ARMORY CODE
            _____________________________
        
            """))
            return 'death'
      


class TheBridge(Scene):
    def enter(self):
        print(dedent("""
            TEXT FOR THE BRIDGE SCENE
            _____________________________
        
            """))
        action = input("> ")

        if action == "throw the bomb":
            print(dedent("""
            TEXT FOR throw the bomb
            _____________________________
        
            """))
            return 'death'

        elif action == "slowly place the bomb":
            print(dedent("""
            TEXT FOR slowly place the bomb
            _____________________________
        
            """))
            return 'escape_pod'
        else:
            print("DOES NOT COMPUTE")
            return 'the_bridge'


class EscapePod(Scene):
    def enter(self):
        print(dedent("""
            TEXT FOR THE ESCAPE POD SCENE
            _____________________________
        
            """))
        
        #good_pod = randint(1,5)
        good_pod = 2
        guess = input("[POD#]> ")

        if int(guess) != good_pod:
            print(dedent("""
            TEXT FOR BAD POD
            _____________________________
        
            """))
            return 'death'
        else:
            print(dedent("""
            TEXT FOR GOOD POD
            _____________________________
        
            """))
            return 'Finished'


class Finished(Scene):
    def enter(self):
        print("YOU WIN.... YAY")
        return 'Finished'
        


class Map(object):

    scenes = {
        'central_corridor' : CentralCorridor(),
        'armory' : Armory(),
        'the_bridge' : TheBridge(),
        'escape_pod' : EscapePod(),
        '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):
        return self.next_scene(self.start_scene)


a_map = Map("central_corridor")
a_game = Engine(a_map)
a_game.play()

HEY I FIGURED IT OUT >>>>>>>

typos … CHECK FOR TYPOS
return ‘armory’
IS NOT THE SAME AS
return ‘Armory’

thats the best and worst 4 hour of my life

Nice, that’s a classic thing to happen. You can’t figure something out, stuck for days, then you email one person and suddenly you’ve got the answer.

Try this next time: Write up exactly what you did here, but email it to yourself as if you’re emailing it to someone else. This is called “rubber ducky debugging”:

For some reason the act of describing your problem to anything external helps you reframe the problem and see the answer.

Thanks Zed,

Yea to be fair when I typed it out on the forum and read through my coded i spotted it …

A free service run by Zed A. Shaw for learncodethehardway.org.