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-11-21 21:26:06 +00:00
|
|
|
|
import { ProfileArtis } from '../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 () {
|
2022-11-26 21:51:36 +00:00
|
|
|
|
weaponBuffs = (await Data.importModule('resources/meta/weapon/index.js')).weaponBuffs || {}
|
2022-09-24 22:42:48 +00:00
|
|
|
|
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 = {}) {
|
2022-08-22 20:53:31 +00:00
|
|
|
|
let buffs = artisBuffs
|
|
|
|
|
let retBuffs = []
|
2022-11-21 21:26:06 +00:00
|
|
|
|
ProfileArtis._eachArtisSet(artis, (sets, num) => {
|
|
|
|
|
let buff = buffs[sets.name] && buffs[sets.name][num]
|
2022-11-20 20:45:27 +00:00
|
|
|
|
if (buff && !buff.isStatic) {
|
|
|
|
|
retBuffs.push({
|
|
|
|
|
...buff,
|
2022-11-21 21:26:06 +00:00
|
|
|
|
title: `${sets.name}${num}:` + buff.title
|
2022-11-20 20:45:27 +00:00
|
|
|
|
})
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return retBuffs
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 武器Buff
|
|
|
|
|
getWeaponBuffs (weaponName) {
|
|
|
|
|
let weaponCfg = weaponBuffs[weaponName] || []
|
|
|
|
|
if (lodash.isPlainObject(weaponCfg)) {
|
|
|
|
|
weaponCfg = [weaponCfg]
|
|
|
|
|
}
|
2022-11-24 03:54:27 +00:00
|
|
|
|
let ret = []
|
2022-08-22 20:53:31 +00:00
|
|
|
|
lodash.forEach(weaponCfg, (ds) => {
|
2022-11-21 21:26:06 +00:00
|
|
|
|
if (ds.isStatic) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
2022-08-22 20:53:31 +00:00
|
|
|
|
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)
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-11-24 03:54:27 +00:00
|
|
|
|
ret.push(ds)
|
2022-08-22 20:53:31 +00:00
|
|
|
|
})
|
2022-11-24 03:54:27 +00:00
|
|
|
|
return ret
|
2022-08-22 20:53:31 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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 = {
|
2022-11-05 11:31:07 +00:00
|
|
|
|
vaporize: '蒸发',
|
|
|
|
|
melt: '融化',
|
|
|
|
|
swirl: '扩散'
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
2022-11-22 20:25:36 +00:00
|
|
|
|
let mKey2 = {
|
|
|
|
|
aggravate: '超激化'
|
|
|
|
|
}
|
2022-08-22 20:53:31 +00:00
|
|
|
|
lodash.forEach(buffs, (buff, idx) => {
|
2022-11-22 20:25:36 +00:00
|
|
|
|
if (lodash.isString(buff)) {
|
|
|
|
|
if (mKey[buff]) {
|
|
|
|
|
buff = {
|
2022-11-26 08:12:32 +00:00
|
|
|
|
title: `元素精通:${mKey[buff]}伤害提高[_${buff}]%`,
|
2022-11-22 20:25:36 +00:00
|
|
|
|
mastery: buff
|
|
|
|
|
}
|
|
|
|
|
buffs[idx] = buff
|
|
|
|
|
} else if (mKey2[buff]) {
|
|
|
|
|
buff = {
|
|
|
|
|
title: `元素精通:触发${mKey2[buff]}伤害值提高[${buff}]`,
|
|
|
|
|
mastery: buff
|
|
|
|
|
}
|
|
|
|
|
buffs[idx] = buff
|
2022-08-22 20:53:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
buff.sort = lodash.isUndefined(buff.sort) ? 1 : buff.sort
|
|
|
|
|
})
|
|
|
|
|
buffs = lodash.sortBy(buffs, ['sort'])
|
|
|
|
|
return buffs
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
export default DmgBuffs
|