Class GameMap

java.lang.Object
rea.components.GameMap

public class GameMap extends Object

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 Details

    • startPlace

      Place startPlace
      The start place of the game map. Since the start place is the root of the composite, this will set the entire game map.
    • changes

      Changes that may be performed on positionable objects in the game.
  • Constructor Details

    • GameMap

      public GameMap(Place startPlace)
      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

      public Place 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

      public void setStartPlace(Place startPlace)
      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

      public void defineChange(Positionable modifiable, Item tool, Positionable modified)
      Define a change that may be performed on a positionable object in the game.
      Parameters:
      modifiable - the positionable object that may be modified
      tool - the item that may be used to modify the positionable object
      modified - the modified positionable object
    • getChange

      public Positionable getChange(Positionable modifiable, Item tool)
      Get the change that may be performed on a positionable object in the game.
      Parameters:
      modifiable - the positionable object that may be modified
      tool - the item that may be used to modify the positionable object
      Returns:
      the modified positionable object, or null if no change is defined
    • visitMap

      public void visitMap(Visitor visitor)
      Visit the map from the start place.
      Parameters:
      visitor - the visitor to accept