INNER CODE UNIT · JavaScript

restoreState

Sisyphe42/ReignsAgent · packages/core/src/index.js:200

export function restoreState(snapshot, options = {}) {
  assertPlainRecord(snapshot, "Runtime snapshot");

  if (snapshot.schemaVersion !== SNAPSHOT_SCHEMA_VERSION) {
    throw new CoreError(`Unsupported snapshot schemaVersion '${snapshot.schemaVersion}'`);
  }

  const activeHooks = restoreHookEntries(snapshot.activeHooks ?? [], options);

  return createInitialState({
    turn: snapshot.turn ?? 0,
    factions: snapshot.factions,
    variables: snapshot.variables ?? {},
    tags: snapshot.tags ?? {},
    activeHooks,
    cardWeights: snapshot.cardWeights ?? {},
    factionScales: snapshot.factionScales ?? {},
    dismissedCardIds: snapshot.dismissedCardIds ?? [],

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…