mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-25 17:35:34 +00:00
优化Enka下对圣遗物词条PropIds的处理逻辑,使属性计算更准确
修复部分情况下自定义面板图不展示的问题
This commit is contained in:
parent
1ee3e9df51
commit
0292db4350
@ -43,7 +43,7 @@ export async function profileArtis (e) {
|
||||
return await Common.render('character/artis-mark', {
|
||||
uid,
|
||||
elem: char.elem,
|
||||
splash: char.getImgs(profile.costume).splash0,
|
||||
splash: profile.costumeSplash,
|
||||
data: profile,
|
||||
costume: profile.costume ? '2' : '',
|
||||
artisDetail,
|
||||
|
@ -195,6 +195,7 @@ export async function renderProfile (e, char, mode = 'profile', params = {}) {
|
||||
let artisDetail = profile.getArtisMark()
|
||||
let artisKeyTitle = ProfileArtis.getArtisKeyTitle()
|
||||
let imgs = char.getImgs(profile.costume)
|
||||
let costumeSplash = profile.costumeSplash
|
||||
// 渲染图像
|
||||
let msgRes = await Common.render('character/profile-detail', {
|
||||
save_id: uid,
|
||||
@ -210,6 +211,7 @@ export async function renderProfile (e, char, mode = 'profile', params = {}) {
|
||||
artisKeyTitle,
|
||||
enemyLv,
|
||||
imgs,
|
||||
costumeSplash,
|
||||
enemyName: dmgCalc.enemyName || '小宝',
|
||||
talentMap: { a: '普攻', e: '战技', q: '爆发' },
|
||||
bodyClass: `char-${char.name}`,
|
||||
@ -218,7 +220,7 @@ export async function renderProfile (e, char, mode = 'profile', params = {}) {
|
||||
}, { e, scale: 1.6, retMsgId: true })
|
||||
if (msgRes && msgRes.message_id) {
|
||||
// 如果消息发送成功,就将message_id和图片路径存起来,3小时过期
|
||||
await redis.set(`miao:original-picture:${msgRes.message_id}`, imgs.splash0, { EX: 3600 * 3 })
|
||||
await redis.set(`miao:original-picture:${msgRes.message_id}`, costumeSplash, { EX: 3600 * 3 })
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -58,22 +58,24 @@ class Artifact extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
static getMainById (id, level = 20, star) {
|
||||
let cfg = mainIdMap[id]
|
||||
if (!cfg) {
|
||||
static getMainById (id, level = 20, star = 5) {
|
||||
let key = mainIdMap[id]
|
||||
if (!key) {
|
||||
return false
|
||||
}
|
||||
let attrCfg = attrMap[Format.isElem(cfg.key) ? 'dmg' : cfg.key]
|
||||
let eff = ['hpPlus', 'atkPlus', 'defPlus'].includes(cfg.key) ? 2 : 1
|
||||
let attrCfg = attrMap[Format.isElem(key) ? 'dmg' : key]
|
||||
let posEff = ['hpPlus', 'atkPlus', 'defPlus'].includes(key) ? 2 : 1
|
||||
let starEff = { 1: 0.21, 2: 0.36, 3: 0.6, 4: 0.9, 5: 1 }
|
||||
return {
|
||||
key: cfg.key,
|
||||
value: attrCfg.value * (1.2 + 0.34 * level) * eff
|
||||
key,
|
||||
value: attrCfg.value * (1.2 + 0.34 * level) * posEff * (starEff[star || 5])
|
||||
}
|
||||
}
|
||||
|
||||
static getAttrsByIds (ids) {
|
||||
static getAttrsByIds (ids, star = 5) {
|
||||
let ret = []
|
||||
let tmp = {}
|
||||
let starEff = { 1: 0.21, 2: 0.36, 3: 0.6, 4: 0.8, 5: 1 }
|
||||
lodash.forEach(ids, (id) => {
|
||||
let cfg = attrIdMap[id]
|
||||
if (!cfg) {
|
||||
@ -93,7 +95,7 @@ class Artifact extends Base {
|
||||
})
|
||||
lodash.forEach(tmp, (ds, key) => {
|
||||
if (attrMap[key]) {
|
||||
ds.value = attrMap[key].value * ds.eff
|
||||
ds.value = attrMap[key].value * ds.eff * starEff[star]
|
||||
}
|
||||
})
|
||||
return ret
|
||||
|
@ -87,7 +87,7 @@ export default class AvatarArtis extends Base {
|
||||
arti.mainId = ds.mainId
|
||||
arti.attrIds = ds.attrIds
|
||||
arti.main = Artifact.getMainById(ds.mainId, arti._level, arti._star)
|
||||
arti.attrs = Artifact.getAttrsByIds(ds.attrIds)
|
||||
arti.attrs = Artifact.getAttrsByIds(ds.attrIds, arti._star)
|
||||
} else if (ds.main && ds.attrs) {
|
||||
arti.main = ArtisMark.formatAttr(ds.main || {})
|
||||
arti.attrs = []
|
||||
|
@ -20,6 +20,9 @@ let getMeta = function (name) {
|
||||
}
|
||||
|
||||
class Character extends Base {
|
||||
// 默认获取的数据
|
||||
_dataKey = 'id,name,abbr,title,star,elem,allegiance,weapon,birthday,astro,cncv,jpcv,ver,desc,talentCons'
|
||||
|
||||
constructor ({ id, name = '', elem = '' }) {
|
||||
super()
|
||||
// 检查缓存
|
||||
@ -40,9 +43,6 @@ class Character extends Base {
|
||||
return this._cache()
|
||||
}
|
||||
|
||||
// 默认获取的数据
|
||||
_dataKey = 'id,name,abbr,title,star,elem,allegiance,weapon,birthday,astro,cncv,jpcv,ver,desc,talentCons'
|
||||
|
||||
// 是否为官方角色
|
||||
get isOfficial () {
|
||||
return /[12]0\d{6}/.test(this._id)
|
||||
@ -140,6 +140,59 @@ class Character extends Base {
|
||||
return this.meta?.talentCons || {}
|
||||
}
|
||||
|
||||
// 获取生日
|
||||
get birthday () {
|
||||
let birth = this.birth
|
||||
if (!birth) {
|
||||
return ''
|
||||
}
|
||||
birth = birth.split('-')
|
||||
return `${birth[0]}月${birth[1]}日`
|
||||
}
|
||||
|
||||
// 基于角色名获取Character
|
||||
static get (val) {
|
||||
let id = CharId.getId(val, Character.gsCfg)
|
||||
if (!id) {
|
||||
return false
|
||||
}
|
||||
return new Character(id)
|
||||
}
|
||||
|
||||
static forEach (fn, type = 'all') {
|
||||
lodash.forEach(idMap, (name, id) => {
|
||||
let char = Character.get({ id, name })
|
||||
if (type === 'release' && !char.isRelease) {
|
||||
return true
|
||||
}
|
||||
if (type === 'official' && !char.isOfficial) {
|
||||
return true
|
||||
}
|
||||
return fn(char) !== false
|
||||
})
|
||||
}
|
||||
|
||||
// 当获取角色为旅行者时,会考虑当前uid的账号情况返回对应旅行者
|
||||
static async getAvatar (name, uid) {
|
||||
let char = Character.get(name)
|
||||
return await char.getTraveler(uid)
|
||||
}
|
||||
|
||||
// TODO:待废弃
|
||||
static getAbbr () {
|
||||
return abbrMap
|
||||
}
|
||||
|
||||
// TODO:待废弃
|
||||
static checkWifeType (charid, type) {
|
||||
return !!wifeMap[type][charid]
|
||||
}
|
||||
|
||||
// 获取排序ID
|
||||
static sortIds (arr) {
|
||||
return arr.sort((a, b) => (idSort[a] || 300) - (idSort[b] || 300))
|
||||
}
|
||||
|
||||
// 获取attr列表
|
||||
getAttrList () {
|
||||
let { meta } = this
|
||||
@ -151,16 +204,6 @@ class Character extends Base {
|
||||
return CharMeta.getMaterials(this, type)
|
||||
}
|
||||
|
||||
// 获取生日
|
||||
get birthday () {
|
||||
let birth = this.birth
|
||||
if (!birth) {
|
||||
return ''
|
||||
}
|
||||
birth = birth.split('-')
|
||||
return `${birth[0]}月${birth[1]}日`
|
||||
}
|
||||
|
||||
// 获取角色character-img图片
|
||||
getCardImg (se = false, def = true) {
|
||||
if (this.name === '旅行者') {
|
||||
@ -169,6 +212,8 @@ class Character extends Base {
|
||||
return CharImg.getCardImg(this.name, se, def)
|
||||
}
|
||||
|
||||
// 设置旅行者数据
|
||||
|
||||
getAvatarTalent (talent = {}, cons = 0, mode = 'original') {
|
||||
return CharTalent.getAvatarTalent(this.id, talent, cons, mode, this.talentCons)
|
||||
}
|
||||
@ -192,34 +237,22 @@ class Character extends Base {
|
||||
|
||||
// 获取角色插画
|
||||
getImgs (costume = '') {
|
||||
if (!lodash.isArray(costume)) {
|
||||
costume = [costume, false]
|
||||
if (lodash.isArray(costume)) {
|
||||
costume = costume[0]
|
||||
}
|
||||
let costumeCfg = [this.checkCostume(costume[0]) ? '2' : '', costume[1] || 'normal']
|
||||
|
||||
let cacheId = `costume${costume[0]}`
|
||||
let costumeIdx = this.checkCostume(costume) ? '2' : ''
|
||||
let cacheId = `costume${costumeIdx}`
|
||||
if (!this._imgs) {
|
||||
this._imgs = {}
|
||||
}
|
||||
if (!this._imgs[cacheId]) {
|
||||
this._imgs[cacheId] = CharImg.getImgs(this.name, costumeCfg, this.isTraveler ? this.elem : '', this.source === 'amber' ? 'png' : 'webp')
|
||||
this._imgs[cacheId] = CharImg.getImgs(this.name, costumeIdx, this.isTraveler ? this.elem : '', this.source === 'amber' ? 'png' : 'webp')
|
||||
}
|
||||
let ret = this._imgs[cacheId]
|
||||
let nPath = `meta/character/${this.name}`
|
||||
if (costumeCfg[1] === 'super') {
|
||||
ret.splash0 = CharImg.getRandomImg(
|
||||
[`profile/super-character/${this.name}`, `profile/normal-character/${this.name}`],
|
||||
[`${nPath}/imgs/splash0.webp`, `${nPath}/imgs/splash${costumeCfg[0]}.webp`, `/${nPath}/imgs/splash.webp`]
|
||||
)
|
||||
} else {
|
||||
ret.splash0 = CharImg.getRandomImg(
|
||||
[`profile/normal-character/${this.name}`],
|
||||
[`${nPath}/imgs/splash${costumeCfg[0]}.webp`, `/${nPath}/imgs/splash.webp`]
|
||||
)
|
||||
}
|
||||
return ret
|
||||
return this._imgs[cacheId]
|
||||
}
|
||||
|
||||
// 基于角色名获取Character
|
||||
|
||||
// 获取详情数据
|
||||
getDetail (elem = '') {
|
||||
if (this._detail) {
|
||||
@ -242,7 +275,8 @@ class Character extends Base {
|
||||
return this._detail
|
||||
}
|
||||
|
||||
// 设置旅行者数据
|
||||
// 获取别名数据
|
||||
|
||||
// TODO:迁移至Avatar
|
||||
setTraveler (uid = '') {
|
||||
if (this.isTraveler && uid && uid.toString().length === 9) {
|
||||
@ -253,6 +287,8 @@ class Character extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
// 检查wife类型
|
||||
|
||||
// 获取旅行者数据
|
||||
async getTraveler (uid) {
|
||||
if (this.isTraveler) {
|
||||
@ -285,52 +321,6 @@ class Character extends Base {
|
||||
return await this.getTraveler(uid)
|
||||
}
|
||||
|
||||
// 基于角色名获取Character
|
||||
static get (val) {
|
||||
let id = CharId.getId(val, Character.gsCfg)
|
||||
if (!id) {
|
||||
return false
|
||||
}
|
||||
return new Character(id)
|
||||
}
|
||||
|
||||
static forEach (fn, type = 'all') {
|
||||
lodash.forEach(idMap, (name, id) => {
|
||||
let char = Character.get({ id, name })
|
||||
if (type === 'release' && !char.isRelease) {
|
||||
return true
|
||||
}
|
||||
if (type === 'official' && !char.isOfficial) {
|
||||
return true
|
||||
}
|
||||
return fn(char) !== false
|
||||
})
|
||||
}
|
||||
|
||||
// 基于角色名获取Character
|
||||
// 当获取角色为旅行者时,会考虑当前uid的账号情况返回对应旅行者
|
||||
static async getAvatar (name, uid) {
|
||||
let char = Character.get(name)
|
||||
return await char.getTraveler(uid)
|
||||
}
|
||||
|
||||
// 获取别名数据
|
||||
// TODO:待废弃
|
||||
static getAbbr () {
|
||||
return abbrMap
|
||||
}
|
||||
|
||||
// 检查wife类型
|
||||
// TODO:待废弃
|
||||
static checkWifeType (charid, type) {
|
||||
return !!wifeMap[type][charid]
|
||||
}
|
||||
|
||||
// 获取排序ID
|
||||
static sortIds (arr) {
|
||||
return arr.sort((a, b) => (idSort[a] || 300) - (idSort[b] || 300))
|
||||
}
|
||||
|
||||
// 获取伤害计算配置
|
||||
getCalcRule () {
|
||||
if (!this._calcRule && this._calcRule !== false) {
|
||||
|
@ -3,6 +3,7 @@ import AvatarData from './AvatarData.js'
|
||||
import { Data } from '../components/index.js'
|
||||
import { ProfileArtis, ProfileDmg } from './index.js'
|
||||
import AttrCalc from './profile-lib/AttrCalc.js'
|
||||
import CharImg from './character-lib/CharImg.js'
|
||||
|
||||
export default class ProfileData extends AvatarData {
|
||||
constructor (ds = {}, calc = true) {
|
||||
@ -17,16 +18,27 @@ export default class ProfileData extends AvatarData {
|
||||
return this.isProfile
|
||||
}
|
||||
|
||||
get splashCostume () {
|
||||
get costumeSplash () {
|
||||
let costume = this._costume
|
||||
if (lodash.isArray(costume)) {
|
||||
costume = costume[0]
|
||||
}
|
||||
costume = this.char.checkCostume(costume) ? '2' : ''
|
||||
|
||||
let nPath = `meta/character/${this.name}`
|
||||
let isSuper = false
|
||||
let talent = this.talent ? lodash.map(this.talent, (ds) => ds.original).join('') : ''
|
||||
if (this.cons === 6 || ['ACE', 'ACE²'].includes(this.artis?.markClass) || talent === '101010') {
|
||||
return [costume, 'super']
|
||||
isSuper = true
|
||||
}
|
||||
if (isSuper) {
|
||||
return CharImg.getRandomImg(
|
||||
[`profile/super-character/${this.name}`, `profile/normal-character/${this.name}`],
|
||||
[`${nPath}/imgs/splash0.webp`, `${nPath}/imgs/splash${costume}.webp`, `/${nPath}/imgs/splash.webp`]
|
||||
)
|
||||
} else {
|
||||
return CharImg.getRandomImg(
|
||||
[`profile/normal-character/${this.name}`],
|
||||
[`${nPath}/imgs/splash${costume}.webp`, `/${nPath}/imgs/splash.webp`]
|
||||
)
|
||||
}
|
||||
return [costume, 'normal']
|
||||
}
|
||||
|
||||
get hasDmg () {
|
||||
@ -61,7 +73,6 @@ export default class ProfileData extends AvatarData {
|
||||
}
|
||||
|
||||
setArtis (ds = false) {
|
||||
console.log('ds', ds.artis?.artis[1])
|
||||
this.artis?.setProfile(this, ds.artis?.artis || ds.artis || ds)
|
||||
}
|
||||
|
||||
|
@ -82,10 +82,8 @@ const CharImg = {
|
||||
},
|
||||
|
||||
// 获取角色的图像资源数据
|
||||
getImgs (name, costumeCfg = '', travelerElem = '', fileType = 'webp') {
|
||||
if (!lodash.isArray(costumeCfg)) {
|
||||
costumeCfg = [costumeCfg, 'normal']
|
||||
}
|
||||
getImgs (name, costumeIdx = '', travelerElem = '', fileType = 'webp') {
|
||||
costumeIdx = costumeIdx === '2' ? '2' : ''
|
||||
let imgs = {}
|
||||
if (!['空', '荧', '旅行者'].includes(name)) {
|
||||
travelerElem = ''
|
||||
@ -102,10 +100,10 @@ const CharImg = {
|
||||
let tAdd = (key, path) => {
|
||||
imgs[key] = `${travelerElem ? tPath : nPath}${path}.${fileType}`
|
||||
}
|
||||
add('face', 'imgs/face', `imgs/face${costumeCfg[0]}`)
|
||||
add('side', 'imgs/side', `imgs/side${costumeCfg[0]}`)
|
||||
add('face', 'imgs/face', `imgs/face${costumeIdx}`)
|
||||
add('side', 'imgs/side', `imgs/side${costumeIdx}`)
|
||||
add('gacha', 'imgs/gacha')
|
||||
add('splash', 'imgs/splash', `imgs/splash${costumeCfg[0]}`)
|
||||
add('splash', 'imgs/splash', `imgs/splash${costumeIdx}`)
|
||||
// 检查彩蛋自定义
|
||||
tAdd('card', 'imgs/card')
|
||||
tAdd('banner', 'imgs/banner')
|
||||
|
@ -11,7 +11,7 @@
|
||||
{{block 'main'}}
|
||||
<div class="basic">
|
||||
<div class="main-pic"
|
||||
style="background-image:url({{_res_path}}{{imgs.splash0}})"></div>
|
||||
style="background-image:url({{_res_path}}{{costumeSplash || imgs?.splash}})"></div>
|
||||
<div class="detail">
|
||||
<div class="char-name">{{data.name}}</div>
|
||||
<div class="char-lv">UID {{uid}} - Lv.{{data.level}}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user