|
| 1 | +from room import Room |
| 2 | + |
| 3 | +# Declare all the rooms |
| 4 | + |
| 5 | +room = { |
| 6 | + 'outside': Room("Outside Cave Entrance", |
| 7 | + "North of you, the cave mount beckons"), |
| 8 | + |
| 9 | + 'foyer': Room("Foyer", """Dim light filters in from the south. Dusty |
| 10 | +passages run north and east."""), |
| 11 | + |
| 12 | + 'overlook': Room("Grand Overlook", """A steep cliff appears before you, falling |
| 13 | +into the darkness. Ahead to the north, a light flickers in |
| 14 | +the distance, but there is no way across the chasm."""), |
| 15 | + |
| 16 | + 'narrow': Room("Narrow Passage", """The narrow passage bends here from west |
| 17 | +to north. The smell of gold permeates the air."""), |
| 18 | + |
| 19 | + 'treasure': Room("Treasure Chamber", """You've found the long-lost treasure |
| 20 | +chamber! Sadly, it has already been completely emptied by |
| 21 | +earlier adventurers. The only exit is to the south."""), |
| 22 | +} |
| 23 | + |
| 24 | + |
| 25 | +# Link rooms together |
| 26 | + |
| 27 | +room['outside'].n_to = room['foyer'] |
| 28 | +room['foyer'].s_to = room['outside'] |
| 29 | +room['foyer'].n_to = room['overlook'] |
| 30 | +room['foyer'].e_to = room['narrow'] |
| 31 | +room['overlook'].s_to = room['foyer'] |
| 32 | +room['narrow'].w_to = room['foyer'] |
| 33 | +room['narrow'].n_to = room['treasure'] |
| 34 | +room['treasure'].s_to = room['narrow'] |
| 35 | + |
| 36 | +# |
| 37 | +# Main |
| 38 | +# |
| 39 | + |
| 40 | +# Make a new player object that is currently in the 'outside' room. |
| 41 | + |
| 42 | +# Write a loop that: |
| 43 | +# |
| 44 | +# * Prints the current room name |
| 45 | +# * Prints the current description (the textwrap module might be useful here). |
| 46 | +# * Waits for user input and decides what to do. |
| 47 | +# |
| 48 | +# If the user enters a cardinal direction, attempt to move to the room there. |
| 49 | +# Print an error message if the movement isn't allowed. |
| 50 | +# |
| 51 | +# If the user enters "q", quit the game. |
0 commit comments