/** Shared helpers for system-authored letters (CE, bank, bounty, …). */ import { LETTER_MAX_BODY_CHARS } from "../definitions/items.js"; export const CENTRAL_EXCHANGE_ORG = "Central Exchange"; export const BANK_LETTER_AUTHOR = "The Bank"; export const BOUNTY_OFFICE_AUTHOR = "Bounty Office"; export const CHURCH_LETTER_AUTHOR = "The Church"; export { QUESTWARD_GIFT_AUTHOR, QUESTWARD_GIFT_ORG, formatGiftLetterBody, formatGiftItemBullet } from "./giftLetters.js"; export { giftItemOrigin } from "./giftOrigin.js"; export const CHURCH_OFFLINE_RESURRECTION_BODY = [ "The priesthood found your lifeless body on the ground and have resurrected you at the church altar while you were offline." ].join("\n"); export const COMBAT_LOGOUT_COWARDICE_BODY = [ "Your cowardice in honourable combat has not gone unnoticed. A temporary skull mark of shame has been placed on your character.", "In the future, please do not log out while in combat with another player." ].join("\n"); export function formatChurchOfflineResurrectionBody () { return CHURCH_OFFLINE_RESURRECTION_BODY.slice(0, LETTER_MAX_BODY_CHARS); } export function formatCombatLogoutCowardiceBody () { return COMBAT_LOGOUT_COWARDICE_BODY.slice(0, LETTER_MAX_BODY_CHARS); } export function isCentralExchangeLetter (instance) { if (instance?.kind !== "letter") { return false; } if (instance.centralExchange === true) { return true; } return instance.authorOrganization === CENTRAL_EXCHANGE_ORG; } export function isBankRestNoticeLetter (instance) { return instance?.kind === "letter" && instance.bankRestNotice === true; } /** * Format the UI "Signed:" block. Optional organization is a second line under the name. * @param {{ authorDisplayName?: string, authorOrganization?: string|null }} instance * @param {string} [fallbackName] */ export function formatLetterSignature (instance, fallbackName = "Unknown") { const name = String(instance?.authorDisplayName ?? "").trim() || fallbackName; const org = String(instance?.authorOrganization ?? "").trim(); return org ? `Signed:\n${name}\n${org}` : `Signed:\n${name}`; }