Package rea.components
Class GameMap
java.lang.Object
rea.components.GameMap
The game map. It is a composite of places, items, characters and passages. The game map is a directed acyclic graph (DAG) where the nodes are places and arcs are passages. Since this DAG has a single root, it can be assigned by its rrot node, the start place.
During the game, the game map may change. For example, a place may have closed door (an unpickable item) and in a different place there is a key (a pickable but non-reusable item). The player may pick the key, move to the place with the closed door, use the key to open the door, and then become an open door (a passage). The DAG representing the game map may change as a result of these actions.
The game map can be transversed using a visitor.- Author:
- José Paulo Leal
jpleal@fc.up.pt
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Map
<Positionable, Map<Item, Positionable>> Changes that may be performed on positionable objects in the game.(package private) Place
The start place of the game map. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
defineChange
(Positionable modifiable, Item tool, Positionable modified) Define a change that may be performed on a positionable object in the game.getChange
(Positionable modifiable, Item tool) Get the change that may be performed on a positionable object in the game.Get the start place of the game map.void
setStartPlace
(Place startPlace) Set the start place of the game map.void
Visit the map from the start place.
-
Field Details
-
startPlace
Place startPlaceThe start place of the game map. Since the start place is the root of the composite, this will set the entire game map. -
changes
Map<Positionable,Map<Item, changesPositionable>> Changes that may be performed on positionable objects in the game.
-
-
Constructor Details
-
GameMap
Create a game map with a start place. Since the start place is the root of the composite, this will set the entire game map.- Parameters:
startPlace
- the start place of the game map
-
-
Method Details
-
getStartPlace
Get the start place of the game map. Since the start place is the root of the composite, this will return the entire game map.- Returns:
- the start place of the game map
-
setStartPlace
Set the start place of the game map. Since the start place is the root of the composite, this will change the entire game map.- Parameters:
startPlace
- for the game map
-
defineChange
Define a change that may be performed on a positionable object in the game.- Parameters:
modifiable
- the positionable object that may be modifiedtool
- the item that may be used to modify the positionable objectmodified
- the modified positionable object
-
getChange
Get the change that may be performed on a positionable object in the game.- Parameters:
modifiable
- the positionable object that may be modifiedtool
- the item that may be used to modify the positionable object- Returns:
- the modified positionable object, or
null
if no change is defined
-
visitMap
Visit the map from the start place.- Parameters:
visitor
- the visitor to accept
-