How do you require the player to have a certain key or item to open a certain door or access a certain room?
To start, per Exercise 3 of the JavaOne 7400darkstar Lab, everything
in the game is based on the MudObject class and
therefore implement the ManagedObject interface and is Serializable. This causes all game objects to be managed
by the PDS server database services to give the objects persistence. Game objects are passed around using their
ManagedReference, not as ManagedObjects.
The MudObject class (1a) defines a minimal interface that allows all objects to have a description, maintain an inventory, support
aliases of its name, and parse commands. For items that the Player can carry around and use, the GettableObject class (1b) provides the commands and methods to support that.
The command parsing is where a lot of the game magic takes place and understanding
it will be our holy grail.
Example: the Rope object
The Rope is going to be used to interact with a door. Since it has to exsit in the game, it must be (3a) a MudObject which
is a ManagedObject and is Serializable allowing the server to manage its existance. Also, since it is going to be used by the
Player, the Player has to be able to pick it up and add it to their inventory. Therefore, the Rope will be a GettableObject
which extends the MudObject class.
The MudObject provides the look command support. The GettableObject
provide the additional take and drop command
support. Since the actions in the game are done by the target of a command. Rope action commands have to be supported
by objects that respond to the Rope. This will be the Trap Door that will be discussed later.