INNER CODE UNIT · JavaScript
serializeState
Sisyphe42/ReignsAgent · packages/core/src/index.js:179
export function serializeState(state) {
assertPlainRecord(state, "Runtime state");
return cloneJsonSafe(
{
schemaVersion: SNAPSHOT_SCHEMA_VERSION,
turn: state.turn ?? 0,
factions: state.factions ?? {},
variables: state.variables ?? {},
tags: state.tags ?? {},
cardWeights: state.cardWeights ?? {},
factionScales: state.factionScales ?? {},
dismissedCardIds: dismissedCardIdsFromState(state),
currentCardId: state.currentCardId ?? null,
gameOver: state.gameOver ?? null,
activeHooks: (state.activeHooks ?? []).map(serializeHookEntry)
},
"Runtime snapshot"