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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
void
decSunScore
(int costPlant) Decrements the sun points.int
int
Returns the win state at the end of the Game.int
void
Increases the number of Zombies killed.void
Increases the sun points obtained.void
Increases the number of Zombies generated.void
setWinState
(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:GameState
Increases the number of Zombies generated.- Specified by:
incZombiesGenerated
in interfaceGameState
-
incKilledZombies
public void incKilledZombies()Description copied from interface:GameState
Increases the number of Zombies killed.- Specified by:
incKilledZombies
in interfaceGameState
-
incSunScore
public void incSunScore()Description copied from interface:GameState
Increases the sun points obtained.- Specified by:
incSunScore
in interfaceGameState
-
decSunScore
public void decSunScore(int costPlant) Description copied from interface:GameState
Decrements the sun points.- Specified by:
decSunScore
in interfaceGameState
- Parameters:
costPlant
- cost of the chosen plant.
-
getKilledZombies
public int getKilledZombies()- Specified by:
getKilledZombies
in interfaceGameState
- Returns:
- number of Zombies killed.
-
getSunScore
public int getSunScore()- Specified by:
getSunScore
in interfaceGameState
- Returns:
- sun points obtained.
-
getZombiesGenerated
public int getZombiesGenerated()- Specified by:
getZombiesGenerated
in interfaceGameState
- Returns:
- number of Zombies generated.
-
areZombieAllKilled
public boolean areZombieAllKilled()- Specified by:
areZombieAllKilled
in 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:GameState
Sets the win state of the current game.- Specified by:
setWinState
in interfaceGameState
- Parameters:
winState
- the state of the current game.
-
getWinState
Description copied from interface:GameState
Returns the win state at the end of the Game.- Specified by:
getWinState
in interfaceGameState
- Returns:
- true if player won, false if player lost, Optional.empty if game is not over.
-