Skip to content

Conversation

@janash
Copy link
Contributor

@janash janash commented Aug 15, 2019

This PR adds some code for creating an ascii map of rooms visited.

  • A 'map' item is added in the study. Once the map is picked up, it will automatically populate with rooms the player has visited.
  • A command 'show map' is added
  • Some additional variables are added for book keeping (which rooms have been visited - for map purposes)
  • The module map.py contains functions associated with the map. In order to get room positions, the rooms are treated as a graph and a depth first search algorithm is used to get room positions (https://en.wikipedia.org/wiki/Graph_traversal).

I've separated most of the map functions into a separate module to hide most of the code.

The map is drawn by house floor and by the row the room is on in the show_map function. The map is rendered each time the function is called. The current room label is printed in ALL CAPS.

I've also changed some comments using # to use ''' - just a Python style thing.

@janash
Copy link
Contributor Author

janash commented Aug 15, 2019

Here is the full map from the code as written:

Floor 2

-..........-+----------+-..........-
 .......... |          | .......... 
 .......... |          | .......... 
            | Sun Room |            
 .......... |          | .......... 
 .......... |          | .......... 
-..........-+----------+-..........-

+----------++----------++----------+
|          ||          ||          |
|          ||          ||          |
| Office   || Master Be|| Bathroom |
|          ||          ||          |
|          ||          ||          |
+----------++----------++----------+

-..........-+----------+-..........-
 .......... |          | .......... 
 .......... |          | .......... 
            | Upstairs |            
 .......... |          | .......... 
 .......... |          | .......... 
-..........-+----------+-..........-

-..........--..........--..........-
 ..........  ..........  .......... 
 ..........  ..........  .......... 
                                    
 ..........  ..........  .......... 
 ..........  ..........  .......... 
-..........--..........--..........-

-..........--..........--..........-
 ..........  ..........  .......... 
 ..........  ..........  .......... 
                                    
 ..........  ..........  .......... 
 ..........  ..........  .......... 
-..........--..........--..........-
Floor 1

-..........--..........--..........-
 ..........  ..........  .......... 
 ..........  ..........  .......... 
                                    
 ..........  ..........  .......... 
 ..........  ..........  .......... 
-..........--..........--..........-

-..........-+----------+-..........-
 .......... |          | .......... 
 .......... |          | .......... 
            | Garden   |            
 .......... |          | .......... 
 .......... |          | .......... 
-..........-+----------+-..........-

+----------++----------++----------+
|          ||          ||          |
|          ||          ||          |
| Parlor   || Atrium   || Guest Bed|
|          ||          ||          |
|          ||          ||          |
+----------++----------++----------+

+----------++----------++----------+
|          ||          ||          |
|          ||          ||          |
| Library  || Hall     || Dining Ro|
|          ||          ||          |
|          ||          ||          |
+----------++----------++----------+

+----------++----------++----------+
|          ||          ||          |
|          ||          ||          |
| Study    || Kitchen  || Pantry   |
|          ||          ||          |
|          ||          ||          |
+----------++----------++----------+

@darrell24015 darrell24015 self-assigned this Aug 19, 2019
@darrell24015 darrell24015 merged commit d399b64 into LearnToProgramRoanoke:master Aug 19, 2019
@darrell24015
Copy link
Contributor

The map is a great addition to the game. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants