2023-02-18 10:29:09 +00:00
|
|
|
|
import { Common } from '../../components/index.js'
|
2023-02-10 21:31:41 +00:00
|
|
|
|
import { MysApi, Player, Character } from '../../models/index.js'
|
2022-08-06 22:36:05 +00:00
|
|
|
|
|
2023-02-13 20:43:14 +00:00
|
|
|
|
const ProfileStat = {
|
|
|
|
|
async stat (e) {
|
2023-02-18 10:29:09 +00:00
|
|
|
|
return ProfileStat.render(e, false)
|
2023-02-13 20:43:14 +00:00
|
|
|
|
},
|
2023-02-18 10:29:09 +00:00
|
|
|
|
|
2023-02-13 20:43:14 +00:00
|
|
|
|
async avatarList (e) {
|
2023-02-18 10:29:09 +00:00
|
|
|
|
return ProfileStat.render(e, true)
|
2023-02-13 20:43:14 +00:00
|
|
|
|
},
|
|
|
|
|
async render (e, isAvatarList = false) {
|
|
|
|
|
// 缓存时间,单位小时
|
|
|
|
|
let msg = e.msg.replace('#', '').trim()
|
|
|
|
|
if (msg === '角色统计' || msg === '武器统计') {
|
|
|
|
|
// 暂时避让一下抽卡分析的关键词
|
|
|
|
|
return false
|
|
|
|
|
}
|
2022-08-06 22:36:05 +00:00
|
|
|
|
|
2023-02-13 20:43:14 +00:00
|
|
|
|
let mys = await MysApi.init(e)
|
|
|
|
|
if (!mys || !mys.uid) return false
|
2022-08-06 22:36:05 +00:00
|
|
|
|
|
2023-02-13 20:43:14 +00:00
|
|
|
|
const uid = mys.uid
|
2023-02-10 14:01:18 +00:00
|
|
|
|
|
2023-02-13 20:43:14 +00:00
|
|
|
|
let player = Player.create(e)
|
2023-02-08 20:55:54 +00:00
|
|
|
|
|
2023-02-13 20:43:14 +00:00
|
|
|
|
let avatarRet = await player.refreshAndGetAvatarData({
|
2023-02-18 23:55:43 +00:00
|
|
|
|
index: 2,
|
2023-02-13 20:43:14 +00:00
|
|
|
|
detail: 1,
|
2023-02-18 10:29:09 +00:00
|
|
|
|
talent: isAvatarList ? 0 : 1,
|
2023-02-13 20:43:14 +00:00
|
|
|
|
rank: true,
|
|
|
|
|
retType: 'array',
|
|
|
|
|
sort: true
|
|
|
|
|
})
|
2023-02-08 20:55:54 +00:00
|
|
|
|
|
2023-02-13 20:43:14 +00:00
|
|
|
|
if (avatarRet.length === 0) {
|
|
|
|
|
e.reply(`暂未获得#${uid}角色数据,请绑定CK或 #更新面板`)
|
|
|
|
|
return true
|
|
|
|
|
}
|
2023-02-10 19:40:55 +00:00
|
|
|
|
|
2023-02-13 20:43:14 +00:00
|
|
|
|
let talentNotice = []
|
2022-08-06 22:36:05 +00:00
|
|
|
|
|
2023-02-13 20:43:14 +00:00
|
|
|
|
if (!mys.isSelfCookie) {
|
|
|
|
|
talentNotice.push('未绑定CK,信息可能展示不完全')
|
|
|
|
|
}
|
2023-02-11 07:24:44 +00:00
|
|
|
|
|
2023-02-13 20:43:14 +00:00
|
|
|
|
let faceChar = Character.get(player.face || avatarRet[0]?.id)
|
2023-02-19 02:38:51 +00:00
|
|
|
|
let imgs = faceChar.imgs
|
2023-02-13 20:43:14 +00:00
|
|
|
|
let face = {
|
2023-02-19 02:38:51 +00:00
|
|
|
|
banner: imgs?.banner,
|
|
|
|
|
face: imgs?.face,
|
|
|
|
|
qFace: imgs?.qFace,
|
2023-02-13 20:43:14 +00:00
|
|
|
|
name: player.name || `#${uid}`,
|
|
|
|
|
sign: player.sign,
|
|
|
|
|
level: player.level
|
|
|
|
|
}
|
2023-02-11 07:24:44 +00:00
|
|
|
|
|
2023-02-13 20:43:14 +00:00
|
|
|
|
let info = player.getInfo()
|
|
|
|
|
info.stats = info.stats || {}
|
|
|
|
|
info.statMap = {
|
|
|
|
|
achievement: '成就',
|
|
|
|
|
wayPoint: '锚点',
|
|
|
|
|
avatar: '角色',
|
|
|
|
|
avatar5: '五星角色',
|
|
|
|
|
goldCount: '金卡总数'
|
|
|
|
|
}
|
2022-08-06 22:36:05 +00:00
|
|
|
|
|
2023-02-13 20:43:14 +00:00
|
|
|
|
return await Common.render(isAvatarList ? 'character/avatar-list' : 'character/profile-stat', {
|
|
|
|
|
save_id: uid,
|
|
|
|
|
uid,
|
|
|
|
|
info,
|
|
|
|
|
updateTime: player.getUpdateTime(),
|
|
|
|
|
isSelfCookie: e.isSelfCookie,
|
|
|
|
|
face,
|
|
|
|
|
avatars: avatarRet,
|
|
|
|
|
talentNotice
|
|
|
|
|
}, { e, scale: 1.4 })
|
2023-02-10 21:31:41 +00:00
|
|
|
|
}
|
2022-08-06 22:36:05 +00:00
|
|
|
|
}
|
2023-02-17 20:42:05 +00:00
|
|
|
|
export default ProfileStat
|