mwg API
    Preparing search index...

    Function questsFromRows

    • Groups a flat table of stage rows into QuestDefinitions a QuestLog can define - the same relational shape core.parseCSV already models for a flat table (actors.AffixTable, actors.buildEntities): a content designer edits two spreadsheet columns (which quest, which stage) instead of a hand-written .ts object literal nesting every quest's stage array. Row order is preserved as stage order within a quest, and first-seen order across the table as quest order.

      requires is only read off a quest's first row - a quest cannot require something different depending on which of its own stage rows a spreadsheet author happened to fill it in on, so only the first counts and a later row's requires is ignored.

      Parameters

      Returns QuestDefinition[]

      import { parseCSV } from '@datamoc/mw_games/core';
      import { questsFromRows, QuestLog, type QuestStageRow } from '@datamoc/mw_games/rpg';

      const csv = `questId,counterVariable,counterTarget,description
      rats,ratsKilled,5,Kill 5 rats
      rats,,,Report back to the innkeeper`;

      const rows = parseCSV<QuestStageRow>(csv, { columns: { counterTarget: 'number' } });
      const quests = questsFromRows(rows);

      const log = new QuestLog();
      for (const quest of quests) log.define(quest);