| 1 | /** Shared helpers for system-authored letters (CE, bank, bounty, …). */ |
| 2 | |
| 3 | import { LETTER_MAX_BODY_CHARS } from "../definitions/items.js"; |
| 4 | |
| 5 | export const CENTRAL_EXCHANGE_ORG = "Central Exchange"; |
| 6 | export const BANK_LETTER_AUTHOR = "The Bank"; |
| 7 | export const BOUNTY_OFFICE_AUTHOR = "Bounty Office"; |
| 8 | export const CHURCH_LETTER_AUTHOR = "The Church"; |
| 9 | export { |
| 10 | QUESTWARD_GIFT_AUTHOR, |
| 11 | QUESTWARD_GIFT_ORG, |
| 12 | formatGiftLetterBody, |
| 13 | formatGiftItemBullet |
| 14 | } from "./giftLetters.js"; |
| 15 | export { giftItemOrigin } from "./giftOrigin.js"; |
| 16 | |
| 17 | export const CHURCH_OFFLINE_RESURRECTION_BODY = [ |
| 18 | "The priesthood found your lifeless body on the ground and have resurrected you at the church altar while you were offline." |
| 19 | ].join("\n"); |
| 20 | |
| 21 | export const COMBAT_LOGOUT_COWARDICE_BODY = [ |
| 22 | "Your cowardice in honourable combat has not gone unnoticed. A temporary skull mark of shame has been placed on your character.", |
| 23 | "In the future, please do not log out while in combat with another player." |
| 24 | ].join("\n"); |
| 25 | |
| 26 | export function formatChurchOfflineResurrectionBody () |
| 27 | { |
| 28 | return CHURCH_OFFLINE_RESURRECTION_BODY.slice(0, LETTER_MAX_BODY_CHARS); |
| 29 | } |
| 30 | |
| 31 | export function formatCombatLogoutCowardiceBody () |
| 32 | { |
| 33 | return COMBAT_LOGOUT_COWARDICE_BODY.slice(0, LETTER_MAX_BODY_CHARS); |
| 34 | } |
| 35 | |
| 36 | export function isCentralExchangeLetter (instance) |
| 37 | { |
| 38 | if (instance?.kind !== "letter") |
| 39 | { return false; } |
| 40 | if (instance.centralExchange === true) |
| 41 | { return true; } |
| 42 | return instance.authorOrganization === CENTRAL_EXCHANGE_ORG; |
| 43 | } |
| 44 | |
| 45 | export function isBankRestNoticeLetter (instance) |
| 46 | { |
| 47 | return instance?.kind === "letter" && instance.bankRestNotice === true; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Format the UI "Signed:" block. Optional organization is a second line under the name. |
| 52 | * @param {{ authorDisplayName?: string, authorOrganization?: string|null }} instance |
| 53 | * @param {string} [fallbackName] |
| 54 | */ |
| 55 | export function formatLetterSignature (instance, fallbackName = "Unknown") |
| 56 | { |
| 57 | const name = String(instance?.authorDisplayName ?? "").trim() || fallbackName; |
| 58 | const org = String(instance?.authorOrganization ?? "").trim(); |
| 59 | return org ? `Signed:\n${name}\n${org}` : `Signed:\n${name}`; |
| 60 | } |