2022-08-22 20:53:31 +00:00
|
|
|
|
/*
|
|
|
|
|
* 伤害计算 - Buff计算
|
|
|
|
|
* */
|
|
|
|
|
import lodash from 'lodash'
|
2022-09-24 22:42:48 +00:00
|
|
|
|
import { Data } from '../../components/index.js'
|
2022-08-22 20:53:31 +00:00
|
|
|
|
|
|
|
|
|
let weaponBuffs = {}
|
|
|
|
|
let artisBuffs = {}
|
|
|
|
|
|
2022-09-24 22:42:48 +00:00
|
|
|
|
// lazy load
|
|
|
|
|
setTimeout(async function init () {
|
|
|
|
|
weaponBuffs = (await Data.importModule('resources/meta/weapon/index.js')).calc || {}
|
|
|
|
|
artisBuffs = (await Data.importModule('resources/meta/artifact/index.js')).calc || {}
|
|
|
|
|
})
|
|
|
|
|
|
2022-08-22 20:53:31 +00:00
|
|
|
|
let DmgBuffs = {
|
|
|
|
|
// 圣遗物Buff
|
2022-09-11 13:10:38 +00:00
|
|
|
|
getArtisBuffs (artis = {}) {
|
|
|
|
|
if (!artis) {
|
|
|
|
|
return []
|
|
|
|
|
}
|
2022-08-22 20:53:31 +00:00
|
|
|
|
let buffs = artisBuffs
|
|
|
|
|
let retBuffs = []
|
2022-09-11 13:10:38 +00:00
|
|
|
|
lodash.forEach(artis, (v, k) => {
|
|
|
|
|
if (buffs[k + v]) {
|
|
|
|
|
retBuffs.push(buffs[k + v])
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
2022-09-24 22:42:48 +00:00
|
|
|
|
if (v >= 4 && buffs[k + '2']) {
|
|
|
|
|
retBuffs.push(buffs[k + '2'])
|
|
|
|
|
}
|
2022-08-22 20:53:31 +00:00
|
|
|
|
})
|
|
|
|
|
return retBuffs
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 武器Buff
|
|
|
|
|
getWeaponBuffs (weaponName) {
|
|
|
|
|
let weaponCfg = weaponBuffs[weaponName] || []
|
|
|
|
|
if (lodash.isPlainObject(weaponCfg)) {
|
|
|
|
|
weaponCfg = [weaponCfg]
|
|
|
|
|
}
|
|
|
|
|
lodash.forEach(weaponCfg, (ds) => {
|
|
|
|
|
if (!/:/.test(ds.title)) {
|
|
|
|
|
ds.title = `${weaponName}:${ds.title}`
|
|
|
|
|
}
|
|
|
|
|
if (ds.refine) {
|
|
|
|
|
ds.data = ds.data || {}
|
|
|
|
|
lodash.forEach(ds.refine, (r, key) => {
|
|
|
|
|
ds.data[key] = ({ refine }) => r[refine] * (ds.buffCount || 1)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return weaponCfg
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getBuffs (profile, buffs = []) {
|
|
|
|
|
let weaponBuffs = DmgBuffs.getWeaponBuffs(profile.weapon?.name || '')
|
2022-09-11 13:10:38 +00:00
|
|
|
|
let artisBuffs = DmgBuffs.getArtisBuffs(profile.artis)
|
2022-08-22 20:53:31 +00:00
|
|
|
|
buffs = lodash.concat(buffs, weaponBuffs, artisBuffs)
|
|
|
|
|
let mKey = {
|
|
|
|
|
zf: '蒸发',
|
|
|
|
|
rh: '融化',
|
|
|
|
|
ks: '扩散'
|
|
|
|
|
}
|
|
|
|
|
lodash.forEach(buffs, (buff, idx) => {
|
|
|
|
|
if (lodash.isString(buff) && mKey[buff]) {
|
|
|
|
|
buff = {
|
|
|
|
|
title: `元素精通:${mKey[buff]}伤害提高[${buff}]%`,
|
|
|
|
|
mastery: buff
|
|
|
|
|
}
|
|
|
|
|
buffs[idx] = buff
|
|
|
|
|
}
|
|
|
|
|
buff.sort = lodash.isUndefined(buff.sort) ? 1 : buff.sort
|
|
|
|
|
})
|
|
|
|
|
buffs = lodash.sortBy(buffs, ['sort'])
|
|
|
|
|
return buffs
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
export default DmgBuffs
|