# Write a text adventure game that allows the player to move from room to room by
# typing "n", "w", "s", and "e" for north, west, south, and east respectively.

# These are the existing rooms. Add more as you see fit.

import textwrap

rooms = {
    "outside": {
        "name": "Outside Cave Entrance",
        "description": "North of you, the cave mouth beckons.",
        "n_to": "foyer",
    },

    "foyer": {
        "name": "Foyer",
        "description": "Dim light filters in from the south. Dusty passages run north and east.",
        "n_to": "overlook",
        "s_to": "outside",
        "e_to": "narrow",
    },

    "overlook": {
        "name": "Grand Overlook",
        "description": """A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm.""",
        "s_to": "foyer",
    },

    "narrow": {
        "name": "Narrow Passage",
        "description": "The narrow passage bends here from west to north. The smell of gold permeates the air.", 
        "w_to": "foyer",
        "n_to": "treasure",
    },

    "treasure": {
        "name": "Treasure Chamber",
        "description": """You've found the long-lost treasure
chamber. Sadly, it has already been completely emptied by
earlier adventurers. The only exit is to the south.""",
        "s_to": "narrow",
    },

}

""" template room to copy into code
    "room": {
        "name": "",
        "description": "",
        "n_to": "",
        "s_to": "",
        "e_to": "",
        "w_to": "",
    },
"""

# Write a class to hold player information, e.g. what room they are in currently

class Character:
    """ Holds information about the player. """
    def __init__(self, start_room):
        self.current_room = start_room

def direction(d, current_room):
    """ How a character moves. """
    key = d + "_to"

    if key not in rooms[current_room]:
        print("You can't go that way.")
        return current_room

    destination = rooms[current_room][key]

    return destination

#
# Main
#

# Make a new player object that is currently in the 'outside' room.

c = Character('outside')

# Write a loop that:
#
# * Prints the current room name

# * Prints the current description (the textwrap module might be useful here).

# * Waits for user input and decides what to do.
#

# If the user enters a cardinal direction, attempt to move to the room there.
# Print an error message if the movement isn't allowed.
#
# If the user enters "q", quit the game.

finished_with_game = False

while not finished_with_game:
    # Print name of current room.
    print("\n{}\n".format(rooms[c.current_room]['name']))

    # Print the description of the room.
    for line in textwrap.wrap(rooms[c.current_room]['description']):
        print(line)

    # User prompt
    s = input("\n<Command> ").strip().lower()

    # Handle input
    if s == "q":
        finished_with_game = True
    elif s in ["n", "s", "w", "e"]:
        c.current_room = direction(s, c.current_room)
    else:
        print("Unknown command {}".format(s))
5a4c332ad62f672d2ac4c8dee3e2152dd3a2c49a
<mask token>


class Character:
    """ Holds information about the player. """

    def __init__(self, start_room):
        self.current_room = start_room


def direction(d, current_room):
    """ How a character moves. """
    key = d + '_to'
    if key not in rooms[current_room]:
        print("You can't go that way.")
        return current_room
    destination = rooms[current_room][key]
    return destination


<mask token>

<mask token>


class Character:
    """ Holds information about the player. """

    def __init__(self, start_room):
        self.current_room = start_room


def direction(d, current_room):
    """ How a character moves. """
    key = d + '_to'
    if key not in rooms[current_room]:
        print("You can't go that way.")
        return current_room
    destination = rooms[current_room][key]
    return destination


<mask token>
while not finished_with_game:
    print('\n{}\n'.format(rooms[c.current_room]['name']))
    for line in textwrap.wrap(rooms[c.current_room]['description']):
        print(line)
    s = input('\n<Command> ').strip().lower()
    if s == 'q':
        finished_with_game = True
    elif s in ['n', 's', 'w', 'e']:
        c.current_room = direction(s, c.current_room)
    else:
        print('Unknown command {}'.format(s))

<mask token>
rooms = {'outside': {'name': 'Outside Cave Entrance', 'description':
    'North of you, the cave mouth beckons.', 'n_to': 'foyer'}, 'foyer': {
    'name': 'Foyer', 'description':
    'Dim light filters in from the south. Dusty passages run north and east.',
    'n_to': 'overlook', 's_to': 'outside', 'e_to': 'narrow'}, 'overlook': {
    'name': 'Grand Overlook', 'description':
    """A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm."""
    , 's_to': 'foyer'}, 'narrow': {'name': 'Narrow Passage', 'description':
    'The narrow passage bends here from west to north. The smell of gold permeates the air.'
    , 'w_to': 'foyer', 'n_to': 'treasure'}, 'treasure': {'name':
    'Treasure Chamber', 'description':
    """You've found the long-lost treasure
chamber. Sadly, it has already been completely emptied by
earlier adventurers. The only exit is to the south."""
    , 's_to': 'narrow'}}
<mask token>


class Character:
    """ Holds information about the player. """

    def __init__(self, start_room):
        self.current_room = start_room


