Next: , Previous: class Container, Up: Class Definitions



5.14 class Exit

The Exit class connects two locations. Each Exit is a one-way pointer to the destination. An Exit object in a room will respond to verbs such as 'go' and its own name, and put players through to the destination location.

Since it is both an important operation and one that exemplifies a lot of issues, here's what happens when the player wants to move from one location to another:

  1. The player's command is parsed and, eventually, a 'go' method (or whatever) is called on the exit.
  2. The exit asks the current location to give the player to the destination location. The process goes something like this:
    1. Updates the player object's location information with a given argument.
    2. Gives capabilities on the player to the remote location.
    3. Removes the player from itself.
  3. The exit decides if it wants to allow the operation. This may include examining the player's inventory for a key object of some kind.
  4. Note, however, that the exit itself does not have the capabilities on the player required to do the movement; those belong to the location itself.