* #角色面板 新增 钟离 的伤害计算

* #角色面板支持对治疗量、护盾量的计算与展示
* #角色面板修复冰融化、少女4等buff等buff遗漏或错误导致的伤害计算偏差
This commit is contained in:
yoimiya-kokomi 2022-05-03 06:32:36 +08:00
parent 177563a442
commit 48e1588af8
7 changed files with 138 additions and 51 deletions

View File

@ -1,9 +1,11 @@
# 1.3.1 # 1.3.2
* `#角色面板` 伤害计算新增部分角色 * `#角色面板` 伤害计算新增部分角色
* 目前支持:雷神、胡桃、魈、神子、甘雨、宵宫、公子、绫人、绫华、心海 * 目前支持:雷神、胡桃、魈、神子、甘雨、宵宫、公子、绫人、绫华、心海、钟离
* `#角色面板` 一些功能升级与调整
* 支持对治疗量、护盾量的计算与展示
* 修复冰融化、少女4等buff等buff遗漏或错误导致的伤害计算偏差
* `#老婆` 功能支持对jpeg格式的图片格式识别 * `#老婆` 功能支持对jpeg格式的图片格式识别
* 修复冰融化、少女4等buff等buff遗漏或错误导致的数据计算问题
# 1.3.0 # 1.3.0

View File

