From bc8fb2360a1ba276eeb1c364fc2d04235e878b5e Mon Sep 17 00:00:00 2001 From: yoimiya-kokomi <592981798@qq.com> Date: Mon, 25 Apr 2022 02:50:17 +0800 Subject: [PATCH] =?UTF-8?q?#=E8=A7=92=E8=89=B2=E8=AF=A6=E6=83=85=20?= =?UTF-8?q?=E4=BC=A4=E5=AE=B3=E8=AE=A1=E7=AE=97=E5=A2=9E=E5=8A=A0=E9=AD=88?= =?UTF-8?q?=E3=80=81=E8=83=A1=E6=A1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/character.js | 33 +++++----- components/Calc.js | 83 ++++++++++++++++++------- resources/meta/character/胡桃/calc.js | 28 +++++++++ resources/meta/character/魈/calc.js | 42 +++++++++++++ resources/meta/weapons/calc.js | 12 ++-- 5 files changed, 151 insertions(+), 47 deletions(-) create mode 100644 resources/meta/character/胡桃/calc.js create mode 100644 resources/meta/character/魈/calc.js diff --git a/apps/character.js b/apps/character.js index ef2d8614..66b8c492 100644 --- a/apps/character.js +++ b/apps/character.js @@ -585,26 +585,23 @@ export async function renderProfile(e, char, render) { let avatar = await getAvatar(e, char, MysApi); let talent = await getTalent(e, avatar); - if(!talent.id){ + + if (global.debugView === "web-debug") { + let file = process.cwd() + "/tools/avatar.json"; + avatar._talent = talent; + fs.writeFileSync(file, JSON.stringify(avatar)); + } + + if (!talent.id) { return true; } let posIdx = { - "生之花": { - idx: 1 - }, - "死之羽": { - idx: 2 - }, - "时之沙": { - idx: 3 - }, - "空之杯": { - idx: 4 - }, - "理之冠": { - idx: 5 - } + "生之花": { idx: 1 }, + "死之羽": { idx: 2 }, + "时之沙": { idx: 3 }, + "空之杯": { idx: 4 }, + "理之冠": { idx: 5 } }; let reliquaries = [], totalMark = 0, totalMaxMark = 0; @@ -635,8 +632,9 @@ export async function renderProfile(e, char, render) { } }); + let enemyLv = await selfUser.getCfg(`char.enemyLv`, 91); let dmgMsg = [], dmgData = []; - let dmgCalc = await Calc.calcData(profile, char, avatar, talent); + let dmgCalc = await Calc.calcData({ profile, char, avatar, talent, enemyLv }); if (dmgCalc && dmgCalc.ret) { lodash.forEach(dmgCalc.ret, (ds) => { ds.dmg = Format.comma(ds.dmg, 0); @@ -659,6 +657,7 @@ export async function renderProfile(e, char, render) { dmgData, dmgMsg, reliquaries, + enemyLv, totalMark: c(totalMark, 1), totalMaxMark, markScore: Reliquaries.getMarkScore(totalMark, totalMaxMark), diff --git a/components/Calc.js b/components/Calc.js index 67235adf..aa781215 100644 --- a/components/Calc.js +++ b/components/Calc.js @@ -1,7 +1,11 @@ import fs from "fs"; import lodash from "lodash"; import Format from "./Format.js"; -import {buffs} from "../resources/meta/reliquaries/calc.js"; + +const eleMap = { + Electro: "雷", + Pyro: "火" +} let Calc = { @@ -20,7 +24,7 @@ let Calc = { } if (details) { - return {details, buffs, defParams} + return { details, buffs, defParams } } return false; }, @@ -28,7 +32,7 @@ let Calc = { // 获取基础属性 attr(profile, avatar) { let ret = {}, - {attr} = profile; + { attr } = profile; // 基础属性 lodash.forEach("atk,def,hp".split(","), (key) => { @@ -47,7 +51,7 @@ let Calc = { } }) - lodash.forEach({cRate: "cpct", cDmg: "cdmg", hInc: "heal"}, (val, key) => { + lodash.forEach({ cRate: "cpct", cDmg: "cdmg", hInc: "heal" }, (val, key) => { ret[val] = { base: attr[key] * 1 || 0, plus: 0, @@ -83,9 +87,12 @@ let Calc = { } ret.weaponType = avatar.weapon.type_name; - ret.element = avatar.element; + ret.element = eleMap[avatar.element]; ret.refine = (avatar.weapon.affix_level * 1 - 1) || 0; + ret.zf = 0; + ret.rh = 0; + return ret; }, @@ -137,15 +144,28 @@ let Calc = { ...meta, attr, params, - refine: attr.refine + refine: attr.refine, + calc(ds) { + return (ds.base || 0) + (ds.plus || 0) + ((ds.base || 0) * (ds.pct || 0) / 100) + } }; // 如果存在rule,则进行计算 - if (buff.rule && !buff.rule(ds)) { + if (buff.check && !buff.check(ds)) { return; } let title = buff.title; + + if (buff.mastery) { + let mastery = attr.mastery.base + attr.mastery.plus; + let masteryNum = 2.78 * mastery / (mastery + 1400) * 100; + buff.data = buff.data || {}; + lodash.forEach(buff.mastery.split(","), (key) => { + buff.data[key] = masteryNum; + }) + } + lodash.forEach(buff.data, (val, key) => { if (lodash.isFunction(val)) { @@ -166,6 +186,11 @@ let Calc = { } if (key === "enemyDef") { attr.enemy.def += val * 1 || 0; + return; + } + + if (["zf", "rh"].includes(key)) { + attr[key] += val * 1 || 0; } }); msg.push(title); @@ -197,7 +222,7 @@ let Calc = { if (ds.refine) { ds.data = ds.data || {}; lodash.forEach(ds.refine, (r, key) => { - ds.data[key] = ({refine}) => r[refine] * (ds.buffCount || 1); + ds.data[key] = ({ refine }) => r[refine] * (ds.buffCount || 1); }) } }) @@ -236,7 +261,7 @@ let Calc = { }) return retBuffs; }, - async calcData(profile, char, avatar, talentData) { + async calcData({ profile, char, avatar, talentData }) { let charCalcData = await Calc.getCharCalcRule(char.name); //avatar.element; @@ -251,7 +276,7 @@ let Calc = { talent } - let {buffs, details, defParams} = charCalcData; + let { buffs, details, defParams } = charCalcData; defParams = defParams || {}; @@ -267,7 +292,7 @@ let Calc = { buffs = lodash.sortBy(buffs, ["sort"]); - let {msg} = Calc.calcAttr(originalAttr, buffs, meta, defParams || {}); + let { msg } = Calc.calcAttr(originalAttr, buffs, meta, defParams || {}); let ret = []; @@ -275,15 +300,15 @@ let Calc = { let params = lodash.merge({}, defParams, detail.params || {}); - let {attr} = Calc.calcAttr(originalAttr, buffs, meta, params); + let { attr } = Calc.calcAttr(originalAttr, buffs, meta, params); - let dmg = function (pctNum = 0, talent = false) { - let {atk, dmg, cdmg, cpct} = attr; + let dmg = function (pctNum = 0, talent = false, ele = false) { + let { atk, dmg, cdmg, cpct } = attr; // 攻击区 let atkNum = (atk.base + atk.plus + atk.base * atk.pct / 100); // 增伤区 - let dmgNum = (1 + dmg.base/100 + dmg.plus / 100); + let dmgNum = (1 + dmg.base / 100 + dmg.plus / 100); //console.log({ base: Format.comma(dmg.base, 2), plus: Format.comma(dmg.plus, 2) }) @@ -309,32 +334,42 @@ let Calc = { } // 防御区 - let enemyLv = 91, lv = 90; + let enemyLv = 86, lv = avatar.level; let defNum = (lv + 100) / ((lv + 100) + (enemyLv + 100) * (1 - enemyDef) * (1 - enemyIgnore)); // 抗性区 let kNum = 0.9; - // 计算最终伤害 - let ret = { - dmg: atkNum * pctNum * dmgNum * (1 + cdmgNum) * defNum * kNum, - avg: atkNum * pctNum * dmgNum * (1 + cpctNum * cdmgNum) * defNum * kNum + // 反应区 + let eleNum = 1; + if (ele) { + eleNum = { zf: 1.5, rh: 2 }[ele] || 1; + + + if (attr[ele]) { + eleNum = eleNum * (1 + attr[ele] / 100); + } } - //console.log(attr, {atkNum, pctNum, dmgNum, cpctNum, cdmgNum, defNum}, ret) - + // 计算最终伤害 + let ret = { + dmg: atkNum * pctNum * dmgNum * (1 + cdmgNum) * defNum * kNum * eleNum, + avg: atkNum * pctNum * dmgNum * (1 + cpctNum * cdmgNum) * defNum * kNum * eleNum + } + if (global.debugView === "web-debug") { + console.log(attr, { atkNum, pctNum, dmgNum, cpctNum, cdmgNum, defNum, eleNum }, ret) + } return ret; }; if (detail.dmg) { - let dmgRet = detail.dmg({attr, talent}, dmg); + let dmgRet = detail.dmg({ attr, talent }, dmg); ret.push({ title: detail.title, ...dmgRet }) } }) - return { ret, msg diff --git a/resources/meta/character/胡桃/calc.js b/resources/meta/character/胡桃/calc.js new file mode 100644 index 00000000..add071b7 --- /dev/null +++ b/resources/meta/character/胡桃/calc.js @@ -0,0 +1,28 @@ +export const details = [{ + title: "半血开E重击", + dmg: ({ talent, attr }, dmg) => dmg(talent.a["重击伤害"], "a2") +}, { + title: "半血开E重击蒸发", + dmg: ({ talent, attr }, dmg) => dmg(talent.a["重击伤害"], "a2", "zf") +}, { + title: "半血开E后Q", + dmg: ({ talent, attr }, dmg) => dmg(talent.q["低血量时技能伤害"], "q") +}]; + +export const buffs = [{ + title: `被动天赋:半血获得33%火伤加成`, + data: { + "dmg": 33 + } + +}, { + title: "元素精通:蒸发融化伤害提高[zf]%", + mastery: "zf,rh" +}, { + title: "胡桃E:获得[atkPlus]点攻击力加成", + data: { + atkPlus: ({ talent, attr, calc }) => { + return talent.e['攻击力提高'] * calc(attr.hp) / 100; + } + } +}]; \ No newline at end of file diff --git a/resources/meta/character/魈/calc.js b/resources/meta/character/魈/calc.js new file mode 100644 index 00000000..31091c2a --- /dev/null +++ b/resources/meta/character/魈/calc.js @@ -0,0 +1,42 @@ +export const details = [{ + title: "裸E", + dmg: ({ talent }, dmg) => dmg(talent.e["技能伤害"], "e") +}, { + title: "满层被动E", + params: { e: 1 }, + dmg: ({ talent }, dmg) => dmg(talent.e["技能伤害"], "e") +}, { + title: "开Q后首插", + params: { + layer: 1 + }, + dmg: ({ talent }, dmg) => dmg(talent.a["低空/高空坠地冲击伤害"][1], "a3") +}, { + title: "开Q后尾插", + params: { + layer: 5 + }, + dmg: ({ talent }, dmg) => dmg(talent.a["低空/高空坠地冲击伤害"][1], "a3") +}]; + + +export const defParams = { + layer: 0 +} + +export const buffs = [{ + title: `魈天赋:开Q后每3秒伤害提升5%,满层提高25%`, + data: { + dmg: ({ params }) => params.layer * 5 + } +}, { + title: "魈大招:下落攻击伤害提升[a3Dmg]%", + data: { + a3Dmg: ({ talent }) => talent.q['普通攻击/重击/下落攻击伤害提升'] + } +}, { + title: "魈被动:3层E使E的伤害提高45%", + data: { + eDmg: ({ params }) => params.e ? 45 : 0 + } +}]; \ No newline at end of file diff --git a/resources/meta/weapons/calc.js b/resources/meta/weapons/calc.js index 55464eb8..75ead86c 100644 --- a/resources/meta/weapons/calc.js +++ b/resources/meta/weapons/calc.js @@ -16,9 +16,9 @@ let polearm = { } }, "匣里灭辰": { - title: "对于水或或元素影响的敌人造成伤害提高[dmgPct]%", + title: "对于水或或元素影响的敌人造成伤害提高[dmg]%", refine: { - dmgPct: [20, 24, 28, 32, 36] + dmg: [20, 24, 28, 32, 36] } }, "千岩长枪": { @@ -68,10 +68,10 @@ let polearm = { } }, "和璞鸢": { - title: "满层攻击力提高[atkPct]%,伤害提升[dmgPct]%", + title: "满层攻击力提高[atkPct]%,伤害提升[dmg]%", refine: { atkPct: [3.2 * 7, 3.9 * 7, 4.6 * 7, 5.3 * 7, 6 * 7], - dmgPct: [12, 15, 18, 21, 24] + dmg: [12, 15, 18, 21, 24] } }, "天空之脊": { @@ -81,12 +81,12 @@ let polearm = { } }, "护摩之杖": { - title: "角色生命低于50%时获得攻击力提升[atkPlus]", + title: "角色生命低于50%时额外获得[atkPlus]攻击力", data: { atkPlus: ({ attr, refine }) => { let { hp } = attr, totalHp = hp.base + hp.plus + hp.pct * hp.base / 100; - return totalHp * [1, 1.2, 1.4, 1.6, 1.8][refine] / 100 + return totalHp * ([0.8, 1, 1.2, 1.4, 1.6][refine] + [1, 1.2, 1.4, 1.6, 1.8][refine]) / 100 } } },