Package model
Class GameState
java.lang.Object
model.GameState
- All Implemented Interfaces:
Serializable
GameState class implementation for Double Trouble Kingdom game, contains the Players, playerNumbers, the roundState, and other fields and methods for managing the state of the Game.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Calculates the soldier' path.boolean
Returns if the Game is ended.void
Determines the starting Player.Returns the animation buffer.Returns the current Player.int
Returns elapsed time.getEnemyCastle
(int playerNumber) Returns the enemy's Castle.getEnemySoldiers
(int playerNumber) Returns the enemy's Soldiers.getEnemyTowers
(int playerNumber) Returns the enemy's Towers.Returns the Players in an ArrayList.Returns the roundState.Returns the winner of the game.boolean
isEnded()
Checks if the game is ended.boolean
Returns if path visualization is enabled.void
loadBuildings
(Map map) Loads the buildings from a map file after load.void
Switches the current roundState to the next one.void
Restarts the elapsedTimer.void
setCurrentPlayer
(Player currentPlayer) Sets the current Player.void
setElapsedTime
(int elapsedTime) Sets the elapsed time.void
Sets the soldier's target.void
Starts the elapsedTimer.void
Stops the elapsedTimer.void
Toggles if path visualization is enabled.
-
Field Details
-
deltaTime
public static double deltaTimeThe deltaTime for animation drawing.
-
-
Constructor Details
-
GameState
public GameState()Constructs a gamesState. -
GameState
Constructs a copy of the GameState.- Parameters:
gameState
- the GameState to copy
-
GameState
Constructs a class containing the Players, roundState, and elapsedTimer.- Parameters:
p1Name
- name of Player1p2Name
- name of Player2database
- DB reference
-
-
Method Details
-
getAnimBuffer
Returns the animation buffer.- Returns:
- the animation buffer
-
loadBuildings
Loads the buildings from a map file after load.- Parameters:
map
- the map file
-
getPlayers
Returns the Players in an ArrayList.- Returns:
- the Players in an ArrayList
-
getRoundState
Returns the roundState.- Returns:
- the roundState
-
nextRoundState
public void nextRoundState()Switches the current roundState to the next one. Switches Player after Training roundState phase. -
isEnded
public boolean isEnded()Checks if the game is ended.- Returns:
- true if the game is ended
-
checkAlive
public boolean checkAlive()Returns if the Game is ended.- Returns:
- if the Game is ended
-
getWinner
Returns the winner of the game.- Returns:
- the winner of the game
-
decideStarter
public void decideStarter()Determines the starting Player. -
getCurrentPlayer
Returns the current Player.- Returns:
- the current Player
-
setCurrentPlayer
Sets the current Player.- Parameters:
currentPlayer
- the Player to set
-
startElapsedTimer
public void startElapsedTimer()Starts the elapsedTimer. -
stopElapsedTimer
public void stopElapsedTimer()Stops the elapsedTimer. -
restartElapsedTimer
public void restartElapsedTimer()Restarts the elapsedTimer. -
getEnemyCastle
Returns the enemy's Castle.- Parameters:
playerNumber
- the Player's number- Returns:
- the enemy's Castle
-
getEnemySoldiers
Returns the enemy's Soldiers.- Parameters:
playerNumber
- the Player's number- Returns:
- the enemy's Soldiers
-
setTargets
public void setTargets()Sets the soldier's target. -
getEnemyTowers
Returns the enemy's Towers.- Parameters:
playerNumber
- the Player's number- Returns:
- the enemy's Towers
-
getElapsedTime
public int getElapsedTime()Returns elapsed time.- Returns:
- elapsed time
-
setElapsedTime
public void setElapsedTime(int elapsedTime) Sets the elapsed time.- Parameters:
elapsedTime
- the elapsed time
-
calculatePaths
public void calculatePaths()Calculates the soldier' path. -
togglePathVisualization
public void togglePathVisualization()Toggles if path visualization is enabled. -
isPathVisualization
public boolean isPathVisualization()Returns if path visualization is enabled.- Returns:
- if path visualization is enabled
-