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. ProvideskipLastAction: trueas the argument if the last action throws an exception (useful for debugging). Providerecorderis useful if you'd like to process each GameContext (useful for recording replays).- Serialized Form
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAction(GameAction action) clone()dump()intgetId()longgetSeed()intbooleanstatic TracereplayContext(boolean skipLastAction) replayContext(boolean skipLastAction, @Nullable Consumer<GameContext> beforeRequestActionHandler) Creates a game context and replays it using data from this trace.voidrestoreStartingStateTo(GameContext context) setActions(List<Integer> actions) voidsetCatalogueVersion(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) voidsetSeed(long seed) voidsetStartState(GameState gameState) setTraceErrors(boolean traceErrors) setVersion(int version) io.vertx.core.json.JsonObjecttoJson()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. AConsumercan 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()