fix: gacha

This commit is contained in:
bietiaop 2024-07-09 17:20:11 +08:00
parent 550f7e0d99
commit 7455033ba6
4 changed files with 36 additions and 14 deletions

View file

@ -97,6 +97,7 @@ export class GachaLog extends ZZZPlugin {
return false;
}
await this.getPlayerInfo();
await this.reply('正在查询抽卡记录,首次下载资源可能耗费一些时间,请稍等');
const data = await anaylizeGachaLog(uid);
if (!data) {
await this.reply('未查询到抽卡记录,请先发送抽卡链接');

View file

@ -175,44 +175,50 @@ export async function anaylizeGachaLog(uid) {
const earliest = data[data.length - 1];
const latest = data[0];
const list = [];
let lastFive = `${data.length}`;
let lastFive = null;
let preIndex = 0;
let luck = 0;
data.forEach((item, i) => {
let i = 0;
for (const item of data) {
await item.get_assets();
let isUp = true;
if (item.rank_type === '4') {
if (NORMAL_LIST.includes(item.name)) {
isUp = false;
}
if (lastFive === `${data.length}`) {
lastFive = `${i + 1}`;
if (lastFive === null) {
lastFive = i;
}
if (list.length > 0) {
list[list.length - 1]['totalCount'] = i - preIndex;
}
list.push({
...item,
rank_type_label: RANK_MAP[item.rank_type],
isUp: isUp,
totalCount: '-',
});
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;
}
});
i++;
}
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);
if (fiveStars > 0)
avgFive = ((totalCount - lastFive) / fiveStars).toFixed(1);
if (upCount > 0) avgUp = ((totalCount - lastFive) / upCount).toFixed(1);
}
if (!lastFive && fiveStars === 0) {
lastFive = '-';
}
result.push({
name,

View file

@ -1,3 +1,5 @@
import { getSquareAvatar, getSquareBangboo } from '../lib/download.js';
/**
* @class
*/
@ -39,6 +41,8 @@ export class SingleGachaLog {
this.item_type = item_type;
this.rank_type = rank_type;
this.id = id;
this.square_icon = '';
}
/**
@ -52,6 +56,17 @@ export class SingleGachaLog {
this.gacha_type === this.gacha_type
);
}
async get_assets() {
if (this.item_type === '音擎') {
} else if (this.item_type === '邦布') {
const result = await getSquareBangboo(this.item_id);
this.square_icon = result;
} else {
const result = await getSquareAvatar(this.item_id);
this.square_icon = result;
}
}
}
/**

View file

@ -40,9 +40,9 @@
<div class="item rankS {{inv.isUp && 'up'}}">
<div class="rank rankS"></div>
<div class="image">
<img src="./images/role_square_avatar_1011.png" alt="">
<img src="{{inv.square_icon}}" alt="">
</div>
<div class="count">{{inv?.totalCount || '-'}}抽</div>
<div class="count">{{inv?.totalCount}}抽</div>
</div>
{{/each}}
</div>