@ -77,7 +77,7 @@ let Calc = {
base: attr[key] * 1 || 0, base: attr[key] * 1 || 0,
plus: 0, plus: 0,
pct: 0, pct: 0,
inc: 0 inc: 100
} }
}) })
@ -89,7 +89,7 @@ let Calc = {
} }
}) })
// a // 技能属性记录
lodash.forEach("a,a2,a3,e,q".split(","), (key) => { lodash.forEach("a,a2,a3,e,q".split(","), (key) => {
ret[key] = { ret[key] = {
pct: 0, // 倍率加成 pct: 0, // 倍率加成
@ -111,6 +111,12 @@ let Calc = {
phy: 0 // 物理防御 phy: 0 // 物理防御
} }
ret.shield = {
base: 100, // 基础
plus: 0, // 护盾强效
inc: 100, // 吸收倍率
}
ret.weaponType = avatar.weapon.type_name; ret.weaponType = avatar.weapon.type_name;
ret.element = eleMap[avatar.element]; ret.element = eleMap[avatar.element];
ret.refine = (avatar.weapon.affix_level * 1 - 1) || 0; ret.refine = (avatar.weapon.affix_level * 1 - 1) || 0;
@ -179,7 +185,7 @@ let Calc = {
} }
}, },
calcAttr(originalAttr, buffs, meta, params = {}, incAttr = '', reduceAttr = '') { calcAttr({ originalAttr, buffs, meta, params = {}, incAttr = '', reduceAttr = '', talent = '' }) {
let attr = lodash.merge({}, originalAttr); let attr = lodash.merge({}, originalAttr);
let msg = []; let msg = [];
@ -195,6 +201,8 @@ let Calc = {
lodash.forEach(buffs, (buff) => { lodash.forEach(buffs, (buff) => {
let ds = Calc.getDs(attr, meta, params); let ds = Calc.getDs(attr, meta, params);
ds.currentTalent = talent;
// 如果存在rule则进行计算 // 如果存在rule则进行计算
if (buff.check && !buff.check(ds)) { if (buff.check && !buff.check(ds)) {
return; return;
@ -229,7 +237,7 @@ let Calc = {
attr[tRet[1]][tRet[2].toLowerCase()] += val * 1 || 0; attr[tRet[1]][tRet[2].toLowerCase()] += val * 1 || 0;
return; return;
} }
let aRet = /^(hp|def|atk|mastery|cpct|cdmg|heal|recharge|dmg|phy)(Plus|Pct|Inc)?$/.exec(key); let aRet = /^(hp|def|atk|mastery|cpct|cdmg|heal|recharge|dmg|phy|shield)(Plus|Pct|Inc)?$/.exec(key);
if (aRet) { if (aRet) {
attr[aRet[1]][aRet[2] ? aRet[2].toLowerCase() : "plus"] += val * 1 || 0; attr[aRet[1]][aRet[2] ? aRet[2].toLowerCase() : "plus"] += val * 1 || 0;
return; return;
@ -269,7 +277,7 @@ let Calc = {
lodash.forEach(weaponCfg, (ds) => { lodash.forEach(weaponCfg, (ds) => {
if (!//.test(ds.title)) { if (!//.test(ds.title)) {
ds.title = `${weaponName}效果${ds.title}`; ds.title = `${weaponName}${ds.title}`;
} }
if (ds.refine) { if (ds.refine) {
ds.data = ds.data || {}; ds.data = ds.data || {};
@ -314,12 +322,14 @@ let Calc = {
return retBuffs; return retBuffs;
}, },
getDmgFn({ attr, avatar, enemyLv }) { getDmgFn({ ds, attr, avatar, enemyLv, showDetail = false }) {
return function (pctNum = 0, talent = false, ele = false) { let { calc } = ds;
let dmgFn = function (pctNum = 0, talent = false, ele = false, mode = "talent") {
let { atk, dmg, cdmg, cpct } = attr; let { atk, dmg, cdmg, cpct } = attr;
// 攻击区 // 攻击区
let atkNum = (atk.base + atk.plus + atk.base * atk.pct / 100); let atkNum = calc(atk);
// 倍率独立乘区 // 倍率独立乘区
@ -391,7 +401,7 @@ let Calc = {
} }
let ret = {}; let ret = {};
if (talent === "dmgRet") { if (mode === "basic") {
ret = { ret = {
dmg: pctNum * dmgNum * (1 + cdmgNum) * defNum * kNum * eleNum, dmg: pctNum * dmgNum * (1 + cdmgNum) * defNum * kNum * eleNum,
avg: pctNum * dmgNum * (1 + cpctNum * cdmgNum) * defNum * kNum * eleNum avg: pctNum * dmgNum * (1 + cpctNum * cdmgNum) * defNum * kNum * eleNum
@ -404,10 +414,30 @@ let Calc = {
} }
} }
// console.log(attr, { atkNum, pctNum, multiNum, plusNum, dmgNum, cpctNum, cdmgNum, defNum, eleNum, kNum }, ret) if (showDetail) {
console.log(attr, { atkNum, pctNum, multiNum, plusNum, dmgNum, cpctNum, cdmgNum, defNum, eleNum, kNum }, ret)
}
return ret; return ret;
}; };
dmgFn.basic = function (pctNum = 0, talent = false, ele = false) {
return dmgFn(pctNum, talent, ele, "basic");
}
dmgFn.heal = function (num) {
return {
avg: num * (1 + calc(attr.heal) / 100) * (attr.heal.inc / 100)
}
}
dmgFn.shield = function (num) {
return {
avg: num * (calc(attr.shield) / 100) * (attr.shield.inc / 100)
};
}
return dmgFn;
}, },
@ -442,31 +472,27 @@ let Calc = {
buffs = lodash.sortBy(buffs, ["sort"]); buffs = lodash.sortBy(buffs, ["sort"]);
let { msg } = Calc.calcAttr(originalAttr, buffs, meta, defParams || {}); let { msg } = Calc.calcAttr({ originalAttr, buffs, meta, params: defParams || {} });
let ret = [], detailMap = [], dmgRet = [], dmgDetail = {}; let ret = [], detailMap = [], dmgRet = [], dmgDetail = {};
lodash.forEach(details, (detail, detailSysIdx) => { lodash.forEach(details, (detail, detailSysIdx) => {
let params = lodash.merge({}, defParams, detail.params || {}); let params = lodash.merge({}, defParams, detail.params || {});
let { attr } = Calc.calcAttr(originalAttr, buffs, meta, params); let { attr } = Calc.calcAttr({ originalAttr, buffs, meta, params, talent: detail.talent || "" });
if (detail.check && !detail.check(Calc.getDs(attr, meta, params))) { if (detail.check && !detail.check(Calc.getDs(attr, meta, params))) {
return; return;
} }
if (detail.cons && meta.cons * 1 < detail.cons * 1) { if (detail.cons && meta.cons * 1 < detail.cons * 1) {
return; return;
} }
let dmg = Calc.getDmgFn({ attr, avatar, enemyLv }),
basicDmgRet;
let ds = lodash.merge({ talent }, Calc.getDs(attr, meta, params)); let ds = lodash.merge({ talent }, Calc.getDs(attr, meta, params));
if (detail.dmg || detail.heal) { let dmg = Calc.getDmgFn({ ds, attr, avatar, enemyLv, showDetail: detail.showDetail }),
basicDmgRet = detail.dmg ? detail.dmg(ds, dmg) : detail.heal(ds, function (num) { basicDmgRet;
let { attr, calc } = ds;
return { if (detail.dmg) {
avg: num * (1 + calc(attr.heal) / 100) * (1 + attr.heal.inc / 100) basicDmgRet = detail.dmg(ds, dmg);
}
});
detail.userIdx = detailMap.length; detail.userIdx = detailMap.length;
detailMap.push(detail); detailMap.push(detail);
ret.push({ ret.push({
@ -505,17 +531,19 @@ let Calc = {
rowData.push({ type: 'na' }); rowData.push({ type: 'na' });
return; return;
} }
let { attr } = Calc.calcAttr(originalAttr, buffs, meta, params, incAttr, reduceAttr); let { attr } = Calc.calcAttr({
let dmg = Calc.getDmgFn({ attr, avatar, enemyLv }); originalAttr,
buffs,
meta,
params,
incAttr,
reduceAttr,
talent: detail.talent || ""
});
let ds = lodash.merge({ talent }, Calc.getDs(attr, meta, params)); let ds = lodash.merge({ talent }, Calc.getDs(attr, meta, params));
let dmg = Calc.getDmgFn({ ds, attr, avatar, enemyLv });
if (detail.dmg || detail.heal) { if (detail.dmg) {
let dmgCalcRet = detail.dmg ? detail.dmg(ds, dmg) : detail.heal(ds, function (num) { let dmgCalcRet = detail.dmg(ds, dmg);
let { attr, calc } = ds;
return {
avg: num * (1 + calc(attr.heal) / 100) * (1 + attr.heal.inc / 100)
}
});
rowData.push({ rowData.push({
type: dmgCalcRet.avg === basicDmg.avg ? "avg" : (dmgCalcRet.avg > basicDmg.avg ? "gt" : "lt"), type: dmgCalcRet.avg === basicDmg.avg ? "avg" : (dmgCalcRet.avg > basicDmg.avg ? "gt" : "lt"),
...dmgCalcRet ...dmgCalcRet

View File

@ -3,14 +3,14 @@ import lodash from "lodash";
export const details = [{ export const details = [{
check: ({ cons }) => cons < 2, check: ({ cons }) => cons < 2,
title: "水母每跳治疗", title: "水母每跳治疗",
heal: ({ attr, talent, calc }, heal) => { dmg: ({ attr, talent, calc }, { heal }) => {
let t = talent.e['治疗量2'], hp = calc(attr.hp); let t = talent.e['治疗量2'], hp = calc(attr.hp);
return heal(hp * t[0] / 100 + t[1] * 1); return heal(hp * t[0] / 100 + t[1] * 1);
} }
}, { }, {
cons: 2, cons: 2,
title: "半血水母每跳治疗", title: "半血水母每跳治疗",
heal: ({ attr, talent, calc }, heal) => { dmg: ({ attr, talent, calc }, { heal }) => {
let t = talent.e['治疗量2'], hp = calc(attr.hp); let t = talent.e['治疗量2'], hp = calc(attr.hp);
return heal(hp * t[0] / 100 + t[1] * 1 + hp * 0.045); return heal(hp * t[0] / 100 + t[1] * 1 + hp * 0.045);
} }
@ -25,12 +25,12 @@ export const details = [{
dmg: ({ attr, talent, cons, calc }, dmg) => { dmg: ({ attr, talent, cons, calc }, dmg) => {
let ret = { dmg: 0, avg: 0 }; let ret = { dmg: 0, avg: 0 };
lodash.forEach('一二三'.split(""), (num) => { lodash.forEach('一二三'.split(""), (num) => {
let dmgRet = dmg(talent.a['三段伤害'], 'a'); let dmgRet = dmg(talent.a[`${num}段伤害`], 'a');
ret.dmg += dmgRet.dmg; ret.dmg += dmgRet.dmg;
ret.avg += dmgRet.avg; ret.avg += dmgRet.avg;
}); });
if (cons > 0) { if (cons > 0) {
let dmgRet = dmg(calc(attr.hp) * 0.3, 'dmgRet'); let dmgRet = dmg.basic(calc(attr.hp) * 0.3);
ret.dmg += dmgRet.dmg; ret.dmg += dmgRet.dmg;
ret.avg += dmgRet.avg; ret.avg += dmgRet.avg;
} }

View File

@ -19,6 +19,12 @@ export const defDmgIdx = 2;
export const mainAttr = "atk,cpct,cdmg,mastery"; export const mainAttr = "atk,cpct,cdmg,mastery";
export const buffs = [{ export const buffs = [{
cons: 1,
title: "甘雨被动霜华矢发射后的5秒内霜华矢暴击率提高20%",
data: {
a2Cpct: 20
}
}, {
cons: 1, cons: 1,
title: "甘雨1命霜华失命中减少敌人15%冰抗", title: "甘雨1命霜华失命中减少敌人15%冰抗",
data: { data: {

View File

@ -0,0 +1,39 @@
export const details = [{
title: "玉璋护盾量",
talent: "e",
dmg: ({ attr, calc, talent }, { shield }) => shield(talent.e['护盾基础吸收量'] + calc(attr.hp) * talent.e['护盾附加吸收量'] / 100)
}, {
title: "共鸣伤害",
talent: "e",
dmg: ({ talent }, dmg) => dmg(talent.e['岩脊伤害/共鸣伤害'][1], 'e') // 6856
}, {
title: "天星伤害",
talent: "q",
dmg: ({ talent }, dmg) => dmg(talent.q['技能伤害'], 'q')
}];
export const defDmgIdx = 2;
export const mainAttr = "hp,atk,cpct,cdmg";
export const buffs = [{
title: "钟离被动满层Buff下护盾强效提高25%",
data: {
shield: 25
}
}, {
title: "岩系护盾岩系护盾吸收效率150%",
data: {
shieldInc: 50
}
}, {
title: "钟离被动:基于生命值上限,共鸣伤害提高[ePlus],天星伤害提高[qPlus]",
data: {
ePlus: ({ attr, calc }) => calc(attr.hp) * 0.019,
qPlus: ({ attr, calc }) => calc(attr.hp) * 0.33
}
}, {
title: "玉璋护盾降低敌人全抗性20%",
data: {
kx: 20
}
}];

View File

@ -87,6 +87,7 @@ export const buffs = {
}, },
"昔日宗室之仪4": { "昔日宗室之仪4": {
title: "宗室4施放元素爆发后攻击力提升20%", title: "宗室4施放元素爆发后攻击力提升20%",
check: ({ currentTalent }) => !currentTalent || currentTalent === "q",
data: { data: {
atkPct: 20 atkPct: 20
} }

View File

@ -73,13 +73,18 @@ let polearm = {
title: "满层元素爆发伤害提高[qDmg]%", title: "满层元素爆发伤害提高[qDmg]%",
refine: { qDmg: step(40) } refine: { qDmg: step(40) }
}, },
"贯虹之槊": { "贯虹之槊": [{
title: "护盾满层状态提高攻击力[atkPct]%", title: "护盾满层状态提高攻击力[atkPct]%",
buffCount: 10, buffCount: 10,
refine: { refine: {
atkPct: step(4) atkPct: step(4)
} }
}, }, {
title: "护盾强效提高[shield]%",
refine: {
shield: step(20)
}
}],
"和璞鸢": { "和璞鸢": {
title: "满层攻击力提高[atkPct]%,伤害提升[dmg]%", title: "满层攻击力提高[atkPct]%,伤害提升[dmg]%",
refine: { refine: {
@ -88,9 +93,9 @@ let polearm = {
} }
}, },
"天空之脊": { "天空之脊": {
title: "暴击率提升[cpct]%", title: "暴击率提升[_cpct]%",
refine: { refine: {
cpct: step(8) _cpct: step(8)
} }
}, },
"护摩之杖": { "护摩之杖": {
@ -214,13 +219,19 @@ let catalyst = {
dmg: step(12) dmg: step(12)
} }
}, },
"尘世之锁": { "尘世之锁": [{
title: "护盾强效提升[shield]%",
refine: {
shield: step(20)
}
}, {
title: "护盾+满层情况下攻击力提高[atkPct]%", title: "护盾+满层情况下攻击力提高[atkPct]%",
buffCount: 10, buffCount: 10,
refine: { refine: {
atkPct: step(4) atkPct: step(4),
shield: step(20)
} }
}, }],
"不灭月华": { "不灭月华": {
title: "治疗加成提高[_heal]%,普攻伤害增加[aPlus]", title: "治疗加成提高[_heal]%,普攻伤害增加[aPlus]",
refine: { refine: {
@ -386,9 +397,9 @@ let bow = {
} }
}], }],
"天空之翼": { "天空之翼": {
title: "暴击伤害提高[cdmg]%", title: "暴击伤害提高20%",
refine: { refine: {
cdmg: step(20) //cdmg: step(20)
} }
}, },
"若水": { "若水": {
@ -547,9 +558,9 @@ let sword = {
} }
}], }],
"斫峰之刃": [{ "斫峰之刃": [{
title: "护盾强效提升[shild]%", title: "护盾强效提升[shield]%",
refine: { refine: {
shild: step(20) shield: step(20)
} }
}, { }, {
title: "满Buff提高攻击力[atkPct]%", title: "满Buff提高攻击力[atkPct]%",
@ -559,9 +570,9 @@ let sword = {
} }
}], }],
"天空之刃": [{ "天空之刃": [{
title: "暴击率提高[cpct]%", title: "暴击率提高[_cpct]%",
refine: { refine: {
cpct: step(4) _cpct: step(4)
} }
}, { }, {
title: "普攻与重击的伤害值提高[aPlus]", title: "普攻与重击的伤害值提高[aPlus]",