miao-plugin/models/profile/DmgBuffs.js

82 lines
2.1 KiB
JavaScript
Raw Normal View History

2022-08-22 20:53:31 +00:00
/*
* 伤害计算 - Buff计算
* */
import lodash from 'lodash'
2023-05-21 18:13:38 +00:00
import { ProfileArtis, ArtifactSet, Weapon } from '../index.js'
2022-08-22 20:53:31 +00:00
let DmgBuffs = {
2023-05-21 18:13:38 +00:00
getBuffs (profile, buffs = [], game = 'gs') {
let weaponBuffs = DmgBuffs.getWeaponBuffs(profile.weapon, game)
let artisBuffs = DmgBuffs.getArtisBuffs(profile.artis, game)
2022-08-22 20:53:31 +00:00
buffs = lodash.concat(buffs, weaponBuffs, artisBuffs)
let mKey = {
vaporize: '蒸发',
melt: '融化',
swirl: '扩散'
2022-08-22 20:53:31 +00:00
}
let mKey2 = {
aggravate: '超激化'
}
buffs = lodash.filter(buffs, (b) => !!b)
2022-08-22 20:53:31 +00:00
lodash.forEach(buffs, (buff, idx) => {
if (lodash.isString(buff)) {
if (mKey[buff]) {
buff = {
title: `元素精通:${mKey[buff]}伤害提高[_${buff}]%`,
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
2023-05-21 18:13:38 +00:00
},
// 圣遗物Buff
getArtisBuffs (artis = {}, game = 'gs') {
let retBuffs = []
ProfileArtis._eachArtisSet(artis, (sets, num) => {
let buffs = ArtifactSet.getArtisSetBuff(sets.name, num, game)
if (lodash.isPlainObject(buffs)) {
buffs = [buffs]
}
lodash.forEach(buffs, (buff) => {
if (buff && !buff.isStatic) {
retBuffs.push({
...buff,
title: `${sets.name}${num}` + buff.title
})
}
})
})
return retBuffs
},
// 武器Buff
getWeaponBuffs (wData, game = 'gs') {
let weapon = Weapon.get(wData.name, game)
if (!weapon) {
return false
}
let affix = wData.refine || wData.affix
let weaponCfg = weapon.getWeaponAffixBuffs(affix, false)
let ret = []
lodash.forEach(weaponCfg, (ds) => {
if (ds.isStatic) {
return true
}
ret.push(ds)
})
return ret
2022-08-22 20:53:31 +00:00
}
}
export default DmgBuffs