Skip to content

Commit

Permalink
new adv
Browse files Browse the repository at this point in the history
  • Loading branch information
Beej Jorgensen committed Jul 23, 2018
1 parent a551651 commit 82ed3fe
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 77 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.vscode/
.vscode
*.pyc
__pycache__
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Learn the basics of Python with a pile of toy programs.

Take a look in the `src/` directory.

NOTE: `adv.py` is for Day 2, so ignore it for today.
NOTE: `adv/` is for Day 2, so ignore it for today.

Suggested order for implementing the toy programs:

Expand All @@ -85,7 +85,16 @@ Suggested order for implementing the toy programs:

Put it together into a bigger toy program: a simple text adventure!

This is in `src/adv.py`. Check it out!
This is in `src/adv/`. Check it out!

* Put the Room class in room.py based on what you see in `adv.py`.

* Put the Player class in `player.py`.

* Follow the instructions `adv.py`.

* Figure out what all those `.pyc` files are that appear after you successfully
run the program.

Stretch goals:

Expand Down
74 changes: 0 additions & 74 deletions src/adv.py

This file was deleted.

51 changes: 51 additions & 0 deletions src/adv/adv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from room import Room

# Declare all the rooms

room = {
'outside': Room("Outside Cave Entrance",
"North of you, the cave mount beckons"),

'foyer': Room("Foyer", """Dim light filters in from the south. Dusty
passages run north and east."""),

'overlook': Room("Grand Overlook", """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."""),

'narrow': Room("Narrow Passage", """The narrow passage bends here from west
to north. The smell of gold permeates the air."""),

'treasure': Room("Treasure Chamber", """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."""),
}


# Link rooms together

room['outside'].n_to = room['foyer']
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']

#
# Main
#

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

# 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.
2 changes: 2 additions & 0 deletions src/adv/player.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Write a class to hold player information, e.g. what room they are in
# currently.
2 changes: 2 additions & 0 deletions src/adv/room.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Implement a class to hold room information. This should have name and
# description attributes.

0 comments on commit 82ed3fe

Please sign in to comment.