mirror of
https://github.com/Shu-Ying/noname-shuying.git
synced 2026-10-23 16:20:02 +08:00
整合
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
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] }));
|
||||
};
|
||||
Reference in New Issue
Block a user