Class GameStateImpl

java.lang.Object
pvzclone.model.impl.GameStateImpl
All Implemented Interfaces:
GameState

public final class GameStateImpl extends Object implements GameState
Class that implements GameState. This class supports reading and writing operations on fields.
  • Constructor Details

    • GameStateImpl

      public GameStateImpl(int totZombies)
      Constructor of GameStateImpl.
      Parameters:
      totZombies - number of zombies in the level.
  • Method Details

    • incZombiesGenerated

      public void incZombiesGenerated()
      Description copied from interface: GameState
      Increases the number of Zombies generated.
      Specified by:
      incZombiesGenerated in interface GameState
    • incKilledZombies

      public void incKilledZombies()
      Description copied from interface: GameState
      Increases the number of Zombies killed.
      Specified by:
      incKilledZombies in interface GameState
    • incSunScore

      public void incSunScore()
      Description copied from interface: GameState
      Increases the sun points obtained.
      Specified by:
      incSunScore in interface GameState
    • decSunScore

      public void decSunScore(int costPlant)
      Description copied from interface: GameState
      Decrements the sun points.
      Specified by:
      decSunScore in interface GameState
      Parameters:
      costPlant - cost of the chosen plant.
    • getKilledZombies

      public int getKilledZombies()
      Specified by:
      getKilledZombies in interface GameState
      Returns:
      number of Zombies killed.
    • getSunScore

      public int getSunScore()
      Specified by:
      getSunScore in interface GameState
      Returns:
      sun points obtained.
    • getZombiesGenerated

      public int getZombiesGenerated()
      Specified by:
      getZombiesGenerated in interface GameState
      Returns:
      number of Zombies generated.
    • areZombieAllKilled

      public boolean areZombieAllKilled()
      Specified by:
      areZombieAllKilled in interface GameState
      Returns:
      if number of zombies killed is equals to the effective zombie number to be killed.
    • setWinState

      public void setWinState(boolean winState)
      Description copied from interface: GameState
      Sets the win state of the current game.
      Specified by:
      setWinState in interface GameState
      Parameters:
      winState - the state of the current game.
    • getWinState

      public Optional<Boolean> getWinState()
      Description copied from interface: GameState
      Returns the win state at the end of the Game.
      Specified by:
      getWinState in interface GameState
      Returns:
      true if player won, false if player lost, Optional.empty if game is not over.