添加原神风属性染色伤害计算支持

This commit is contained in:
restid 2024-11-05 00:19:37 +08:00
parent 59c9c5f5e3
commit 7829b88ec7
5 changed files with 64 additions and 7 deletions

View File

@ -316,6 +316,14 @@ export default class Avatar extends Base {
} }
let attr = this._attr = this._attr || Attr.create(this) let attr = this._attr = this._attr || Attr.create(this)
this.attr = attr.calc() this.attr = attr.calc()
if (this.game === 'gs') {
let artisMain = this.artis?.artis['4']?.main || {}
for (let key of ['pyro', 'hydro', 'electro', 'cryo'])
if (artisMain.key === key)
this.attr[key] = artisMain.value
else
this.attr[key] = 0
}
this.base = attr.getBase() this.base = attr.getBase()
} }

View File

@ -56,6 +56,23 @@ let DmgAttr = {
} }
}) })
if (game === 'gs')
lodash.forEach('pyro,hydro,electro,cryo'.split(','), (key) => {
ret[key] = ret[key] || {
pct: 0, // 倍率加成
multi: 0, // 独立倍率乘区加成宵宫E等
plus: 0, // 伤害值提高
dmg: attr[key] || 0, // 伤害提高
enemydmg: 0, // 承受伤害提高
cpct: 0, // 暴击提高
cdmg: 0, // 爆伤提高
def: 0, // 防御降低
ignore: 0 // 无视防御
}
})
ret.enemy = ret.enemy || { ret.enemy = ret.enemy || {
def: 0, // 降低防御 def: 0, // 降低防御
ignore: 0, // 无视防御 ignore: 0, // 无视防御
@ -198,7 +215,7 @@ let DmgAttr = {
title = title.replace(`[${key}]`, Format.comma(val, 1)) title = title.replace(`[${key}]`, Format.comma(val, 1))
// 技能提高 // 技能提高
let tRet = /^(a|a2|a3|e|q|t|dot|break)(Def|Ignore|Dmg|Enemydmg|Plus|Pct|Cpct|Cdmg|Multi)$/.exec(key) let tRet = /^(a|a2|a3|e|q|t|dot|break|pyro|electro|cryo|hydro)(Def|Ignore|Dmg|Enemydmg|Plus|Pct|Cpct|Cdmg|Multi)$/.exec(key)
if (tRet) { if (tRet) {
attr[tRet[1]][tRet[2].toLowerCase()] += val * 1 || 0 attr[tRet[1]][tRet[2].toLowerCase()] += val * 1 || 0
return return

View File

@ -70,18 +70,31 @@ let DmgBuffs = {
// 圣遗物Buff // 圣遗物Buff
getArtisBuffs (artis = {}, game = 'gs') { getArtisBuffs (artis = {}, game = 'gs') {
let retBuffs = [] let retBuffs = []
const elemMap = { '雷': 'electro', '火': 'pyro', '冰': 'cryo', '水': 'hydro' }
ArtifactSet.eachSet(artis, (sets, num) => { ArtifactSet.eachSet(artis, (sets, num) => {
let buffs = ArtifactSet.getArtisSetBuff(sets.name, num, game) let buffs = ArtifactSet.getArtisSetBuff(sets.name, num, game)
if (lodash.isPlainObject(buffs)) { if (lodash.isPlainObject(buffs)) {
buffs = [buffs] buffs = [buffs]
} }
lodash.forEach(buffs, (buff) => { lodash.forEach(buffs, (buff) => {
if (buff && !buff.isStatic) { if (!buff) return
if (!buff.isStatic) {
retBuffs.push({ retBuffs.push({
...buff, ...buff,
title: `${sets.name}${num}` + buff.title title: `${sets.name}${num}` + buff.title
}) })
} }
else if (buff.elem in elemMap) {
let elebuff = lodash.cloneDeep(buff)
elebuff.data[`${elemMap[buff.elem]}Dmg`] = buff.data.dmg
delete elebuff.isStatic
delete elebuff.data.dmg
delete elebuff.elem
retBuffs.push({
...elebuff,
title: `${sets.name}${num}${buff.elem}` + elebuff.title
})
}
}) })
}) })
return retBuffs return retBuffs

View File

@ -46,6 +46,10 @@ let DmgCalc = {
if (ele === 'phy') { if (ele === 'phy') {
dmgNum = (1 + phy.base / 100 + phy.plus / 100 + dynamicPhy / 100) dmgNum = (1 + phy.base / 100 + phy.plus / 100 + dynamicPhy / 100)
} }
else if (game === 'gs' && talent)
for (let key of ['pyro', 'hydro', 'electro', 'cryo'])
if (talent.includes(key))
dmgNum = 1
// 易伤区 // 易伤区
let enemydmgNum = 1 let enemydmgNum = 1
@ -130,7 +134,13 @@ let DmgCalc = {
let eleNum = 1 let eleNum = 1
let eleBase = 1 let eleBase = 1
if (game === 'gs') { if (game === 'gs') {
eleNum = isEle ? DmgMastery.getBasePct(ele, attr.element) : 1 let reactionElement = attr.element
const eleMap = { pyro: '火', hydro: '水', electro: '雷', cryo: '冰' }
Object.keys(eleMap).forEach(key => {
if (talent.includes(key)) reactionElement = eleMap[key];
})
eleNum = isEle ? DmgMastery.getBasePct(ele, reactionElement) : 1
eleBase = isEle ? 1 + attr[ele] / 100 + DmgMastery.getMultiple(ele, calc(attr.mastery)) : 1 eleBase = isEle ? 1 + attr[ele] / 100 + DmgMastery.getMultiple(ele, calc(attr.mastery)) : 1
} }
@ -267,6 +277,15 @@ let DmgCalc = {
// 星铁meta数据天赋为百分比前数字 // 星铁meta数据天赋为百分比前数字
pctNum = pctNum * 100 pctNum = pctNum * 100
} }
if (game === 'gs' && talent.includes('color')) {
let dmgRet = { max: 1e8, avg: 1e8 }
for (let key of ['pyro', 'hydro', 'electro', 'cryo']) {
let newTalent = talent.replace('color', key)
let dmgTmp = DmgCalc.calcRet({ pctNum, talent: newTalent, ele, basicNum, mode, dynamicData }, data)
if (dmgTmp.avg < dmgRet.avg) dmgRet = dmgTmp
}
return dmgRet
}
return DmgCalc.calcRet({ pctNum, talent, ele, basicNum, mode, dynamicData }, data) return DmgCalc.calcRet({ pctNum, talent, ele, basicNum, mode, dynamicData }, data)
} }

View File

@ -1,14 +1,14 @@
const attr = function (key, val, elem = '', unit = '%') { const attr = function (key, val, elem = '', unit = '%') {
const keyMap = { const keyMap = {
hp: '生命值', hpPct: '生命值',
hpPlus: '生命值', hpPlus: '生命值',
atk: '攻击力', atkPct: '攻击力',
def: '防御力', defPct: '防御力',
cpct: '暴击率', cpct: '暴击率',
dmg: '元素伤害', dmg: '元素伤害',
phy: '物理伤害', phy: '物理伤害',
shield: '护盾强效', shield: '护盾强效',
heal: '治疗', heal: '治疗加成',
mastery: '元素精通' mastery: '元素精通'
} }
let ret = { let ret = {