import { LETTER_MAX_BODY_CHARS, itemDefinition, itemDisplayName } from "../definitions/items.js"; import { formatGiftItemBullet, QUESTWARD_GIFT_AUTHOR, QUESTWARD_GIFT_ORG } from "./giftLetters.js"; export { QUESTWARD_GIFT_AUTHOR, QUESTWARD_GIFT_ORG }; /** * Bank letter when quest completion rewards land in the vault. * Signature is applied separately via author fields (John Questward / CEO). */ export function formatQuestBankRewardLetterBody ({ characterDisplayName, questTitle, items = [] }) { const name = String(characterDisplayName ?? "").trim() || "Adventurer"; const title = String(questTitle ?? "").trim() || "a quest"; const lines = (items ?? []).map((row) => { const def = row.itemId != null ? itemDefinition(row.itemId) : null; const displayName = row.displayName ?? (def ? itemDisplayName({ itemId: row.itemId, quantity: row.quantity }, def) : null) ?? def?.displayName ?? `Item ${row.itemId ?? "?"}`; return formatGiftItemBullet({ displayName, quantity: row.quantity }); }); const itemBlock = lines.length ? lines.join("\n") : "• (no items)"; return [ `Dear ${name},`, "", `Congratulations on your completion of the quest "${title}".`, "", "The following rewards have been added to your bank:", itemBlock ].join("\n").slice(0, LETTER_MAX_BODY_CHARS); }