mirror of
https://github.com/Shu-Ying/noname-shuying.git
synced 2026-10-09 10:29:58 +08:00
13 lines
565 B
JavaScript
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] }));
|
|
};
|