/** Normalize world-settings list of quests granted to new (and existing) characters. */ export function normalizeInitialQuests (raw) { if (!Array.isArray(raw)) { return []; } const out = []; const seen = new Set(); for (const entry of raw) { const id = String(entry?.questId ?? entry ?? "").trim().slice(0, 80); if (!id || seen.has(id)) { continue; } seen.add(id); out.push(id); } return out; } export function initialQuestsEqual (a, b) { const left = normalizeInitialQuests(a); const right = normalizeInitialQuests(b); if (left.length !== right.length) { return false; } return left.every((id, index) => id === right[index]); } export function diffInitialQuests (prev, next) { const before = new Set(normalizeInitialQuests(prev)); const after = normalizeInitialQuests(next); const bullets = []; for (const id of after) { if (!before.has(id)) { bullets.push(`Initial quest +${id}`); } } for (const id of before) { if (!after.includes(id)) { bullets.push(`Initial quest −${id}`); } } return bullets; }