def direction(d, current_room):
    """ How a character moves. """
    key = d + '_to'
    if key not in rooms[current_room]:
        print("You can't go that way.")
        return current_room
    destination = rooms[current_room][key]
    return destination


c = Character('outside')
finished_with_game = False
while not finished_with_game:
    print('\n{}\n'.format(rooms[c.current_room]['name']))
    for line in textwrap.wrap(rooms[c.current_room]['description']):
        print(line)
    s = input('\n<Command> ').strip().lower()
    if s == 'q':
        finished_with_game = True
    elif s in ['n', 's', 'w', 'e']:
        c.current_room = direction(s, c.current_room)
    else:
        print('Unknown command {}'.format(s))

import textwrap
rooms = {'outside': {'name': 'Outside Cave Entrance', 'description':
    'North of you, the cave mouth beckons.', 'n_to': 'foyer'}, 'foyer': {
    'name': 'Foyer', 'description':
    'Dim light filters in from the south. Dusty passages run north and east.',
    'n_to': 'overlook', 's_to': 'outside', 'e_to': 'narrow'}, 'overlook': {
    'name': 'Grand Overlook', 'description':
    """A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm."""
    , 's_to': 'foyer'}, 'narrow': {'name': 'Narrow Passage', 'description':
    'The narrow passage bends here from west to north. The smell of gold permeates the air.'
    , 'w_to': 'foyer', 'n_to': 'treasure'}, 'treasure': {'name':
    'Treasure Chamber', 'description':
    """You've found the long-lost treasure
chamber. Sadly, it has already been completely emptied by
earlier adventurers. The only exit is to the south."""
    , 's_to': 'narrow'}}
<mask token>


class Character:
    """ Holds information about the player. """

    def __init__(self, start_room):
        self.current_room = start_room


def direction(d, current_room):
    """ How a character moves. """
    key = d + '_to'
    if key not in rooms[current_room]:
        print("You can't go that way.")
        return current_room
    destination = rooms[current_room][key]
    return destination


c = Character('outside')
finished_with_game = False
while not finished_with_game:
    print('\n{}\n'.format(rooms[c.current_room]['name']))
    for line in textwrap.wrap(rooms[c.current_room]['description']):
        print(line)
    s = input('\n<Command> ').strip().lower()
    if s == 'q':
        finished_with_game = True
    elif s in ['n', 's', 'w', 'e']:
        c.current_room = direction(s, c.current_room)
    else:
        print('Unknown command {}'.format(s))

# Write a text adventure game that allows the player to move from room to room by
# typing "n", "w", "s", and "e" for north, west, south, and east respectively.

# These are the existing rooms. Add more as you see fit.

import textwrap

rooms = {
    "outside": {
        "name": "Outside Cave Entrance",
        "description": "North of you, the cave mouth beckons.",
        "n_to": "foyer",
    },

    "foyer": {
        "name": "Foyer",
        "description": "Dim light filters in from the south. Dusty passages run north and east.",
        "n_to": "overlook",
        "s_to": "outside",
        "e_to": "narrow",
    },

    "overlook": {
        "name": "Grand Overlook",
        "description": """A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm.""",
        "s_to": "foyer",
    },

    "narrow": {
        "name": "Narrow Passage",
        "description": "The narrow passage bends here from west to north. The smell of gold permeates the air.", 
        "w_to": "foyer",
        "n_to": "treasure",
    },

    "treasure": {
        "name": "Treasure Chamber",
        "description": """You've found the long-lost treasure
chamber. Sadly, it has already been completely emptied by
earlier adventurers. The only exit is to the south.""",
        "s_to": "narrow",
    },

}

""" template room to copy into code
    "room": {
        "name": "",
        "description": "",
        "n_to": "",
        "s_to": "",
        "e_to": "",
        "w_to": "",
    },
"""

# Write a class to hold player information, e.g. what room they are in currently

class Character:
    """ Holds information about the player. """
    def __init__(self, start_room):
        self.current_room = start_room

def direction(d, current_room):
    """ How a character moves. """
    key = d + "_to"

    if key not in rooms[current_room]:
        print("You can't go that way.")
        return current_room

    destination = rooms[current_room][key]

    return destination

#
# Main
#

# Make a new player object that is currently in the 'outside' room.

c = Character('outside')

# Write a loop that:
#
# * Prints the current room name

# * Prints the current description (the textwrap module might be useful here).

# * Waits for user input and decides what to do.
#

# If the user enters a cardinal direction, attempt to move to the room there.
# Print an error message if the movement isn't allowed.
#
# If the user enters "q", quit the game.

finished_with_game = False

while not finished_with_game:
    # Print name of current room.
    print("\n{}\n".format(rooms[c.current_room]['name']))

    # Print the description of the room.
    for line in textwrap.wrap(rooms[c.current_room]['description']):
        print(line)

    # User prompt
    s = input("\n<Command> ").strip().lower()

    # Handle input
    if s == "q":
        finished_with_game = True
    elif s in ["n", "s", "w", "e"]:
        c.current_room = direction(s, c.current_room)
    else:
        print("Unknown command {}".format(s))