Class ControllerImpl

java.lang.Object
pvzclone.controller.impl.ControllerImpl
All Implemented Interfaces:
Controller

public final class ControllerImpl extends Object implements Controller
Class that implements the Controller.
  • Constructor Details

    • ControllerImpl

      public ControllerImpl()
      Initializes the game.
  • Method Details

    • callMainloop

      public void callMainloop()
      Description copied from interface: Controller
      Calls the main loop of the game. This method should be called after the game is initialized.
      Specified by:
      callMainloop in interface Controller
    • getEntities

      public Set<Entities> getEntities()
      Description copied from interface: Controller
      Retrieves the set of entities in the game. Entities represent the elements present in the game world.
      Specified by:
      getEntities in interface Controller
      Returns:
      a Set of Entities representing the elements in the game world.
    • newPlant

      public void newPlant(Pair<Integer,Integer> pos)
      Description copied from interface: Controller
      this method communicates with the model telling him the position of the new plant.
      Specified by:
      newPlant in interface Controller
      Parameters:
      pos - is the position of the new plant.
    • increaseSunPoints

      public void increaseSunPoints()
      Description copied from interface: Controller
      Increases the points obtained by the suns in GameState.
      Specified by:
      increaseSunPoints in interface Controller
    • getSunScore

      public int getSunScore()
      Description copied from interface: Controller
      Retrieves the points from the GameState.
      Specified by:
      getSunScore in interface Controller
      Returns:
      points obtained at the moment.
    • chooseLevel

      public void chooseLevel(int numberOfTheLevel)
      Description copied from interface: Controller
      Sets the number of the Level to the number of the argument passed.
      Specified by:
      chooseLevel in interface Controller
      Parameters:
      numberOfTheLevel - level index.
    • getChosenLevel

      public Optional<Integer> getChosenLevel()
      Description copied from interface: Controller
      Retrieves the number of the chosen level if the level was chosen, if not it returns an empty Optional.
      Specified by:
      getChosenLevel in interface Controller
      Returns:
      number of the level that we chose.
    • getLevelCount

      public int getLevelCount()
      Description copied from interface: Controller
      Returns the number of levels available in the application.
      Specified by:
      getLevelCount in interface Controller
      Returns:
      number of levels available in the application.