Class GameState
java.lang.Object
com.hiddenswitch.spellsource.common.GameState
- All Implemented Interfaces:
Serializable
,Cloneable
The fields that correspond to a complete state of the game.
This game state is used, in practice, as a snapshot of the game in a specific point in time using GameContext.getGameStateCopy()
and to copy games using GameContext.setGameState(GameState)
.
Creating a game state using GameContext.getGameState()
produces an instance whose objects are shared with the
GameContext
. Mutating the player objects, for example, in such a game state will also mutate the player
objects in the context. To retrieve a copy, use GameContext.getGameState()
or clone()
the state.
While the fields in this instance are immutable, the engine does not prevent changes to fields within the fields. This is not an immutable data type.
-
Constructor Summary
ConstructorsConstructorDescriptionGameState
(GameContext fromContext) GameState
(GameContext fromContext, TurnState turnState) GameState
(GameContext fromContext, TurnState turnState, boolean byReference) -
Method Summary
Modifier and TypeMethodDescriptionclone()
int
The currently active player.int
The next ID to generate in anIdFactoryImpl
/The deck format of this game.Gets a reference to the game context's environment, a piece of game state that keeps tracks of which minions are currently being summoned, which targets are being targeted, how much damage is set to be dealt, etc.protected Map<Integer,
EntityLocation> getMap()
Gets a map containing all theEntityLocation
objects in this game state.The amount of time left in a timer, such as an end of turn or mulligan timer, until the player's actions are automatically terminated.A player object corresponding to the arbitrarily-decided first player of the game.A player object corresponding to the arbitrarily-decided second player of the game.static long
ACardList
of cards that are temporarily created in this game.long
The timestamp of when thisGameState
was accessed.int
The current turn number.The currentTurnState
of the game.Gets the variables in the game.com.google.common.collect.MapDifference<Integer,
EntityLocation> start()
Gets aMapDifference
that corresponds to this state being the first state.com.google.common.collect.MapDifference<Integer,
EntityLocation> Gets a difference between this game state and thenextState
in terms of entity locations.
-
Constructor Details
-
GameState
-
GameState
-
GameState
-
-
Method Details
-
getSerialVersionUID
public static long getSerialVersionUID() -
getEntities
-
getMap
Gets a map containing all theEntityLocation
objects in this game state.- Returns:
- A map.
-
start
Gets aMapDifference
that corresponds to this state being the first state.- Returns:
- A
Maps.difference(Map, Map)
call where an empty map is the left argument and this game state is the right argument.
-
clone
-
getPlayer1
A player object corresponding to the arbitrarily-decided first player of the game.- See Also:
-
getPlayer2
A player object corresponding to the arbitrarily-decided second player of the game.- See Also:
-
getTempCards
ACardList
of cards that are temporarily created in this game. -
getEnvironment
Gets a reference to the game context's environment, a piece of game state that keeps tracks of which minions are currently being summoned, which targets are being targeted, how much damage is set to be dealt, etc.This helps implement a variety of complex rules in the game.
-
getCurrentId
public int getCurrentId()The next ID to generate in anIdFactoryImpl
/ -
getActivePlayerId
public int getActivePlayerId()The currently active player. -
getTurnState
The currentTurnState
of the game. -
getTimestamp
public long getTimestamp()The timestamp of when thisGameState
was accessed. -
getTurnNumber
public int getTurnNumber()The current turn number. -
getDeckFormat
The deck format of this game. -
getMillisRemaining
The amount of time left in a timer, such as an end of turn or mulligan timer, until the player's actions are automatically terminated. Whennull
, no timer is set. -
getVariables
Gets the variables in the game. Spells are responsible for managing their own state here. -
getTriggers
-