NewRooms.html
18jun09 CmdrZin
25sep10 CmdrZin

Adding a Maze

This effort is to add a simple maze the to existing DarkMud map to help understand how the properties file works in regards to rooms.

We start by looking at the original map and then extending it wit a simple maze. With a picture of what the end result should be, adding the required entries to the properties file should be easy.
   

Original Map New Map
          ------
         |      |
         | Clst |
         |      |
   ------ --||--
  |      |      |
  | Draw = Strt |
  |(TrpD)|      |
   ------ --||-- ------
         |      |      |
         | Dark =  Lib |
         |      | (map)|
          --||-- ------
         |      |
         |North |
         | Cavn |
          --||--
         |      |
         |South |
         | Cavn |
          ------
          ------ ------ ------ ------
         |      |      |      |      |
         | Clst |  m14 =  m15 =  m11 |
         |      |      |      |      |
   ------ --||-- --||-- ------ --||--
  |      |      |      |      |      |
  | Draw =Start <  m13 =  m12 =  m10 |
  |(TrpD)|      |      |      |      |
   ------ --||-- ------ ------ --||--
         |      |      |      |      |
         | Dark =  Lib |      |  m9  |
         |      | (map)|      |      |
          --||-- ------ ------ --||-- ------
         |      |      |      |      |      |
         |North |  m4  =  m3  |  m8  |  m7  |
         | Cavn |      |      |      |      |
          --||-- ------ --||-- --||-- --||--
         |      |      |      |      |      |
         |South >  m1  =  m2  =  m5  =  m6  |
         | Cavn |      |      |      |      |
          ------ ------ ------ ------ ------

I've inserted room names on the map to make life easy in matching the properties to the map.
The double lines || and = indicate two-way doors and the arrows < and > indicated one-way doors.

Now would be a good time to describe the maze a bit since it's right here to look at.
Turn on the creative juice machine (or have a few beers) and come up with a hopefully interesting store for the maze.
Here's my cut at it (burp).
Add to the South Cavern a door to the EAST.
  Description (look): You see a small dark opening in the east wall of the cavern.
Room m1.
  Description: Dark tunnel
  Description (look): You are in a small dark tunnel. It continues to the east.
Room m2. Intersection
  Description:  Intersection
  Description (look): You are at an intersection of tunnels leading north, west, and east. There is glowing fungus on the walls.
Room m3.
  Description: Dark cave
  Description (look): You are in a small dark cave. There are opening to the west and south.
Room m4.
  Description: Cave with mushrooms
  Description (look): This small cave is littered with glowing mushrooms. There is a dried up skeleton here.
etc...

This maze can be made harder by using the same name and descriptions for all of the rooms (i.e. You see little twisty passages all the same.)
But then, this is just an example.

The descriptions and paths need to be converted into properties for the game to use. For this we refer to Appendix A of the Java One LAB-7400 document.
Here's the excerpt about Doors and Rooms that is needed.

A room is described by the following properties:

room.<name>.class The fully qualified name of the class from which the room should be instantiated. If this property is left out, the room is instantiated from com.sun.sgs.darkmud.core.Room.
room.<name>.description The description of the room. If this property is left out, the room is given a default description.
room.<name>.inventory A comma-separated list of the property names of all the objects to be created in this room, including doors. Doors must be named in the format door.<room_name>.<direction_abv>. For example, a door in the starting room that goes south would be named door.origin.s. Objects are name item.<name>, like item.lamp.

A door is described by the following properties:

