mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
feat: gacha
This commit is contained in:
parent
e28fbd8472
commit
af3b551a6a
33 changed files with 579 additions and 15 deletions
101
lib/gacha.js
101
lib/gacha.js
|
|
@ -127,3 +127,104 @@ export async function updateGachaLog(authKey, uid) {
|
|||
saveGachaLog(uid, previousLog);
|
||||
return previousLog;
|
||||
}
|
||||
|
||||
const RANK_MAP = {
|
||||
4: 'S',
|
||||
3: 'A',
|
||||
2: 'B',
|
||||
};
|
||||
const HOMO_TAG = ['非到极致', '运气不好', '平稳保底', '小欧一把', '欧狗在此'];
|
||||
const NORMAL_LIST = [
|
||||
'「11号」',
|
||||
'猫又',
|
||||
'莱卡恩',
|
||||
'丽娜',
|
||||
'格莉丝',
|
||||
'珂蕾妲',
|
||||
'拘缚者',
|
||||
'燃狱齿轮',
|
||||
'嵌合编译器',
|
||||
'钢铁肉垫',
|
||||
'硫磺石',
|
||||
'啜泣摇篮',
|
||||
];
|
||||
|
||||
export async function anaylizeGachaLog(uid) {
|
||||
const savedData = getGachaLog(uid);
|
||||
if (!savedData) {
|
||||
return null;
|
||||
}
|
||||
const result = [];
|
||||
for (const name in savedData) {
|
||||
const data = savedData[name].map(
|
||||
item =>
|
||||
new SingleGachaLog(
|
||||
item.uid,
|
||||
item.gacha_id,
|
||||
item.gacha_type,
|
||||
item.item_id,
|
||||
item.count,
|
||||
item.time,
|
||||
item.name,
|
||||
item.lang,
|
||||
item.item_type,
|
||||
item.rank_type,
|
||||
item.id
|
||||
)
|
||||
);
|
||||
const earliest = data[data.length - 1];
|
||||
const latest = data[0];
|
||||
const list = [];
|
||||
let lastFive = `${data.length}`;
|
||||
let preIndex = 0;
|
||||
let luck = 0;
|
||||
data.forEach((item, i) => {
|
||||
let isUp = true;
|
||||
if (item.rank_type === '4') {
|
||||
if (NORMAL_LIST.includes(item.name)) {
|
||||
isUp = false;
|
||||
}
|
||||
if (lastFive === `${data.length}`) {
|
||||
lastFive = `${i + 1}`;
|
||||
}
|
||||
list.push({
|
||||
...item,
|
||||
rank_type_label: RANK_MAP[item.rank_type],
|
||||
isUp: isUp,
|
||||
});
|
||||
if (list.length > 0) {
|
||||
list[list.length - 1]['totalCount'] = i - preIndex;
|
||||
}
|
||||
preIndex = i;
|
||||
}
|
||||
if (i === data.length - 1 && list.length > 0) {
|
||||
list[list.length - 1]['totalCount'] = i - preIndex;
|
||||
}
|
||||
});
|
||||
const upCount = list.length;
|
||||
const totalCount = data.length;
|
||||
const fiveStars = list.length;
|
||||
logger.mark('fiveStars', fiveStars);
|
||||
logger.mark('totalCount', totalCount);
|
||||
let timeRange = '还没有抽卡';
|
||||
let avgFive = '-';
|
||||
let avgUp = '-';
|
||||
if (data.length > 0) {
|
||||
timeRange = `${latest.time} ~ ${earliest.time}`;
|
||||
if (fiveStars > 0) avgFive = (totalCount / fiveStars).toFixed(1);
|
||||
if (upCount > 0) avgUp = (totalCount / upCount).toFixed(1);
|
||||
}
|
||||
result.push({
|
||||
name,
|
||||
timeRange,
|
||||
list,
|
||||
lastFive,
|
||||
fiveStars,
|
||||
upCount,
|
||||
totalCount,
|
||||
avgFive,
|
||||
avgUp,
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue