BlueGit

timfa questward

Files

questward / shared / bounty / pricing.js

pricing.js

pricing.js 741 B Download Raw
1import { formatQuantity } from "../definitions/items.js";
2
3/** @param {number} copper */
4export function formatBountyCopper (copper)
5{
6 const amount = Math.max(0, Math.floor(Number(copper) || 0));
7 return formatQuantity(amount);
8}
9
10/**
11 * @param {{ killerName: string, victimName: string, amountCopper: number }} opts
12 */
13export function bountyPayoutLetterBody ({ killerName, victimName, amountCopper })
14{
15 const killer = String(killerName ?? "Adventurer").trim() || "Adventurer";
16 const victim = String(victimName ?? "someone").trim() || "someone";
17 const amount = formatBountyCopper(amountCopper);
18 return [
19 `Dear ${killer},`,
20 "",
21 `For defeating ${victim}, a bounty of ${amount} has been paid into your bank vault.`
22 ].join("\n");
23}