miao-plugin/apps/profile/ProfileArtis.js

103 lines
2.6 KiB
JavaScript
Raw Normal View History

/*
* 角色圣遗物评分详情
*
* */
import lodash from 'lodash'
import { Cfg, Common, Meta } from '#miao'
import { getTargetUid, profileHelp, getProfileRefresh } from './ProfileCommon.js'
2024-02-04 01:27:34 +00:00
import { Artifact, Button, Character, Player } from '#miao.models'
import ArtisMarkCfg from '../../models/artis/ArtisMarkCfg.js'
/*
* 角色圣遗物面板
* */
export async function profileArtis (e) {
let { uid, avatar } = e
let profile = e._profile || await getProfileRefresh(e, avatar)
if (!profile) {
return true
}
2022-08-18 10:13:42 +00:00
if (!profile.hasArtis()) {
e.reply('未能获得圣遗物详情,请重新获取面板信息后查看')
return true
}
let char = profile.char
let { game } = char
let charCfg = ArtisMarkCfg.getCfg(profile)
2022-08-18 10:13:42 +00:00
2024-04-01 17:39:32 +00:00
let { attrMap } = Meta.getMeta(game, 'arti')
let artisDetail = profile.getArtisMark()
2024-04-01 17:39:32 +00:00
let artisKeyTitle = Artifact.getArtisKeyTitle(game)
// 渲染图像
2024-02-04 01:27:34 +00:00
return e.reply([await Common.render('character/artis-mark', {
uid,
elem: char.elem,
splash: profile.costumeSplash,
2024-04-03 12:08:11 +00:00
imgs: profile.imgs,
data: profile,
costume: profile.costume ? '2' : '',
artisDetail,
artisKeyTitle,
attrMap,
charCfg,
game,
changeProfile: e._profileMsg
2024-04-01 17:39:32 +00:00
}, { e, scale: 1.6 / 1.1, retType: 'base64' }), new Button(e).profile(char, uid)])
}
/*
* 圣遗物列表
* */
export async function profileArtisList (e) {
2024-04-03 16:35:06 +00:00
let game = /星铁|遗器/.test(e.msg) ? 'sr' : 'gs'
2024-04-03 18:01:01 +00:00
e.isSr = game === 'sr'
2024-04-03 16:35:06 +00:00
let uid = await getTargetUid(e)
if (!uid) {
return true
}
let artis = []
2024-04-03 16:35:06 +00:00
let player = Player.create(uid, game)
2023-02-08 20:55:54 +00:00
player.forEachAvatar((avatar) => {
let profile = avatar.getProfile()
if (!profile) {
return true
}
2022-08-18 10:13:42 +00:00
let name = profile.name
2024-04-03 16:35:06 +00:00
let char = Character.get(name, game)
2022-08-18 10:13:42 +00:00
if (!profile.hasData || !profile.hasArtis()) {
return true
}
2022-08-18 10:13:42 +00:00
let profileArtis = profile.getArtisMark()
lodash.forEach(profileArtis.artis, (arti, idx) => {
arti.charWeight = profileArtis.charWeight
2022-08-18 10:13:42 +00:00
arti.avatar = name
arti.side = char.side
2022-08-18 10:13:42 +00:00
artis.push(arti)
})
})
if (artis.length === 0) {
2024-04-03 16:35:06 +00:00
let artisName = game === 'gs' ? '圣遗物' : '遗器'
e.reply(`请先获取角色面板数据后再查看${artisName}列表...`)
await profileHelp(e)
return true
}
artis = lodash.sortBy(artis, '_mark')
artis = artis.reverse()
let number = Cfg.get('artisNumber', 28)
artis = artis.slice(0, `${number}`)
2024-04-03 16:35:06 +00:00
let artisKeyTitle = Artifact.getArtisKeyTitle(game)
// 渲染图像
return await Common.render('character/artis-list', {
save_id: uid,
uid,
artis,
artisKeyTitle
}, { e, scale: 1.4 })
2024-04-01 17:39:32 +00:00
}