fixed # 更新刘备配置和奖励

This commit is contained in:
2026-09-30 15:43:07 +08:00
parent 82d80397b6
commit 0ccb14cecd
22 changed files with 681 additions and 30 deletions
+39
View File
@@ -0,0 +1,39 @@
import { canUpgradeCard } from "../cards/upgrades.js";
import { canAcquireRelic } from "../relics/definitions.js";
export function prepareRewardPackage(run, spec, randomChoices) {
if (!Number.isSafeInteger(spec.gold) || spec.gold < 0) {
throw new Error("奖励包金币无效");
}
const relicChoices = randomChoices(run, spec.relicPool, 3);
if (relicChoices.some(reward => !reward.relic)) {
throw new Error("奖励包候选必须是遗物");
}
return {
gold: spec.gold,
upgradeChoices: run.player.deck.filter(canUpgradeCard),
relicChoices,
};
}
export function applyRewardPackage(run, pack, selection, applyReward) {
if (!selection || typeof selection !== "object") {
throw new Error("奖励包选择无效");
}
const card = run.player.deck.find(card => card.id === selection.cardId);
const relic = pack.relicChoices.find(choice =>
choice.id === selection.relicId);
if (pack.upgradeChoices.length) {
if (!pack.upgradeChoices.some(card => card.id === selection.cardId) ||
!canUpgradeCard(card)) throw new Error("强化目标无效");
} else if (selection.cardId !== null) throw new Error("无可强化卡牌");
if (pack.relicChoices.length) {
if (!relic || !canAcquireRelic(run, relic.relic)) {
throw new Error("遗物选择无效");
}
} else if (selection.relicId !== null) throw new Error("无可选遗物");
run.player.gold += pack.gold;
run.statistics.goldEarned += pack.gold;
if (pack.upgradeChoices.length) card.upgrade = (card.upgrade || 0) + 1;
if (relic) applyReward(run, relic.id);
}
+1
View File
@@ -254,6 +254,7 @@ export const getNodeEncounter = (run, node, override = null) => {
requiredCharacter: encounter?.requiredCharacter || null,
openingDialogue: encounter?.openingDialogue || [],
fixedRewards: encounter?.fixedRewards || [],
rewardPackage: encounter?.rewardPackage || null,
skipRandomReward: encounter?.skipRandomReward === true,
victoryDialogue: encounter?.victoryDialogue || [],
battlePlan: encounter?.battlePlan || (enemy === RAIDER_TRIO_ENCOUNTER ?