2022-06-25 23:45:43 +00:00
|
|
|
/*
|
|
|
|
* 角色圣遗物评分详情
|
|
|
|
*
|
|
|
|
* */
|
2022-07-30 21:06:00 +00:00
|
|
|
import lodash from 'lodash'
|
|
|
|
import { Profile, Common, Format } from '../../components/index.js'
|
|
|
|
import { getTargetUid, profileHelp, autoGetProfile } from './profile-common.js'
|
|
|
|
import { Artifact } from '../../components/models.js'
|
2022-06-25 23:45:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 角色圣遗物面板
|
|
|
|
* */
|
2022-07-30 21:06:00 +00:00
|
|
|
export async function profileArtis (e, { render }) {
|
|
|
|
let { uid, avatar } = e
|
2022-06-25 23:45:43 +00:00
|
|
|
|
2022-06-27 20:46:49 +00:00
|
|
|
let { profile, char, err } = await autoGetProfile(e, uid, avatar, async () => {
|
2022-07-30 21:06:00 +00:00
|
|
|
await profileArtis(e, { render })
|
|
|
|
})
|
2022-06-27 20:46:49 +00:00
|
|
|
|
|
|
|
if (err) {
|
2022-07-30 21:06:00 +00:00
|
|
|
return
|
2022-06-27 20:46:49 +00:00
|
|
|
}
|
2022-06-25 23:45:43 +00:00
|
|
|
|
2022-07-30 21:06:00 +00:00
|
|
|
let charCfg = Artifact.getCharCfg(profile.name)
|
|
|
|
let { artis, totalMark, totalMarkClass, usefulMark } = getArtis(profile.name, profile.artis)
|
2022-06-27 20:46:49 +00:00
|
|
|
|
|
|
|
if (!profile.artis || profile.artis.length === 0) {
|
2022-07-30 21:06:00 +00:00
|
|
|
e.reply('未能获得圣遗物详情,请重新获取面板信息后查看')
|
|
|
|
return true
|
2022-06-27 20:46:49 +00:00
|
|
|
}
|
|
|
|
|
2022-07-30 21:06:00 +00:00
|
|
|
let { attrMap } = Artifact.getMeta()
|
2022-06-25 23:45:43 +00:00
|
|
|
|
2022-07-30 21:06:00 +00:00
|
|
|
// 渲染图像
|
|
|
|
return await Common.render('character/artis-mark', {
|
2022-06-25 23:45:43 +00:00
|
|
|
uid,
|
|
|
|
elem: char.elem,
|
|
|
|
data: profile,
|
|
|
|
artis,
|
|
|
|
totalMark,
|
|
|
|
totalMarkClass,
|
|
|
|
usefulMark,
|
|
|
|
attrMap,
|
|
|
|
charCfg
|
2022-07-30 21:06:00 +00:00
|
|
|
}, { e, render, scale: 1.3 })
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 圣遗物列表
|
|
|
|
* */
|
2022-07-30 21:06:00 +00:00
|
|
|
export async function profileArtisList (e, { render }) {
|
|
|
|
let uid = await getTargetUid(e)
|
2022-06-25 23:45:43 +00:00
|
|
|
if (!uid) {
|
2022-07-30 21:06:00 +00:00
|
|
|
return true
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
|
|
|
|
2022-07-30 21:06:00 +00:00
|
|
|
let artis = []
|
|
|
|
let profiles = Profile.getAll(uid) || {}
|
2022-06-25 23:45:43 +00:00
|
|
|
|
|
|
|
if (!profiles || profiles.length === 0) {
|
2022-07-30 21:06:00 +00:00
|
|
|
e.reply('暂无角色圣遗物详情')
|
|
|
|
return true
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lodash.forEach(profiles || [], (ds) => {
|
2022-07-30 21:06:00 +00:00
|
|
|
let name = ds.name
|
|
|
|
if (!name || name === '空' || name === '荧') {
|
|
|
|
return
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
|
|
|
|
2022-07-30 21:06:00 +00:00
|
|
|
let usefulMark
|
2022-06-25 23:45:43 +00:00
|
|
|
|
2022-07-30 21:06:00 +00:00
|
|
|
let charCfg = Artifact.getCharCfg(name)
|
|
|
|
usefulMark = charCfg.titleWeight
|
2022-06-25 23:45:43 +00:00
|
|
|
|
|
|
|
/* 处理圣遗物 */
|
|
|
|
if (ds.artis) {
|
2022-07-30 21:06:00 +00:00
|
|
|
let newScore = Artifact.getArtisMark(name, ds.artis)
|
2022-06-25 23:45:43 +00:00
|
|
|
|
|
|
|
lodash.forEach(ds.artis, (arti, idx) => {
|
|
|
|
if (!arti.name) {
|
2022-07-30 21:06:00 +00:00
|
|
|
return
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
2022-07-30 21:06:00 +00:00
|
|
|
idx = idx.replace('arti', '')
|
|
|
|
let mark = newScore[idx]
|
|
|
|
arti.mark = Format.comma(mark, 1)
|
|
|
|
arti._mark = mark
|
|
|
|
arti.markClass = Artifact.getMarkClass(mark)
|
|
|
|
arti.main = Artifact.formatArti(arti.main)
|
|
|
|
arti.attrs = Artifact.formatArti(arti.attrs)
|
|
|
|
arti.usefulMark = usefulMark
|
|
|
|
arti.avatar = name
|
|
|
|
artis.push(arti)
|
2022-06-25 23:45:43 +00:00
|
|
|
})
|
|
|
|
}
|
2022-07-30 21:06:00 +00:00
|
|
|
})
|
2022-06-25 23:45:43 +00:00
|
|
|
|
|
|
|
if (artis.length === 0) {
|
2022-07-30 21:06:00 +00:00
|
|
|
e.reply('请先获取角色面板数据后再查看圣遗物列表...')
|
|
|
|
await profileHelp(e)
|
|
|
|
return true
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
2022-07-30 21:06:00 +00:00
|
|
|
artis = lodash.sortBy(artis, '_mark')
|
|
|
|
artis = artis.reverse()
|
|
|
|
artis = artis.slice(0, 28)
|
2022-06-25 23:45:43 +00:00
|
|
|
|
2022-07-30 21:06:00 +00:00
|
|
|
// 渲染图像
|
|
|
|
return await Common.render('character/artis', {
|
2022-06-25 23:45:43 +00:00
|
|
|
save_id: uid,
|
2022-07-30 21:06:00 +00:00
|
|
|
uid,
|
|
|
|
artis
|
|
|
|
}, { e, render, scale: 1.4 })
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 获取圣遗物评分及详情
|
|
|
|
* */
|
2022-07-30 21:06:00 +00:00
|
|
|
export function getArtis (char, artisData) {
|
|
|
|
let charCfg = Artifact.getCharCfg(char)
|
|
|
|
let newScore = Artifact.getArtisMark(char, artisData)
|
|
|
|
let totalMark = 0
|
|
|
|
let artis = []
|
2022-06-25 23:45:43 +00:00
|
|
|
|
|
|
|
lodash.forEach(artisData, (arti, idx) => {
|
2022-07-30 21:06:00 +00:00
|
|
|
idx = idx.replace('arti', '')
|
|
|
|
let ds = arti
|
|
|
|
let mark = newScore[idx]
|
|
|
|
totalMark += mark
|
|
|
|
ds.mark = Format.comma(mark, 1)
|
|
|
|
ds.markClass = Artifact.getMarkClass(mark)
|
|
|
|
ds.main = Artifact.formatArti(arti.main, charCfg.mark, true)
|
|
|
|
ds.attrs = Artifact.formatArti(arti.attrs, charCfg.mark, false)
|
|
|
|
artis[idx * 1 - 1] = ds
|
|
|
|
})
|
2022-06-25 23:45:43 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
artis,
|
|
|
|
totalMark,
|
|
|
|
totalMarkClass: Artifact.getMarkClass(totalMark / 5),
|
|
|
|
usefulMark: charCfg.titleWeight
|
|
|
|
}
|
|
|
|
}
|