改动整体底层系统

This commit is contained in:
2026-09-29 00:29:00 +08:00
parent ced1b28cc2
commit 2e552cf17d
24 changed files with 809 additions and 53 deletions
+9 -1
View File
@@ -1,9 +1,17 @@
import config from "../config.js";
import { nextRandom } from "../state.js";
import { canAcquireCard } from "../content/card-definitions.js";
export const rewardCardName = reward => reward?.card?.name || ({ card_sha: "sha", card_tao: "tao" })[reward?.effectId] || null;
export const canAcquireReward = (run, reward) => {
const name = rewardCardName(reward);
return !name || canAcquireCard(run?.player?.character, name);
};
export const getRandomRewardChoices = (run, poolId, count = 3) => {
const fallbackId = "shared.pool.battle.normal";
const pool = (config.rewardPools[poolId] || config.rewardPools[fallbackId]).slice();
const pool = (config.rewardPools[poolId] || config.rewardPools[fallbackId])
.filter(id => canAcquireReward(run, config.rewards[id])).slice();
for (let index = pool.length - 1; index > 0; index--) {
const target = Math.floor(nextRandom(run) * (index + 1));
[pool[index], pool[target]] = [pool[target], pool[index]];