1
This commit is contained in:
49
server-node/src/modules/runtime/runtimeTreasureTexts.ts
Normal file
49
server-node/src/modules/runtime/runtimeTreasureTexts.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { formatCurrency } from './runtimeEconomyPrimitives.js';
|
||||
|
||||
type TreasureRewardItem = {
|
||||
name: string;
|
||||
};
|
||||
|
||||
type TreasureRewardLike = {
|
||||
items: TreasureRewardItem[];
|
||||
hp: number;
|
||||
mana: number;
|
||||
currency: number;
|
||||
storyHint?: string;
|
||||
};
|
||||
|
||||
type TreasureEncounterLike = {
|
||||
npcName: string;
|
||||
};
|
||||
|
||||
type TreasureInteractionAction = 'inspect' | 'leave' | 'secure';
|
||||
|
||||
export function buildTreasureResultText(
|
||||
encounter: TreasureEncounterLike,
|
||||
action: TreasureInteractionAction,
|
||||
reward?: TreasureRewardLike,
|
||||
worldType?: string | null,
|
||||
) {
|
||||
if (action === 'leave') {
|
||||
return `你暂时没有触碰 ${encounter.npcName},只是把它的异常位置和痕迹牢牢记下。`;
|
||||
}
|
||||
|
||||
const itemText =
|
||||
reward?.items.length ? reward.items.map((item) => item.name).join('、') : '零散战利品';
|
||||
const restoreParts = [
|
||||
(reward?.hp ?? 0) > 0 ? `气血 +${reward?.hp ?? 0}` : null,
|
||||
(reward?.mana ?? 0) > 0 ? `灵力 +${reward?.mana ?? 0}` : null,
|
||||
].filter(Boolean);
|
||||
const restoreText =
|
||||
restoreParts.length > 0 ? `,并恢复 ${restoreParts.join('、')}` : '';
|
||||
const currencyText = reward
|
||||
? `,另得 ${formatCurrency(reward.currency, worldType ?? null)}`
|
||||
: '';
|
||||
const storyHint = reward?.storyHint ? ` ${reward.storyHint}` : '';
|
||||
|
||||
if (action === 'inspect') {
|
||||
return `你仔细检查了 ${encounter.npcName},顺着现场痕迹拆开机关与伪装,最终收回 ${itemText}${currencyText}${restoreText}。${storyHint}`;
|
||||
}
|
||||
|
||||
return `你迅速收下了 ${encounter.npcName} 中最关键的收获:${itemText}${currencyText}。${storyHint}`;
|
||||
}
|
||||
Reference in New Issue
Block a user