INNER CODE UNIT · JavaScript

applyChoice

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

function applyChoice(choice, state, recordEvent) {
  const effects = choice.effects ?? {};

  if (effects.tags) {
    for (const [tag, value] of Object.entries(effects.tags)) {
      if (value === false || value === null || value === undefined) {
        delete state.tags[tag];
      } else {
        state.tags[tag] = value;
      }
    }
  }

  if (effects.variables) {
    for (const [variable, value] of Object.entries(effects.variables)) {
      if (value === null || value === undefined) {
        delete state.variables[variable];
      } else {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…