2022-08-06 22:36:05 +00:00
|
|
|
|
import lodash from 'lodash'
|
2022-08-18 10:13:42 +00:00
|
|
|
|
import { Common, Profile, Data } from '../../components/index.js'
|
2022-09-20 11:50:27 +00:00
|
|
|
|
import { AvatarList, MysApi } from '../../models/index.js'
|
2022-08-06 22:36:05 +00:00
|
|
|
|
|
2022-08-24 01:07:06 +00:00
|
|
|
|
export async function profileStat (e) {
|
2022-08-06 22:36:05 +00:00
|
|
|
|
// 缓存时间,单位小时
|
|
|
|
|
|
|
|
|
|
let msg = e.msg.replace('#', '').trim()
|
|
|
|
|
if (msg === '角色统计' || msg === '武器统计') {
|
|
|
|
|
// 暂时避让一下抽卡分析的关键词
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 11:50:27 +00:00
|
|
|
|
let mys = await MysApi.init(e)
|
|
|
|
|
if (!mys || !mys.uid) return true
|
|
|
|
|
let uid = mys.uid
|
2022-08-06 22:36:05 +00:00
|
|
|
|
|
2022-09-20 11:50:27 +00:00
|
|
|
|
let resIndex = await mys.getCharacter()
|
2022-08-06 22:36:05 +00:00
|
|
|
|
if (!resIndex) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 20:54:01 +00:00
|
|
|
|
if (!await AvatarList.hasTalentCache(uid)) {
|
2022-08-07 22:24:40 +00:00
|
|
|
|
e.reply('正在获取角色信息,请稍候...')
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 20:54:01 +00:00
|
|
|
|
let avatars = new AvatarList(uid, resIndex.avatars)
|
2022-08-06 22:36:05 +00:00
|
|
|
|
let ids = avatars.getIds()
|
|
|
|
|
|
2022-09-20 11:50:27 +00:00
|
|
|
|
let talentData = await avatars.getTalentData(ids, mys)
|
2022-08-06 22:36:05 +00:00
|
|
|
|
|
|
|
|
|
// 天赋等级背景
|
|
|
|
|
const talentLvMap = '0,1,1,1,2,2,3,3,3,4,5'.split(',')
|
|
|
|
|
|
2022-08-07 22:14:24 +00:00
|
|
|
|
let profiles = Profile.getAll(uid)
|
|
|
|
|
|
2022-08-06 22:36:05 +00:00
|
|
|
|
let avatarRet = []
|
|
|
|
|
lodash.forEach(talentData, (avatar) => {
|
2022-08-18 10:13:42 +00:00
|
|
|
|
let { talent, id } = avatar
|
2022-08-06 22:36:05 +00:00
|
|
|
|
avatar.aeq = talent?.a?.original + talent?.e?.original + talent?.q?.original || 3
|
|
|
|
|
avatarRet.push(avatar)
|
2022-08-18 10:13:42 +00:00
|
|
|
|
if (profiles[id]) {
|
2022-09-08 09:38:15 +00:00
|
|
|
|
let profile = profiles[id]
|
2022-09-20 11:50:27 +00:00
|
|
|
|
if (profile.hasData) {
|
2022-09-08 09:38:15 +00:00
|
|
|
|
let mark = profiles[id].getArtisMark(false)
|
|
|
|
|
avatar.artisMark = Data.getData(mark, 'mark,markClass,names')
|
|
|
|
|
}
|
2022-08-07 22:14:24 +00:00
|
|
|
|
}
|
2022-08-06 22:36:05 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
let sortKey = 'level,star,aeq,cons,weapon.level,weapon.star,weapon.affix,fetter'.split(',')
|
|
|
|
|
|
|
|
|
|
avatarRet = lodash.orderBy(avatarRet, sortKey)
|
|
|
|
|
avatarRet = avatarRet.reverse()
|
|
|
|
|
|
2022-08-07 22:14:24 +00:00
|
|
|
|
let talentNotice = ''
|
2022-08-06 22:36:05 +00:00
|
|
|
|
|
2022-09-20 11:50:27 +00:00
|
|
|
|
if (!mys.isSelfCookie) {
|
2022-08-07 22:14:24 +00:00
|
|
|
|
talentNotice = '未绑定Cookie,无法获取天赋列表。请回复 #体力帮助 获取配置教程'
|
2022-08-06 22:36:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return await Common.render('character/profile-stat', {
|
|
|
|
|
save_id: uid,
|
|
|
|
|
uid,
|
|
|
|
|
talentLvMap,
|
|
|
|
|
avatars: avatarRet,
|
|
|
|
|
isSelf: e.isSelf,
|
|
|
|
|
talentNotice,
|
2022-08-07 22:14:24 +00:00
|
|
|
|
elem: 'hydro'
|
2022-08-24 01:07:06 +00:00
|
|
|
|
}, { e, scale: 1.8 })
|
2022-08-06 22:36:05 +00:00
|
|
|
|
}
|