diff --git a/apps/gachalog.js b/apps/gachalog.js index 9e9c6cd..46ad671 100644 --- a/apps/gachalog.js +++ b/apps/gachalog.js @@ -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('未查询到抽卡记录,请先发送抽卡链接'); diff --git a/lib/gacha.js b/lib/gacha.js index b2242de..e474994 100644 --- a/lib/gacha.js +++ b/lib/gacha.js @@ -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, diff --git a/model/gacha.js b/model/gacha.js index b9f7532..68f135f 100644 --- a/model/gacha.js +++ b/model/gacha.js @@ -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; + } + } } /** diff --git a/resources/gachalog/index.html b/resources/gachalog/index.html index 1985109..f996fbe 100644 --- a/resources/gachalog/index.html +++ b/resources/gachalog/index.html @@ -40,9 +40,9 @@