From 50251cb20bdb7f0d68d1818a56f3394ca5ec4605 Mon Sep 17 00:00:00 2001 From: Aluxes <39981645+AshenAshes@users.noreply.github.com> Date: Thu, 23 May 2024 23:37:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E*=E6=8A=BD=E5=8D=A1=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=20*=E6=AD=A6=E5=99=A8=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/gacha.js | 9 +- apps/gacha/Gacha.js | 83 ++++++++---- apps/gacha/GachaData.js | 62 ++++++--- resources/gacha/gacha-detail.css | 4 +- resources/gacha/gacha-detail.html | 28 ++-- resources/gacha/gacha-detail.less | 14 +- resources/gacha/gacha-stat.css | 1 - resources/gacha/gacha-stat.html | 12 +- resources/gacha/gacha-stat.less | 3 +- resources/meta-sr/info/index.js | 204 ++++++++++++++++++++++++++++++ 10 files changed, 344 insertions(+), 76 deletions(-) create mode 100644 resources/meta-sr/info/index.js diff --git a/apps/gacha.js b/apps/gacha.js index af537d6b..218c513e 100644 --- a/apps/gacha.js +++ b/apps/gacha.js @@ -9,17 +9,16 @@ app.reg({ detail: { name: '抽卡记录', fn: Gacha.detail, - rule: /^#*喵喵(抽卡|抽奖|角色|武器|常驻|集录|up)+池?(记录|祈愿|分析)$/, - yzRule: /^#*(抽卡|抽奖|角色|武器|常驻|集录|up)+池?(记录|祈愿|分析)$/, + rule: /^#*(星铁)?喵喵(抽卡|抽奖|角色|武器|光锥|常驻|集录|up)+池?(记录|祈愿|分析)$/, + yzRule: /^#*(星铁)?(抽卡|抽奖|角色|武器|光锥|常驻|集录|up)+池?(记录|祈愿|分析)$/, yzCheck: () => Cfg.get('gachaStat', false) }, stat: { name: '抽卡统计', fn: Gacha.stat, - rule: /^#*喵喵(全部|抽卡|抽奖|角色|武器|常驻|集录|up|版本)+池?统计$/, - yzRule: /^#*(全部|抽卡|抽奖|角色|武器|常驻|集录|up|版本)+池?统计$/, + rule: /^#*(星铁)?喵喵(全部|抽卡|抽奖|角色|武器|光锥|常驻|集录|up|版本)+池?统计$/, + yzRule: /^#*(星铁)?(全部|抽卡|抽奖|角色|武器|光锥|常驻|集录|up|版本)+池?统计$/, yzCheck: () => Cfg.get('gachaStat', false) - } }) diff --git a/apps/gacha/Gacha.js b/apps/gacha/Gacha.js index 557dcf54..c295cead 100644 --- a/apps/gacha/Gacha.js +++ b/apps/gacha/Gacha.js @@ -6,23 +6,45 @@ import { Button, Character, Player } from '#miao.models' let Gacha = { async detail (e) { let msg = e.msg.replace(/#|抽卡|记录|祈愿|分析|池/g, '') - let type = 301 - switch (msg) { - case 'up': - case '抽卡': - case '角色': - case '抽奖': - type = 301 - break - case '常驻': - type = 200 - break - case '武器': - type = 302 - break - case '集录': - type = 500 - break + let game = /星铁/.test(msg) ? 'sr' : 'gs' + msg = msg.replace(/星铁/, '') + let type + if (e.isSr) { + type = 11 + switch (msg) { + case 'up': + case '抽卡': + case '角色': + case '抽奖': + type = 11 + break + case '常驻': + type = 1 + break + case '武器': + case '光锥': + type = 12 + break + } + } else { + type = 301 + switch (msg) { + case 'up': + case '抽卡': + case '角色': + case '抽奖': + type = 301 + break + case '常驻': + type = 200 + break + case '武器': + type = 302 + break + case '集录': + type = 500 + break + } } let uid = e.uid || await getTargetUid(e) let qq = e.user_id @@ -30,22 +52,29 @@ let Gacha = { return false } - let gacha = GachaData.analyse(e.user_id, uid, type) + let gacha = GachaData.analyse(e.user_id, uid, type, game) if (!gacha) { e.reply([`UID:${uid} 本地暂无抽卡信息,请通过【#抽卡帮助】获得绑定帮助...`, new Button(e).gacha()]) return true } + + if (type === 302 || type === 12) type = 'weapon' this.reply([await Common.render('gacha/gacha-detail', { save_id: uid, uid, gacha, - face: Gacha.getFace(uid) + face: Gacha.getFace(uid, game), + game, + type, + elem: e.isSr ? 'sr' : 'hydro' }, { e, scale: 1.4, retType: 'base64' }), new Button(e).gacha()]) }, async stat (e) { let msg = e.msg.replace(/#|统计|分析|池/g, '') + let game = /星铁/.test(msg) ? 'sr' : 'gs' + msg = msg.replace(/星铁/, '') let type = 'up' - if (/武器/.test(msg)) { + if (/武器|光锥/.test(msg)) { type = 'weapon' } else if (/角色/.test(msg)) { type = 'char' @@ -61,7 +90,7 @@ let Gacha = { if (!uid || !qq) { return false } - let gacha = GachaData.stat(e.user_id, uid, type) + let gacha = GachaData.stat(e.user_id, uid, type, game) if (!gacha) { e.reply([`UID:${uid} 本地暂无抽卡信息,请通过【#抽卡帮助】获得绑定帮助...`, new Button(e).gacha()]) return true @@ -70,14 +99,16 @@ let Gacha = { save_id: uid, uid, gacha, - face: Gacha.getFace(uid) + face: Gacha.getFace(uid, game), + game, + elem: e.isSr ? 'sr' : 'hydro' }, { e, scale: 1.4, retType: 'base64' }), new Button(e).gacha()]) }, - getFace (uid) { - let player = Player.create(uid) - - let faceChar = Character.get(player.face || 10000014) + getFace (uid, game) { + let player = Player.create(uid, game) + let defaultFaceChar = game === 'gs' ? 10000014 : 1005 + let faceChar = Character.get(player.face || defaultFaceChar, game) let imgs = faceChar?.imgs if (!imgs?.face) { imgs = Character.get(10000079).imgs diff --git a/apps/gacha/GachaData.js b/apps/gacha/GachaData.js index 75f62c84..3dadebfc 100644 --- a/apps/gacha/GachaData.js +++ b/apps/gacha/GachaData.js @@ -2,6 +2,7 @@ import lodash from 'lodash' import { Data } from '#miao' import { Character, Weapon } from '#miao.models' import { poolDetail, mixPoolDetail } from '../../resources/meta-gs/info/index.js' +import { poolDetailSr } from '../../resources/meta-sr/info/index.js' import moment from 'moment' let poolVersion = [] @@ -23,6 +24,24 @@ poolVersion.push({ end: new Date('2025-12-31 23:59:59') }) +let poolVersionSr = [] +lodash.forEach(poolDetailSr, (ds) => { + poolVersionSr.push({ + ...ds, + start: new Date(ds.from), + end: new Date(ds.to) + }) +}) +let lastSr = poolVersionSr[poolVersionSr.length - 1] +poolVersionSr.push({ + version: '新版本', + half: '?', + from: lastSr.to, + to: '2025-12-31 23:59:59', + start: lastSr.end, + end: new Date('2025-12-31 23:59:59') +}) + let mixPoolVersion = [] lodash.forEach(mixPoolDetail, (ds) => { mixPoolVersion.push({ @@ -44,18 +63,20 @@ mixPoolVersion.push({ let GachaData = { // 获取JSON数据 - readJSON (qq, uid, type) { + readJSON (qq, uid, type, game) { let logJson = [] // 获取本地数据 进行数据合并 - logJson = Data.readJSON(`/data/gachaJson/${qq}/${uid}/${type}.json`, 'root') + game === 'gs' + ? logJson = Data.readJSON(`/data/gachaJson/${qq}/${uid}/${type}.json`, 'root') + : logJson = Data.readJSON(`/data/srJson/${qq}/${uid}/${type}.json`, 'root') let itemMap = {} let nameMap = {} let items = [] let ids = {} lodash.forEach(logJson, (ds) => { if (!nameMap[ds.name]) { - if (ds.item_type === '武器') { - let weapon = Weapon.get(ds.name) + if (ds.item_type === '武器' || ds.item_type === '光锥') { + let weapon = Weapon.get(ds.name, game) if (weapon) { nameMap[ds.name] = weapon.id itemMap[weapon.id] = { @@ -75,7 +96,7 @@ let GachaData = { } } } else if (ds.item_type === '角色') { - let char = Character.get(ds.name) + let char = Character.get(ds.name, game) if (char) { nameMap[ds.name] = char.id itemMap[char.id] = { @@ -112,8 +133,8 @@ let GachaData = { }, // 卡池分析 - analyse (qq, uid, type) { - let logData = GachaData.readJSON(qq, uid, type) + analyse (qq, uid, type, game) { + let logData = GachaData.readJSON(qq, uid, type, game) let fiveLog = [] let fourLog = [] let fiveNum = 0 @@ -139,7 +160,7 @@ let GachaData = { let currVersion lodash.forEach(logData.items, (item) => { if (!currVersion || (item.time < currVersion.start)) { - currVersion = GachaData.getVersion(item.time, true, isMix) + currVersion = GachaData.getVersion(item.time, true, isMix, game) } allNum++ @@ -282,31 +303,32 @@ let GachaData = { }, // 卡池统计 - stat (qq, uid, type) { + stat (qq, uid, type, game) { let items = [] let itemMap = {} let hasVersion = true let isMix = false + let isSr = game === 'sr' let loadData = function (poolId) { - let gachaData = GachaData.readJSON(qq, uid, poolId) + let gachaData = GachaData.readJSON(qq, uid, poolId, game) items = items.concat(gachaData.items) lodash.extend(itemMap, gachaData.itemMap || {}) } if (['up', 'char', 'all'].includes(type)) { - loadData(301) + isSr ? loadData(11) : loadData(301) } if (['up', 'weapon', 'all'].includes(type)) { - loadData(302) + isSr ? loadData(12) : loadData(302) } if (['all', 'normal'].includes(type)) { hasVersion = false - loadData(200) + isSr ? loadData(1) : loadData(200) } if (['mix'].includes(type)) { isMix = true loadData(500) } - if (['all'].includes(type)) { + if (['all'].includes(type) && !isSr) { loadData(500) } @@ -396,7 +418,7 @@ let GachaData = { if (currVersion) { versionData.push(getCurr()) } - let v = GachaData.getVersion(ds.time, hasVersion, isMix) + let v = GachaData.getVersion(ds.time, hasVersion, isMix, game) if (!hasVersion) { v.version = type === 'all' ? '全部统计' : '常驻池' } @@ -436,7 +458,7 @@ let GachaData = { } }, - getVersion (time, hasVersion = true, isMix = false) { + getVersion (time, hasVersion = true, isMix = false, game) { if (isMix) { for (let ds of mixPoolVersion) { if (time > ds.start && time < ds.end) { @@ -444,12 +466,18 @@ let GachaData = { } } } - if (hasVersion) { + if (hasVersion && game === 'gs') { for (let ds of poolVersion) { if (time > ds.start && time < ds.end) { return ds } } + } else if (hasVersion && game === 'sr') { + for (let ds of poolVersionSr) { + if (time > ds.start && time < ds.end) { + return ds + } + } } return { version: hasVersion === false ? '全部' : '未知', diff --git a/resources/gacha/gacha-detail.css b/resources/gacha/gacha-detail.css index 727449d5..a77256fa 100644 --- a/resources/gacha/gacha-detail.css +++ b/resources/gacha/gacha-detail.css @@ -20,7 +20,7 @@ .gacha-list .gacha-item .date .dot { width: 23.75px; height: 43px; - background: url('./imgs/date-icon.webp') center -38px; + background: url('imgs/date-icon.webp') center -38px; background-size: 100% auto; } .gacha-list .gacha-item .date .dot.first { @@ -45,7 +45,6 @@ margin-top: 5px; } .gacha-list .gacha-item .name { - width: 90px; text-align: right; line-height: 38px; padding-right: 5px; @@ -140,4 +139,3 @@ .avatar-card .name { text-align: center; } -/*# sourceMappingURL=gacha-detail.css.map */ \ No newline at end of file diff --git a/resources/gacha/gacha-detail.html b/resources/gacha/gacha-detail.html index 9714d54c..9a03e60b 100644 --- a/resources/gacha/gacha-detail.html +++ b/resources/gacha/gacha-detail.html @@ -1,15 +1,16 @@ {{extend elemLayout}} - {{block 'css'}} - - - - + + + {{/block}} - +{{if game === 'gs'}} {{ set statMap = { allNum:'抽卡总数', fiveNum:'金卡数',wai:'歪 T.T',fourNum:'紫卡数', fiveAvg:'平均出金', upYs:'UP原石' } }} - +{{else}} +{{ set statMap = { allNum:'抽卡总数', fiveNum:'金卡数',wai:'歪 T.T',fourNum:'紫卡数', fiveAvg:'平均出金', upYs:'UP星琼' } }} +{{/if}} {{block 'main'}} +{{ set gameHash = game === 'gs' ? '#' : '*'}}