INNER CODE UNIT · JavaScript

normalizeEffects

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

function normalizeEffects(cardId, choiceId, effects) {
  assertPlainRecord(effects, `Choice '${choiceId}' on card '${cardId}' effects`);

  for (const key of Object.keys(effects)) {
    if (!EFFECT_KEYS.has(key)) {
      throw new CoreError(`Choice '${choiceId}' on card '${cardId}' has unknown effect '${key}'`);
    }
  }

  if (effects.tags !== undefined) {
    assertPlainRecord(effects.tags, `Choice '${choiceId}' on card '${cardId}' tag effects`);
  }

  if (effects.variables !== undefined) {
    assertPlainRecord(effects.variables, `Choice '${choiceId}' on card '${cardId}' variable effects`);
  }

  if (effects.factions !== undefined) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…