Class SimpleVisitor

java.lang.Object
rea.gameplay.games.SimpleVisitor
All Implemented Interfaces:
Visitor

public class SimpleVisitor extends Object implements Visitor
A simples visitor that counts elements of each kind in the game map, namely:

This visitor can be used to extend specialized visitors, to collect other information needed to check if the games is completed, by going through all the elements in the map. The extended visitor may reuse methods from this class that propagate Element.accept(Visitor) to descendents.

This class is part of the Visitor pattern - a concrete visitor.

Author:
José Paulo Leal jpleal@fc.up.pt
  • Constructor Details

    • SimpleVisitor

      public SimpleVisitor()
      Create an instance of this class. No particular initializations are performed.
  • Method Details

    • visit

      public void visit(Character character)
      Description copied from interface: Visitor
      Do a visit to a character in the composite structure
      Specified by:
      visit in interface Visitor
      Parameters:
      character - to be visited
    • visit

      public void visit(Place place)
      Description copied from interface: Visitor
      Do a visit to a place in the composite structure
      Specified by:
      visit in interface Visitor
      Parameters:
      place - to be visited
    • visit

      public void visit(Item item)
      Description copied from interface: Visitor
      Do a visit to an item in the composite structure
      Specified by:
      visit in interface Visitor
      Parameters:
      item - to be visited
    • visit

      public void visit(Passage passage)
      Description copied from interface: Visitor
      Do a visit to a passage in the composite structure
      Specified by:
      visit in interface Visitor
      Parameters:
      passage - to be visited
    • getCharacters

      public Set<Character> getCharacters()
      The set of players in the map. This value will change as players are added and removed from the map.
      Returns:
      the set of players in the map
    • getPlaces

      public Set<Place> getPlaces()
      The set places in the map. This value will change as places are added and removed from the map.
      Returns:
      set of places in the map
    • getItems

      public Set<Item> getItems()
      The set of items in the map. This will change as items are collected and remove from the map.
      Returns:
      set of items in the map
    • getPassages

      public Set<Passage> getPassages()
      The set of passages in the map. This value will change as certain items are used other items. For instance, if a key is used to open a door, the door will be changed in a passage to another place
      Returns:
      set of passages in the map