2024-07-03 07:34:37 +00:00
|
|
|
|
import lodash from 'lodash'
|
|
|
|
|
import { Cfg, Common, Data } from '#miao'
|
2024-07-04 18:57:19 +00:00
|
|
|
|
import { RoleCombat, MysApi, Player } from '#miao.models'
|
2024-07-03 07:34:37 +00:00
|
|
|
|
|
|
|
|
|
export async function RoleCombatSummary (e) {
|
2024-07-05 14:09:53 +00:00
|
|
|
|
let isMatch = /^#(喵喵)(幻想|幻境|剧诗|幻想真境剧诗)(数据)?$/.test(e.original_msg || e.msg || '')
|
|
|
|
|
if (!Cfg.get('roleCombat', false) && !isMatch) {
|
2024-07-03 07:34:37 +00:00
|
|
|
|
return false
|
|
|
|
|
}
|
2024-09-23 11:53:33 +00:00
|
|
|
|
// 需要自身 ck 查询
|
|
|
|
|
let mys = await MysApi.init(e, 'cookie')
|
2024-07-03 07:34:37 +00:00
|
|
|
|
if (!mys || !mys.uid) {
|
|
|
|
|
if (isMatch) {
|
|
|
|
|
e.reply(`请绑定ck后再使用${e.original_msg || e.msg}`)
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
let uid = mys.uid
|
|
|
|
|
let player = Player.create(e)
|
|
|
|
|
let resDetail, resRole
|
|
|
|
|
try {
|
2024-07-03 15:35:59 +00:00
|
|
|
|
resRole = await mys.getRoleCombat(true)
|
2024-07-03 07:34:37 +00:00
|
|
|
|
let lvs = Data.getVal(resRole, 'data.0')
|
|
|
|
|
// 检查是否查询到了幻想真境剧诗信息
|
2024-09-01 16:57:11 +00:00
|
|
|
|
// TODO: 有个 has_data,有个 has_detail_data
|
|
|
|
|
// 注意可能出现 has_data 为 false,但是 has_detail_data 为 true 的情形
|
|
|
|
|
// 不知道怎么搞,分别做适配?
|
|
|
|
|
if (!lvs || !lvs.has_detail_data) {
|
2024-07-03 07:34:37 +00:00
|
|
|
|
e.reply('暂未获得本期幻想真境剧诗挑战数据...')
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resDetail = await mys.getCharacter()
|
|
|
|
|
if (!resDetail || !resRole || !resDetail.avatars || resDetail.avatars.length <= 3) {
|
|
|
|
|
e.reply('角色信息获取失败')
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
delete resDetail._res
|
|
|
|
|
delete resRole._res
|
|
|
|
|
} catch (err) {
|
|
|
|
|
// console.log(err);
|
|
|
|
|
}
|
2024-07-04 18:57:19 +00:00
|
|
|
|
|
2024-07-03 07:34:37 +00:00
|
|
|
|
// 更新player信息
|
|
|
|
|
player.setMysCharData(resDetail)
|
|
|
|
|
|
2024-07-04 18:57:19 +00:00
|
|
|
|
if (resRole.data.length === 0) {
|
|
|
|
|
e.reply('暂未获得本期深渊挑战数据...')
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
let role = new RoleCombat(resRole.data[0])
|
|
|
|
|
let roleData = role.getData()
|
|
|
|
|
let ownAvatarIds = role.getOwnAvatars()
|
|
|
|
|
let ownAvatarData = player.getAvatarData(ownAvatarIds)
|
|
|
|
|
let otherAvatarData = role.getOtherAvatarsData()
|
|
|
|
|
|
|
|
|
|
let avatarData = lodash.merge(ownAvatarData, otherAvatarData)
|
|
|
|
|
return await Common.render('stat/role-summary', {
|
|
|
|
|
role: roleData,
|
|
|
|
|
avatars: avatarData,
|
|
|
|
|
save_id: uid,
|
|
|
|
|
uid
|
|
|
|
|
}, { e, scale: 1.2 })
|
2024-07-03 07:34:37 +00:00
|
|
|
|
}
|