door.<room_name>.<direction_abv>.class The fully qualified name of the class from which the door should be instantiated. If this property is left out, the door is instantiated from com.sun.sgs.darkmud.core.Door.
door.<room_name>.<direction_abv>.aliases A comma-separated list of names by which the door is known. In general a door doesn't need any aliases because it is represented by its direction. There are, however, cases where the door may provide some higher level of interaction, such as a locked door or a portable door, requiring that the door be addressable directly.
door.<room_name>.<direction_abv>.description The description of the door. If this property is left out, the door is given a default description. This description is what a player sees when he looks at the room containing the door.
door.<room_name>.<direction_abv>.long_description The long description of the door. If this property is left out, the door uses the regular description. This description is what a player sees when he looks at the door.
door.<room_name>.<direction_abv>.destination The property name of the room to which the door connects.
Since none of the Rooms are special, they do not need a room.<>.class property. We only have to use a description and the inventory entries.
The Door description for the Room are set by the Door properties, so they do not have to be entered here. We do have to make sure to put the Doors in the inventory for the Room or they wont show up!
The first thing that is needed is a door added to the South Cavern that leads into the maze.
room.southCavern.inventory=door.southCavern.n, door.southCavern.crazy, item.rope, door.southCavern.e
And a little bit of text to set the mood.
door.southCavern.e.long_description=You see a small dark opening in the east wall of the cavern.
Since this is a long_description, it only shows up if the player uses the LOOK command.
The normal description is set to space so that nothing show up for the Door when entering the room. This is a simple way of hidding the door.
door.southCavern.e.description=

Now we can describe the maze using the descriptions above.
The Door is an object in the Room, therefore it is listed in the Rooms inventory. Only the first parts of the Door identifier are needed to uniquely identify it.
room.m1.description=You are in a small dark tunnel.
room.m1.inventory=door.m1.e
Since we have a Door, we should give it a destination. As with the Door, only the first parts of the Room are needed.
door.m1.e.destination=room.m2
Notice that there isn't a Door to the west. This makes the Door from the South Cavern effectively a one-way door.
Here are the added properties:
room.southCavern.inventory=door.southCavern.n, door.southCavern.crazy, item.rope, door.southCavern.e
door.southCavern.e.long_description=You see a small dark opening in the east wall of the cavern.
door.southCavern.e.description=
room.m1.description=You are in a small dark tunnel.
room.m1.inventory=door.m1.e
door.m1.e.destination=room.m2
door.m1.e.description=A small opening leading to the east.

room.m2.description=You are at an intersection of tunnels. There is glowing fungus on the walls.
room.m2.inventory=door.m2.e, door.m2.n, door.m2.w
door.m2.e.destination=room.m1
door.m2.e.description=A small opening leading to the east.
door.m2.n.destination=room.m5
door.m2.n.description=A small opening leading to the north.
door.m2.w.destination=room.m3
door.m2.w.description=A small opening leading to the west.
# Descriptions are used so the user is told it's an opening and not a door.
room.m3.description=You are in a small dark cave.
room.m3.inventory=door.m3.w, door.m3.s
door.m3.w.destination=room.m4
door.m3.w.description=A small opening leading to the west.
door.m3.s.destination=room.m2
door.m3.s.description=A small opening leading to the south.

room.m4.description=This small cave is littered with glowing mushrooms. There is dried up skelleton here.
room.m4.inventory=door.m4.e
door.m4.e.destination=room.m3
door.m4.e.description=A small opening leading to the east.
etc...(see MudMainMaze.properties file)

Cut and pasting into the MudMain.properties file then boot up the game (be sure to erase the db files) and check for warnings.
Hmm..no destination for door.southCavern.e .. doh
door.southCavern.e.destination=room.m1

Ok, pick up lamp, head south, touch altar and float south across to South Cavern...hmm..no long description..just "east"
"go e".."You are in You are in a small dark tunnel."...Guess the "You are in" is not needed..go back and edit out.
"look".."A small opening leading to the east.east"..so don't need to put in direction either..edit file, erase db, and restart.
Remember to put a space after the description of the Door.
Hmm..opening doesn't get listed on entrance, which is what we want, and does get described on "look"..ok..
more navigation bugs..travel though the maze and verify each door and room...edit file as needed..
Ok..all fixed up and checked out..go the the map room..woo hoo..the maze shows up!!!! Cool.

The properties file will be named MudMainMaze.properties. To use it, rename it MudMain.properties and replace the old file with it.