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);
Groups a flat table of stage rows into
QuestDefinitions aQuestLogcandefine- the same relational shapecore.parseCSValready 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.tsobject 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.requiresis 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'srequiresis ignored.