Class Trace
java.lang.Object
net.demilich.metastone.game.logic.Trace
- All Implemented Interfaces:
Serializable
,Cloneable
Stores information about a game context that allows you to reproduce exactly what happened in the match.
Given the seed, starting conditions and index of each action in the available actions that a player chose, the game will reproduce.
- See Also:
-
to create a string you can save and later load.
to recreate this object from a dumped string.
to replay a context after loading it from a string. Provide
skipLastAction: true
as the argument if the last action throws an exception (useful for debugging). Providerecorder
is useful if you'd like to process each GameContext (useful for recording replays).- Serialized Form
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAction
(GameAction action) clone()
dump()
int
getId()
long
getSeed()
int
boolean
static Trace
replayContext
(boolean skipLastAction) replayContext
(boolean skipLastAction, @Nullable Consumer<GameContext> beforeRequestActionHandler) Creates a game context and replays it using data from this trace.void
restoreStartingStateTo
(GameContext context) setActions
(List<Integer> actions) void
setCatalogueVersion
(int catalogueVersion) setDeckCardIds
(List<DeckTrace> deckCardIds) setDeckFormatName
(String deckFormatName) setDeckFormatSets
(List<String> deckFormatSets) setHeroClasses
(List<String> heroClasses) setMulligans
(List<MulliganTrace> mulligans) setRawActions
(List<GameAction> rawActions) setSecondPlayerBonusCards
(List<String> secondPlayerBonusCards) void
setSeed
(long seed) void
setStartState
(GameState gameState) setTraceErrors
(boolean traceErrors) setVersion
(int version) io.vertx.core.json.JsonObject
toJson()
toString()
-
Constructor Details
-
Trace
public Trace()
-
-
Method Details
-
setSeed
public void setSeed(long seed) -
getSeed
public long getSeed() -
setCatalogueVersion
public void setCatalogueVersion(int catalogueVersion) -
getCatalogueVersion
public int getCatalogueVersion() -
getActions
-
addAction
-
replayContext
-
replayContext
-
replayContext
public GameContext replayContext(boolean skipLastAction, @Nullable @Nullable Consumer<GameContext> beforeRequestActionHandler) Creates a game context and replays it using data from this trace. AConsumer
can be optionally specified that receives the game context before every action taken by either player.- Parameters:
skipLastAction
-beforeRequestActionHandler
-- Returns:
-
restoreStartingStateTo
-
dump
-
load
-
getHeroClasses
-
setHeroClasses
-
getDeckCardIds
-
setDeckCardIds
-
getDeckFormatName
-
setDeckFormatName
-
getDeckFormatSets
-
setDeckFormatSets
-
getSecondPlayerBonusCards
-
setSecondPlayerBonusCards
-
getMulligans
-
setMulligans
-
setActions
-
getId
-
setId
-
isTraceErrors
public boolean isTraceErrors() -
setTraceErrors
-
getRawActions
-
setRawActions
-
getVersion
public int getVersion() -
setVersion
-
clone
-
toString
-
toJson
public io.vertx.core.json.JsonObject toJson()