import sys


def playerAction():
    return input("What do you do: ").lower()

# Rooms

def startRoom():
    # Room Content
    print("You need to reach room 204... wherever that is. You have a lesson in this building very soon.")
    print("There's a hallway to the north and to the west.")


    # Player Actions
    action = playerAction()
    
    if "north" in action:
        hallFive()
    elif "west" in action:
        hallZero()

    # Insert other room actions here

    else:
        print("You can't do that.")
    startRoom()


def hallZero():
    # Room Content
    print("You are in a hallway.")
    print("There's another hallway to the north, one door to the east and one door on the south wall.")


    # Player Actions
    action = playerAction()
    
    if "north" in action:
        hallOne()
    elif "east" in action:
        startRoom()
    elif "south" in action:
        cafe()


    # Insert other room actions here

    else:
        print("You can't do that.")
    hallZero()

def hallOne():
    # Room Content
    print("You're in a hallway.")
    print("There are stairs to the west, and further hallways to the north, the east and the south.")


    # Player Actions
    action = playerAction()
    
    if "north" in action:
        hallTwo()
    elif "east" in action:
        hallThree()
    elif "south" in action:
        hallZero()
    elif "west" in action or "stair" in action:
        hallFour()

    # Insert other room actions here

    else:
        print("You can't do that.")
    hallOne()

def hallTwo():
    # Room Content
    print("You are in a hallway.")
    print("There are five rooms to the north (labeled 1,2,3,4 and 5), and a hallway to the south.")


    # Player Actions
    action = playerAction()
    
    if "south" in action:
        hallOne

    # Insert other room actions here
    elif "1" in action:
        print("This isn't your room.")
    elif "2" in action:
        print("This isn't your room.")
    elif "3" in action:
        print("This isn't your room.")
    elif "4" in action:
        room204()
    elif "5" in action:
        print("This isn't your room.")

    else:
        print("You can't do that.")
    hallTwo()

def hallThree():
    # Room Content
    print("You are in a hallway.")
    print("There are three doors to the south (1, 2, 3) and hallways to the east and west")


    # Player Actions
    action = playerAction()
    
    if "east" in action:
        hallFive()
    elif "west" in action:
        hallOne()

    # Insert other room actions here
    elif "1" in action:
        print("This isn't your room.")
    elif "2" in action:
        print("This isn't your room.")
    elif "3" in action:
        print("This isn't your room.")


    else:
        print("You can't do that.")
    hallThree()

def hallFour():
    # Room Content
    print("You are in an upstairs hallway.")
    print("There are three rooms to the west, and the stairs are to the east.")


    # Player Actions
    action = playerAction()
    
    if "east" in action or "stair" in action:
        hallTwo()
    # Insert other room actions here
    elif "1" in action:
        print("This isn't your room.")
    elif "2" in action:
        print("This isn't your room.")
    elif "3" in action:
        print("This isn't your room.")

    else:
        print("You can't do that.")
    hallFour()

def hallFive():
    # Room Content
    print("You are in a hallway.")
    print("There is another hallway to the west.")
    print("The doors on the north and east walls appear to connect to the same room.")
    print("There is also a door on the south wall.")

    # Player Actions
    action = playerAction()
    
    if "north" in action or "east" in action:
        lounge()
    elif "south" in action:
        startRoom()
    elif "west" in action:
        hallThree()

    # Insert other room actions here

    else:
        print("You can't do that.")
    hallFive()


def lounge():
    # Room Content
    print("You're in a lounge, several students are milling around.")
    print("There are doors back to the hallway on the south and west walls.")

    # Player Actions
    action = playerAction()
    
    if "south" in action or "west" in action:
        hallFive()

    # Insert other room actions here

    else:
        print("You can't do that.")
    lounge()

def cafe():
    # Room Content
    print("The cafe is pretty busy, everyone is trying to buy coffee.")
    print("The door back to the hallway is to the north.")

    # Player Actions
    action = playerAction()
    
    if "north" in action:
        hallZero
    # Insert other room actions here

    else:
        print("You can't do that.")
    cafe()

def room204():
    # Room Content
    print("This is your classroom!")
    print("You recognise the people in here!")
    print("You win!")
    sys.exit()
    




startRoom()