Package pvzclone.model.impl
Class GameStateImpl
java.lang.Object
pvzclone.model.impl.GameStateImpl
- All Implemented Interfaces:
GameState
Class that implements GameState.
This class supports reading and writing operations on fields.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoiddecSunScore(int costPlant) Decrements the sun points.intintReturns the win state at the end of the Game.intvoidIncreases the number of Zombies killed.voidIncreases the sun points obtained.voidIncreases the number of Zombies generated.voidsetWinState(boolean winState) Sets the win state of the current game.
-
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:GameStateIncreases the number of Zombies generated.- Specified by:
incZombiesGeneratedin interfaceGameState
-
incKilledZombies
public void incKilledZombies()Description copied from interface:GameStateIncreases the number of Zombies killed.- Specified by:
incKilledZombiesin interfaceGameState
-
incSunScore
public void incSunScore()Description copied from interface:GameStateIncreases the sun points obtained.- Specified by:
incSunScorein interfaceGameState
-
decSunScore
public void decSunScore(int costPlant) Description copied from interface:GameStateDecrements the sun points.- Specified by:
decSunScorein interfaceGameState- Parameters:
costPlant- cost of the chosen plant.
-
getKilledZombies
public int getKilledZombies()- Specified by:
getKilledZombiesin interfaceGameState- Returns:
- number of Zombies killed.
-
getSunScore
public int getSunScore()- Specified by:
getSunScorein interfaceGameState- Returns:
- sun points obtained.
-
getZombiesGenerated
public int getZombiesGenerated()- Specified by:
getZombiesGeneratedin interfaceGameState- Returns:
- number of Zombies generated.
-
areZombieAllKilled
public boolean areZombieAllKilled()- Specified by:
areZombieAllKilledin interfaceGameState- 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:GameStateSets the win state of the current game.- Specified by:
setWinStatein interfaceGameState- Parameters:
winState- the state of the current game.
-
getWinState
Description copied from interface:GameStateReturns the win state at the end of the Game.- Specified by:
getWinStatein interfaceGameState- Returns:
- true if player won, false if player lost, Optional.empty if game is not over.
-