2022-04-04 21:36:44 +00:00
|
|
|
/*
|
|
|
|
* 胡桃数据库的统计
|
|
|
|
*
|
|
|
|
* */
|
2022-07-23 20:32:10 +00:00
|
|
|
import lodash from 'lodash'
|
2022-10-08 09:37:22 +00:00
|
|
|
import { Cfg, Common, App, Data } from '../components/index.js'
|
2022-09-20 11:50:27 +00:00
|
|
|
import { Abyss, AvatarList, Character, MysApi } from '../models/index.js'
|
2022-11-23 20:26:07 +00:00
|
|
|
import HutaoApi from './wiki/HutaoApi.js'
|
2022-07-23 20:32:10 +00:00
|
|
|
|
2022-09-16 20:37:09 +00:00
|
|
|
let app = App.init({
|
|
|
|
id: 'stat',
|
2022-09-16 22:01:31 +00:00
|
|
|
name: '深渊统计'
|
2022-09-16 20:37:09 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
app.reg('cons-stat', consStat, {
|
|
|
|
rule: /^#(喵喵)?角色(持有|持有率|命座|命之座|.命)(分布|统计|持有|持有率)?$/,
|
|
|
|
desc: '【#统计】 #角色持有率 #角色5命统计'
|
|
|
|
})
|
|
|
|
app.reg('abyss-pct', abyssPct, {
|
|
|
|
rule: /^#(喵喵)?深渊(第?.{1,2}层)?(角色)?(出场|使用)(率|统计)*$/,
|
|
|
|
desc: '【#统计】 #深渊出场率 #深渊12层出场率'
|
|
|
|
})
|
|
|
|
app.reg('abyss-team', abyssTeam, {
|
|
|
|
rule: /#深渊(组队|配队)/,
|
|
|
|
describe: '【#角色】 #深渊组队'
|
|
|
|
})
|
|
|
|
app.reg('upload-data', uploadData, {
|
|
|
|
rule: /^#*(喵喵|上传|本期)*(深渊|深境|深境螺旋)[ |0-9]*(数据)?$/,
|
|
|
|
desc: '上传深渊'
|
|
|
|
})
|
|
|
|
export default app
|
|
|
|
|
|
|
|
async function consStat (e) {
|
2022-07-23 20:32:10 +00:00
|
|
|
let consData = await HutaoApi.getCons()
|
2022-08-06 22:36:05 +00:00
|
|
|
let overview = await HutaoApi.getOverview()
|
2022-06-21 22:07:12 +00:00
|
|
|
|
2022-04-04 21:36:44 +00:00
|
|
|
if (!consData) {
|
2022-07-23 20:32:10 +00:00
|
|
|
e.reply('角色持有数据获取失败,请稍后重试~')
|
|
|
|
return true
|
2022-04-04 21:36:44 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let msg = e.msg
|
2022-04-04 21:36:44 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let mode = /持有/.test(msg) ? 'char' : 'cons'
|
2022-04-04 21:36:44 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let conNum = -1
|
|
|
|
if (mode === 'cons') {
|
2022-04-04 21:36:44 +00:00
|
|
|
lodash.forEach([/0|零/, /1|一/, /2|二/, /3|三/, /4|四/, /5|五/, /6|六|满/], (reg, idx) => {
|
|
|
|
if (reg.test(msg)) {
|
2022-07-23 20:32:10 +00:00
|
|
|
conNum = idx
|
|
|
|
return false
|
2022-04-04 21:36:44 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!consData && !consData.data) {
|
2022-07-23 20:32:10 +00:00
|
|
|
return true
|
2022-04-04 21:36:44 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let data = consData.data
|
2022-06-21 22:07:12 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let Lumine = lodash.filter(data, (ds) => ds.avatar === 10000007)[0] || {}
|
|
|
|
let Aether = lodash.filter(data, (ds) => ds.avatar === 10000005)[0] || {}
|
2022-06-21 22:07:12 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
Lumine.holdingRate = (1 - Aether.holdingRate) || Lumine.holdingRate
|
2022-06-21 22:07:12 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let ret = []
|
2022-04-04 21:36:44 +00:00
|
|
|
|
2022-06-21 22:07:12 +00:00
|
|
|
lodash.forEach(data, (ds) => {
|
2022-07-23 20:32:10 +00:00
|
|
|
let char = Character.get(ds.avatar)
|
2022-04-04 21:36:44 +00:00
|
|
|
|
|
|
|
let data = {
|
|
|
|
name: char.name || ds.avatar,
|
2022-09-26 18:38:09 +00:00
|
|
|
abbr: char.abbr,
|
2022-04-04 21:36:44 +00:00
|
|
|
star: char.star || 3,
|
2022-09-03 21:08:57 +00:00
|
|
|
side: char.side,
|
2022-04-04 21:36:44 +00:00
|
|
|
hold: ds.holdingRate
|
2022-07-23 20:32:10 +00:00
|
|
|
}
|
2022-04-04 21:36:44 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
if (mode === 'char') {
|
2022-04-04 21:36:44 +00:00
|
|
|
data.cons = lodash.map(ds.rate, (c) => {
|
2022-07-23 20:32:10 +00:00
|
|
|
c.value = c.value * ds.holdingRate
|
|
|
|
return c
|
|
|
|
})
|
2022-04-04 21:36:44 +00:00
|
|
|
} else {
|
|
|
|
data.cons = ds.rate
|
|
|
|
}
|
2022-06-06 20:59:47 +00:00
|
|
|
data.cons = lodash.sortBy(data.cons, ['id'])
|
2022-04-04 21:36:44 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
ret.push(data)
|
|
|
|
})
|
2022-04-04 21:36:44 +00:00
|
|
|
|
|
|
|
if (conNum > -1) {
|
2022-07-23 20:32:10 +00:00
|
|
|
ret = lodash.sortBy(ret, [`cons[${conNum}].value`])
|
|
|
|
ret.reverse()
|
2022-04-04 21:36:44 +00:00
|
|
|
} else {
|
2022-07-23 20:32:10 +00:00
|
|
|
ret = lodash.sortBy(ret, ['hold'])
|
2022-04-04 21:36:44 +00:00
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
// 渲染图像
|
|
|
|
return await Common.render('stat/character', {
|
2022-04-04 21:36:44 +00:00
|
|
|
chars: ret,
|
2022-07-23 20:32:10 +00:00
|
|
|
mode,
|
2022-04-04 21:36:44 +00:00
|
|
|
conNum,
|
2022-08-06 22:36:05 +00:00
|
|
|
totalCount: overview?.data?.totalPlayerCount || 0,
|
2022-04-04 21:36:44 +00:00
|
|
|
lastUpdate: consData.lastUpdate,
|
|
|
|
pct: function (num) {
|
2022-07-23 20:32:10 +00:00
|
|
|
return (num * 100).toFixed(2)
|
|
|
|
}
|
2022-08-24 01:07:06 +00:00
|
|
|
}, { e, scale: 1.5 })
|
2022-04-04 21:36:44 +00:00
|
|
|
}
|
|
|
|
|
2022-09-16 20:37:09 +00:00
|
|
|
async function abyssPct (e) {
|
2022-07-23 20:32:10 +00:00
|
|
|
let mode = /使用/.test(e.msg) ? 'use' : 'pct'
|
|
|
|
let modeName
|
|
|
|
let abyssData
|
|
|
|
let modeMulti = 1
|
2022-07-08 21:49:29 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
if (mode === 'use') {
|
|
|
|
modeName = '使用率'
|
|
|
|
abyssData = await HutaoApi.getAbyssUse()
|
2022-07-08 21:49:29 +00:00
|
|
|
} else {
|
2022-07-23 20:32:10 +00:00
|
|
|
modeName = '出场率'
|
|
|
|
abyssData = await HutaoApi.getAbyssPct()
|
|
|
|
modeMulti = 8
|
2022-07-08 21:49:29 +00:00
|
|
|
}
|
2022-08-06 22:36:05 +00:00
|
|
|
let overview = await HutaoApi.getOverview()
|
2022-07-08 21:49:29 +00:00
|
|
|
|
2022-04-04 21:36:44 +00:00
|
|
|
if (!abyssData) {
|
2022-07-23 20:32:10 +00:00
|
|
|
e.reply(`深渊${modeName}数据获取失败,请稍后重试~`)
|
|
|
|
return true
|
2022-04-04 21:36:44 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let ret = []
|
|
|
|
let chooseFloor = -1
|
|
|
|
let msg = e.msg
|
2022-04-04 21:36:44 +00:00
|
|
|
|
|
|
|
const floorName = {
|
2022-07-23 20:32:10 +00:00
|
|
|
12: '十二层',
|
|
|
|
11: '十一层',
|
|
|
|
10: '十层',
|
|
|
|
9: '九层'
|
|
|
|
}
|
2022-04-04 21:36:44 +00:00
|
|
|
|
|
|
|
// 匹配深渊楼层信息
|
|
|
|
lodash.forEach(floorName, (cn, num) => {
|
2022-07-23 20:32:10 +00:00
|
|
|
let reg = new RegExp(`${cn}|${num}`)
|
2022-04-04 21:36:44 +00:00
|
|
|
if (reg.test(msg)) {
|
2022-07-23 20:32:10 +00:00
|
|
|
chooseFloor = num
|
|
|
|
return false
|
2022-04-04 21:36:44 +00:00
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
})
|
2022-04-04 21:36:44 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let data = abyssData.data
|
|
|
|
data = lodash.sortBy(data, 'floor')
|
|
|
|
data = data.reverse()
|
2022-06-29 20:40:06 +00:00
|
|
|
|
|
|
|
lodash.forEach(data, (floorData) => {
|
2022-07-23 20:32:10 +00:00
|
|
|
let avatars = []
|
2022-04-04 21:36:44 +00:00
|
|
|
lodash.forEach(floorData.avatarUsage, (ds) => {
|
2022-07-23 20:32:10 +00:00
|
|
|
let char = Character.get(ds.id)
|
2022-04-04 21:36:44 +00:00
|
|
|
if (char) {
|
|
|
|
avatars.push({
|
|
|
|
name: char.name,
|
2022-06-06 20:59:47 +00:00
|
|
|
star: char.star,
|
2022-09-03 21:08:57 +00:00
|
|
|
value: ds.value * modeMulti,
|
|
|
|
face: char.face
|
2022-04-04 21:36:44 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
2022-07-23 20:32:10 +00:00
|
|
|
avatars = lodash.sortBy(avatars, 'value', ['asc'])
|
|
|
|
avatars.reverse()
|
2022-04-04 21:36:44 +00:00
|
|
|
if (chooseFloor === -1) {
|
2022-07-23 20:32:10 +00:00
|
|
|
avatars = avatars.slice(0, 14)
|
2022-04-04 21:36:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret.push({
|
|
|
|
floor: floorData.floor,
|
|
|
|
avatars
|
2022-07-23 20:32:10 +00:00
|
|
|
})
|
2022-04-04 21:36:44 +00:00
|
|
|
})
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
return await Common.render('stat/abyss-pct', {
|
2022-04-04 21:36:44 +00:00
|
|
|
abyss: ret,
|
|
|
|
floorName,
|
|
|
|
chooseFloor,
|
2022-07-08 21:49:29 +00:00
|
|
|
mode,
|
|
|
|
modeName,
|
2022-08-06 22:36:05 +00:00
|
|
|
totalCount: overview?.data?.collectedPlayerCount || 0,
|
2022-07-08 21:49:29 +00:00
|
|
|
lastUpdate: abyssData.lastUpdate
|
2022-08-24 01:07:06 +00:00
|
|
|
}, { e, scale: 1.5 })
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
|
2022-09-16 20:37:09 +00:00
|
|
|
async function abyssTeam (e) {
|
2022-09-20 11:50:27 +00:00
|
|
|
let mys = await MysApi.init(e, 'cookie')
|
2022-09-21 03:06:33 +00:00
|
|
|
if (!mys || !mys.uid || !mys.isSelfCookie) {
|
2022-07-23 20:32:10 +00:00
|
|
|
return true
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let abyssData = await HutaoApi.getAbyssTeam()
|
2022-05-04 20:53:20 +00:00
|
|
|
if (!abyssData || !abyssData.data) {
|
2022-07-23 20:32:10 +00:00
|
|
|
e.reply('深渊组队数据获取失败,请稍后重试~')
|
|
|
|
return true
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
abyssData = abyssData.data
|
2022-09-20 19:15:22 +00:00
|
|
|
let avatars
|
2022-09-17 09:48:24 +00:00
|
|
|
try {
|
2022-09-20 19:15:22 +00:00
|
|
|
avatars = await AvatarList.getAll(e, mys)
|
|
|
|
// resDetail = await mys.getCharacter()
|
|
|
|
if (!avatars) {
|
2022-09-17 09:48:24 +00:00
|
|
|
e.reply('角色信息获取失败')
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
} catch (err) {
|
|
|
|
// console.log(err);
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
2022-09-20 19:15:22 +00:00
|
|
|
let avatarData = await avatars.getTalentData()
|
2022-07-23 20:32:10 +00:00
|
|
|
let avatarRet = {}
|
|
|
|
let data = {}
|
|
|
|
let noAvatar = {}
|
2022-09-17 09:48:24 +00:00
|
|
|
lodash.forEach(avatarData, (avatar) => {
|
|
|
|
let t = avatar.talent
|
|
|
|
avatarRet[avatar.id] = Math.min(avatar.level, avatar.weapon?.level || 1) * 100 + Math.max(t.a?.original, t.e?.original, t.q?.original) * 1000
|
2022-07-23 20:32:10 +00:00
|
|
|
})
|
2022-05-04 20:53:20 +00:00
|
|
|
|
|
|
|
let getTeamCfg = (str) => {
|
2022-07-23 20:32:10 +00:00
|
|
|
let teams = str.split(',')
|
|
|
|
teams.sort()
|
|
|
|
let teamMark = 0
|
2022-05-04 20:53:20 +00:00
|
|
|
lodash.forEach(teams, (a) => {
|
|
|
|
if (!avatarRet[a]) {
|
2022-07-23 20:32:10 +00:00
|
|
|
teamMark = -1
|
|
|
|
noAvatar[a] = true
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
if (teamMark !== -1) {
|
2022-07-23 20:32:10 +00:00
|
|
|
teamMark += avatarRet[a] * 1
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
if (teamMark === -1) {
|
2022-07-23 20:32:10 +00:00
|
|
|
teamMark = 1
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
return {
|
2022-07-23 20:32:10 +00:00
|
|
|
key: teams.join(','),
|
2022-05-04 20:53:20 +00:00
|
|
|
mark: teamMark
|
2022-07-23 20:32:10 +00:00
|
|
|
}
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let hasSame = function (team1, team2) {
|
|
|
|
for (let idx = 0; idx < team1.length; idx++) {
|
|
|
|
if (team2.includes(team1[idx])) {
|
2022-07-23 20:32:10 +00:00
|
|
|
return true
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
return false
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lodash.forEach(abyssData, (ds) => {
|
2022-10-22 19:45:28 +00:00
|
|
|
let floor = ds.floor
|
2022-05-04 20:53:20 +00:00
|
|
|
if (!data[floor]) {
|
|
|
|
data[floor] = {
|
|
|
|
up: {},
|
|
|
|
down: {},
|
|
|
|
teams: []
|
2022-07-23 20:32:10 +00:00
|
|
|
}
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
2022-10-22 19:45:28 +00:00
|
|
|
lodash.forEach(['up', 'down'], (halfKey) => {
|
|
|
|
lodash.forEach(ds[halfKey], (ds) => {
|
|
|
|
let teamCfg = getTeamCfg(ds.item)
|
2022-05-04 20:53:20 +00:00
|
|
|
if (teamCfg) {
|
|
|
|
if (!data[floor][halfKey][teamCfg.key]) {
|
|
|
|
data[floor][halfKey][teamCfg.key] = {
|
|
|
|
count: 0,
|
|
|
|
mark: 0,
|
|
|
|
hasTeam: teamCfg.mark > 1
|
2022-07-23 20:32:10 +00:00
|
|
|
}
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
2022-10-22 19:45:28 +00:00
|
|
|
data[floor][halfKey][teamCfg.key].count += ds.rate
|
|
|
|
data[floor][halfKey][teamCfg.key].mark += ds.rate * teamCfg.mark
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
})
|
2022-07-23 20:32:10 +00:00
|
|
|
})
|
2022-05-04 20:53:20 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let temp = []
|
2022-05-04 20:53:20 +00:00
|
|
|
lodash.forEach(['up', 'down'], (halfKey) => {
|
|
|
|
lodash.forEach(data[floor][halfKey], (ds, team) => {
|
|
|
|
temp.push({
|
|
|
|
team,
|
2022-07-23 20:32:10 +00:00
|
|
|
teamArr: team.split(','),
|
2022-05-04 20:53:20 +00:00
|
|
|
half: halfKey,
|
|
|
|
count: ds.count,
|
|
|
|
mark: ds.mark,
|
|
|
|
mark2: 1,
|
|
|
|
hasTeam: ds.hasTeam
|
|
|
|
})
|
|
|
|
})
|
2022-07-23 20:32:10 +00:00
|
|
|
temp = lodash.sortBy(temp, 'mark')
|
|
|
|
data[floor].teams = temp.reverse()
|
|
|
|
})
|
|
|
|
})
|
2022-05-04 20:53:20 +00:00
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let ret = {}
|
2022-05-04 20:53:20 +00:00
|
|
|
|
|
|
|
lodash.forEach(data, (floorData, floor) => {
|
|
|
|
ret[floor] = {}
|
2022-07-23 20:32:10 +00:00
|
|
|
let ds = ret[floor]
|
2022-05-04 20:53:20 +00:00
|
|
|
lodash.forEach(floorData.teams, (t1) => {
|
|
|
|
if (t1.mark2 <= 0) {
|
2022-09-30 12:20:04 +00:00
|
|
|
return true
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
lodash.forEach(floorData.teams, (t2) => {
|
|
|
|
if (t1.mark2 <= 0) {
|
2022-09-30 12:20:04 +00:00
|
|
|
return true
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
if (t1.half === t2.half || t2.mark2 <= 0) {
|
2022-09-30 12:20:04 +00:00
|
|
|
return true
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let teamKey = t1.half === 'up' ? (t1.team + '+' + t2.team) : (t2.team + '+' + t1.team)
|
2022-05-04 20:53:20 +00:00
|
|
|
if (ds[teamKey]) {
|
2022-09-30 12:20:04 +00:00
|
|
|
return true
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
if (hasSame(t1.teamArr, t2.teamArr)) {
|
2022-09-30 12:20:04 +00:00
|
|
|
return true
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ds[teamKey] = {
|
2022-07-23 20:32:10 +00:00
|
|
|
up: t1.half === 'up' ? t1 : t2,
|
|
|
|
down: t1.half === 'up' ? t2 : t1,
|
2022-05-04 20:53:20 +00:00
|
|
|
count: Math.min(t1.count, t2.count),
|
|
|
|
mark: t1.hasTeam && t2.hasTeam ? t1.mark + t2.mark : t1.count + t2.count // 如果不存在组队则进行评分惩罚
|
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
t1.mark2--
|
|
|
|
t2.mark2--
|
|
|
|
return false
|
|
|
|
})
|
2022-05-04 20:53:20 +00:00
|
|
|
if (lodash.keys(ds).length >= 20) {
|
2022-07-23 20:32:10 +00:00
|
|
|
return false
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
})
|
2022-07-23 20:32:10 +00:00
|
|
|
})
|
2022-05-04 20:53:20 +00:00
|
|
|
|
|
|
|
lodash.forEach(ret, (ds, floor) => {
|
2022-07-23 20:32:10 +00:00
|
|
|
ds = lodash.sortBy(lodash.values(ds), 'mark')
|
|
|
|
ds = ds.reverse()
|
|
|
|
ds = ds.slice(0, 4)
|
2022-05-04 20:53:20 +00:00
|
|
|
|
|
|
|
lodash.forEach(ds, (team) => {
|
2022-07-23 20:32:10 +00:00
|
|
|
team.up.teamArr = Character.sortIds(team.up.teamArr)
|
|
|
|
team.down.teamArr = Character.sortIds(team.down.teamArr)
|
2022-05-04 20:53:20 +00:00
|
|
|
})
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
ret[floor] = ds
|
2022-05-04 20:53:20 +00:00
|
|
|
})
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
let avatarMap = {}
|
2022-05-04 20:53:20 +00:00
|
|
|
|
2022-09-17 09:48:24 +00:00
|
|
|
lodash.forEach(avatarData, (ds) => {
|
2022-09-03 21:08:57 +00:00
|
|
|
let char = Character.get(ds.id)
|
2022-05-04 20:53:20 +00:00
|
|
|
avatarMap[ds.id] = {
|
|
|
|
id: ds.id,
|
|
|
|
name: ds.name,
|
2022-09-17 09:48:24 +00:00
|
|
|
star: ds.star,
|
2022-05-04 20:53:20 +00:00
|
|
|
level: ds.level,
|
2022-09-03 21:08:57 +00:00
|
|
|
cons: ds.cons,
|
|
|
|
face: char.face
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
lodash.forEach(noAvatar, (d, id) => {
|
2022-07-23 20:32:10 +00:00
|
|
|
let char = Character.get(id)
|
2022-05-04 20:53:20 +00:00
|
|
|
avatarMap[id] = {
|
|
|
|
id,
|
|
|
|
name: char.name,
|
2022-09-03 21:08:57 +00:00
|
|
|
face: char.face,
|
2022-05-04 20:53:20 +00:00
|
|
|
star: char.star,
|
|
|
|
level: 0,
|
2022-07-23 20:32:10 +00:00
|
|
|
cons: 0
|
2022-05-04 20:53:20 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-07-23 20:32:10 +00:00
|
|
|
return await Common.render('stat/abyss-team', {
|
2022-05-04 20:53:20 +00:00
|
|
|
teams: ret,
|
2022-07-23 20:32:10 +00:00
|
|
|
avatars: avatarMap
|
2022-08-24 01:07:06 +00:00
|
|
|
}, { e, scale: 1.5 })
|
2022-07-03 20:51:27 +00:00
|
|
|
}
|
|
|
|
|
2022-09-16 20:37:09 +00:00
|
|
|
async function uploadData (e) {
|
2022-08-02 19:12:07 +00:00
|
|
|
let isMatch = /^#(喵喵|上传)深渊(数据)?$/.test(e.original_msg || e.msg || '')
|
2022-11-12 21:35:46 +00:00
|
|
|
if (!Cfg.get('uploadAbyssData', false) && !isMatch) {
|
2022-08-02 19:12:07 +00:00
|
|
|
return false
|
|
|
|
}
|
2022-11-25 08:14:25 +00:00
|
|
|
let mys = await MysApi.init(e, 'all')
|
2022-10-25 20:11:01 +00:00
|
|
|
if (!mys || !mys.uid) {
|
2022-08-06 22:42:14 +00:00
|
|
|
if (isMatch) {
|
2022-08-16 20:04:12 +00:00
|
|
|
e.reply(`请绑定ck后再使用${e.original_msg || e.msg}`)
|
2022-08-06 22:42:14 +00:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
let ret = {}
|
2022-10-25 20:11:01 +00:00
|
|
|
let uid = mys.uid
|
2022-09-16 20:37:09 +00:00
|
|
|
let resDetail, resAbyss
|
2022-07-03 20:51:27 +00:00
|
|
|
try {
|
2022-09-20 11:50:27 +00:00
|
|
|
resAbyss = await mys.getSpiralAbyss(1)
|
2022-10-08 09:37:22 +00:00
|
|
|
let lvs = Data.getVal(resAbyss, 'floors.0.levels.0')
|
|
|
|
// 检查是否查询到了深渊信息
|
|
|
|
if (!lvs || !lvs.battles) {
|
|
|
|
e.reply('暂未获得本期深渊挑战数据...')
|
|
|
|
return true
|
|
|
|
} else if (lvs && lvs.battles && lvs.battles.length === 0) {
|
|
|
|
if (!mys.isSelfCookie) {
|
|
|
|
if (isMatch) {
|
|
|
|
e.reply(`请绑定ck后再使用${e.original_msg || e.msg}`)
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2022-09-18 20:54:01 +00:00
|
|
|
if (resAbyss.floors.length > 0 && !await AvatarList.hasTalentCache(uid)) {
|
2022-08-03 17:51:48 +00:00
|
|
|
e.reply('正在获取用户信息,请稍候...')
|
|
|
|
}
|
2022-09-20 11:50:27 +00:00
|
|
|
resDetail = await mys.getCharacter()
|
2022-07-03 20:51:27 +00:00
|
|
|
if (!resDetail || !resAbyss || !resDetail.avatars || resDetail.avatars.length <= 3) {
|
2022-07-23 20:32:10 +00:00
|
|
|
e.reply('角色信息获取失败')
|
|
|
|
return true
|
2022-07-03 20:51:27 +00:00
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
delete resDetail._res
|
|
|
|
delete resAbyss._res
|
2022-07-07 23:02:25 +00:00
|
|
|
ret = await HutaoApi.uploadData({
|
|
|
|
uid,
|
|
|
|
resDetail,
|
|
|
|
resAbyss
|
2022-07-23 20:32:10 +00:00
|
|
|
})
|
2022-07-03 20:51:27 +00:00
|
|
|
} catch (err) {
|
2022-07-07 23:02:25 +00:00
|
|
|
// console.log(err);
|
2022-07-03 20:51:27 +00:00
|
|
|
}
|
|
|
|
if (ret && ret.retcode === 0) {
|
2022-07-31 21:42:16 +00:00
|
|
|
let stat = []
|
2022-07-07 23:02:25 +00:00
|
|
|
if (ret.data) {
|
2022-07-31 21:42:16 +00:00
|
|
|
if (resAbyss.floors.length === 0) {
|
|
|
|
e.reply('暂未获得本期深渊挑战数据...')
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
let abyss = new Abyss(resAbyss)
|
2022-08-16 20:04:12 +00:00
|
|
|
let abyssData = abyss.getData()
|
2022-09-18 20:54:01 +00:00
|
|
|
let avatars = new AvatarList(uid, resDetail.avatars)
|
2022-08-01 21:15:37 +00:00
|
|
|
let avatarIds = abyss.getAvatars()
|
2022-08-16 20:04:12 +00:00
|
|
|
let overview = ret.info || (await HutaoApi.getOverview())?.data || {}
|
2022-07-07 23:02:25 +00:00
|
|
|
let addMsg = function (title, ds) {
|
2022-07-31 21:42:16 +00:00
|
|
|
let tmp = {}
|
2022-08-16 20:04:12 +00:00
|
|
|
if (!ds) {
|
2022-09-30 12:20:04 +00:00
|
|
|
return false
|
2022-07-07 23:02:25 +00:00
|
|
|
}
|
2022-08-16 20:04:12 +00:00
|
|
|
if (!ds.avatarId && !ds.id) {
|
2022-09-30 12:20:04 +00:00
|
|
|
return false
|
2022-08-16 20:04:12 +00:00
|
|
|
}
|
|
|
|
let char = Character.get(ds.avatarId || ds.id)
|
2022-07-31 21:42:16 +00:00
|
|
|
tmp.title = title
|
|
|
|
tmp.id = char.id
|
2022-08-02 19:12:07 +00:00
|
|
|
tmp.value = `${(ds.value / 10000).toFixed(1)} W`
|
2022-07-31 21:42:16 +00:00
|
|
|
let msg = []
|
|
|
|
tmp.msg = msg
|
2022-07-08 21:49:29 +00:00
|
|
|
let pct = (percent, name) => {
|
|
|
|
if (percent < 0.2) {
|
2022-07-31 21:42:16 +00:00
|
|
|
msg.push({
|
|
|
|
title: '少于',
|
|
|
|
value: (Math.max(0.1, 100 - percent * 100)).toFixed(1),
|
|
|
|
name: name
|
|
|
|
})
|
2022-07-08 21:49:29 +00:00
|
|
|
} else {
|
2022-07-31 21:42:16 +00:00
|
|
|
msg.push({
|
|
|
|
title: '超过',
|
|
|
|
value: (Math.min(99.9, percent * 100)).toFixed(1),
|
|
|
|
name: name
|
|
|
|
})
|
2022-07-08 21:49:29 +00:00
|
|
|
}
|
2022-07-07 23:02:25 +00:00
|
|
|
}
|
2022-08-16 20:04:12 +00:00
|
|
|
if (ds.percent) {
|
|
|
|
pct(ds.percent, char.name)
|
|
|
|
pct(ds.percentTotal, '总记录')
|
|
|
|
} else {
|
|
|
|
msg.push({
|
|
|
|
txt: '暂无统计信息'
|
|
|
|
})
|
|
|
|
}
|
2022-07-31 21:42:16 +00:00
|
|
|
stat.push(tmp)
|
2022-07-07 23:02:25 +00:00
|
|
|
}
|
2022-08-16 20:04:12 +00:00
|
|
|
addMsg('最强一击', ret.data?.damage || abyssData?.stat?.dmg || {})
|
|
|
|
addMsg('最高承伤', ret.data?.takeDamage || abyssData?.stat.takeDmg || {})
|
2022-09-20 11:50:27 +00:00
|
|
|
let avatarData = await avatars.getTalentData(avatarIds, mys)
|
2022-07-31 21:42:16 +00:00
|
|
|
return await Common.render('stat/abyss-summary', {
|
2022-08-16 20:04:12 +00:00
|
|
|
abyss: abyssData,
|
2022-07-31 21:42:16 +00:00
|
|
|
avatars: avatarData,
|
|
|
|
stat,
|
2022-08-02 19:12:07 +00:00
|
|
|
save_id: uid,
|
2022-08-16 20:04:12 +00:00
|
|
|
totalCount: overview?.collectedPlayerCount || 0,
|
2022-08-02 19:12:07 +00:00
|
|
|
uid
|
2022-08-24 01:07:06 +00:00
|
|
|
}, { e, scale: 1.8 })
|
2022-07-31 21:42:16 +00:00
|
|
|
} else {
|
|
|
|
e.reply('暂未获得本期深渊挑战数据...')
|
|
|
|
return true
|
2022-07-07 23:02:25 +00:00
|
|
|
}
|
2022-07-03 20:51:27 +00:00
|
|
|
} else {
|
2022-07-23 20:32:10 +00:00
|
|
|
e.reply(`${ret.message || '上传失败'},请稍后重试...`)
|
2022-07-03 20:51:27 +00:00
|
|
|
}
|
2022-07-23 20:32:10 +00:00
|
|
|
return true
|
|
|
|
}
|