mirror of
https://github.com/shanmiteko/LotteryAutoScript.git
synced 2026-06-04 21:01:17 +08:00
pref: 对将要转发的动态洗牌乱序
防止被看出是抽奖号
This commit is contained in:
parent
53ae976caf
commit
fdee933ca4
@ -89,7 +89,7 @@ class Monitor extends Public {
|
||||
log.info('筛选动态', `筛选完毕(${len})`);
|
||||
|
||||
if (len) {
|
||||
for (const Lottery of allLottery) {
|
||||
for (const Lottery of Util.shuffle(allLottery)) {
|
||||
let status = 0;
|
||||
if (Lottery.isOfficialLottery) {
|
||||
let { ts } = await BiliAPI.getLotteryNotice(Lottery.dyid);
|
||||
|
||||
18
lib/Util.js
18
lib/Util.js
@ -115,6 +115,24 @@ const Util = {
|
||||
}
|
||||
return RandomOne
|
||||
},
|
||||
/**
|
||||
* Fisher–Yates shuffle洗牌
|
||||
* @template T
|
||||
* @param {Array<T>} array
|
||||
* @return {Array<T>}
|
||||
*/
|
||||
shuffle(array) {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
}
|
||||
return array;
|
||||
},
|
||||
/**
|
||||
* 是否有指定环境变量
|
||||
* @param {string} env_name
|
||||
* @returns
|
||||
*/
|
||||
hasEnv(env_name) {
|
||||
return process.env[env_name] ? true : false;
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user