Files
noname-shuying/mengsan/runtime/reward.js
T
2026-09-28 20:58:29 +08:00

13 lines
565 B
JavaScript

import config from "../config.js";
import { nextRandom } from "../state.js";
export const getRandomRewardChoices = (run, poolId, count = 3) => {
const fallbackId = "shared.pool.battle.normal";
const pool = (config.rewardPools[poolId] || config.rewardPools[fallbackId]).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]];
}
return pool.slice(0, count).map(id => ({ id, ...config.rewards[id] }));
};