2022-06-11 14:10:53 +00:00
|
|
|
import { attrValue, attrNameMap, attrMap, mainAttr, subAttr, usefulAttr }
|
|
|
|
from "../../resources/meta/reliquaries/reliquaries-mark-new.js";
|
2022-06-09 20:53:38 +00:00
|
|
|
import { Character } from "../models.js";
|
|
|
|
import lodash from "lodash";
|
2022-06-25 23:45:43 +00:00
|
|
|
import Format from "../Format.js";
|
2022-06-09 20:53:38 +00:00
|
|
|
|
|
|
|
let charCfg = {};
|
2022-06-25 23:45:43 +00:00
|
|
|
let Artifact = {
|
2022-06-09 20:53:38 +00:00
|
|
|
getCharCfg(name) {
|
|
|
|
if (charCfg[name]) {
|
|
|
|
return charCfg[name]
|
|
|
|
}
|
|
|
|
let attrWeight = usefulAttr[name] || { atk: 75, cp: 100, cd: 100 };
|
|
|
|
let attrMark = {};
|
|
|
|
|
|
|
|
let char = Character.get(name);
|
|
|
|
let baseAttr = char.lvStat.detail['90'];
|
|
|
|
lodash.forEach(attrWeight, (weight, attr) => {
|
|
|
|
attrMark[attr] = weight / attrValue[attr];
|
|
|
|
});
|
|
|
|
|
|
|
|
// let baseAttr = [400, 500, 300];
|
|
|
|
if (attrMark.hp) {
|
|
|
|
attrMark.hpPlus = attrMark.hp / baseAttr[0] * 100;
|
|
|
|
}
|
|
|
|
if (attrMark.atk) {
|
2022-06-25 23:51:19 +00:00
|
|
|
// 以520作为武器白值均值计算
|
|
|
|
attrMark.atkPlus = attrMark.atk / (baseAttr[1] * 1 + 520) * 100;
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
|
|
|
if (attrMark.def) {
|
|
|
|
attrMark.defPlus = attrMark.def / baseAttr[2] * 100;
|
|
|
|
}
|
2022-06-25 23:45:43 +00:00
|
|
|
let maxMark = Artifact.getMaxMark(attrWeight);
|
2022-06-09 20:53:38 +00:00
|
|
|
let titleMark = {}, titleWeight = {};
|
|
|
|
lodash.forEach(attrMark, (mark, attr) => {
|
2022-06-25 23:45:43 +00:00
|
|
|
let aTitle = attrMap[attr].title;
|
2022-06-11 14:10:53 +00:00
|
|
|
if (/小/.test(aTitle)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
titleMark[aTitle] = mark;
|
|
|
|
titleWeight[aTitle] = attrWeight[attr] || 0;
|
|
|
|
if (/大/.test(aTitle)) {
|
|
|
|
let sTitle = aTitle.replace("大", "小");
|
|
|
|
titleWeight[sTitle] = titleWeight[aTitle];
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
charCfg[name] = {
|
|
|
|
weight: attrWeight,
|
|
|
|
mark: attrMark,
|
|
|
|
titleMap: titleMark,
|
|
|
|
titleWeight,
|
|
|
|
maxMark
|
|
|
|
};
|
|
|
|
return charCfg[name];
|
|
|
|
},
|
|
|
|
getMaxAttr(charAttr = {}, list2 = [], maxLen = 1, banAttr = "") {
|
|
|
|
let tmp = [];
|
|
|
|
lodash.forEach(list2, (attr) => {
|
|
|
|
if (attr === banAttr) return;
|
|
|
|
if (!charAttr[attr]) return;
|
|
|
|
tmp.push({ attr, mark: charAttr[attr] });
|
|
|
|
});
|
|
|
|
tmp = lodash.sortBy(tmp, "mark");
|
|
|
|
tmp = tmp.reverse();
|
|
|
|
let ret = [];
|
|
|
|
lodash.forEach(tmp, (ds) => ret.push(ds.attr));
|
|
|
|
return ret.slice(0, maxLen);
|
|
|
|
},
|
|
|
|
getMaxMark(attrWeight) {
|
|
|
|
let ret = {};
|
|
|
|
for (let idx = 1; idx <= 5; idx++) {
|
|
|
|
let totalMark = 0, mMark = 0;
|
|
|
|
let mAttr = "";
|
|
|
|
if (idx === 1) {
|
|
|
|
mAttr = "hpPlus";
|
|
|
|
} else if (idx === 2) {
|
|
|
|
mAttr = "atkPlus";
|
|
|
|
} else if (idx >= 3) {
|
2022-06-25 23:45:43 +00:00
|
|
|
mAttr = Artifact.getMaxAttr(attrWeight, mainAttr[idx])[0];
|
2022-06-09 20:53:38 +00:00
|
|
|
mMark = attrWeight[mAttr];
|
|
|
|
totalMark += attrWeight[mAttr] * 2;
|
|
|
|
}
|
|
|
|
|
2022-06-25 23:45:43 +00:00
|
|
|
let sAttr = Artifact.getMaxAttr(attrWeight, subAttr, 4, mAttr);
|
2022-06-09 20:53:38 +00:00
|
|
|
lodash.forEach(sAttr, (attr, aIdx) => {
|
|
|
|
totalMark += attrWeight[attr] * (aIdx === 0 ? 6 : 1)
|
|
|
|
});
|
|
|
|
ret[idx] = totalMark;
|
|
|
|
ret['m' + idx] = mMark;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
},
|
|
|
|
getAttr(ds) {
|
|
|
|
let title = ds[0]
|
|
|
|
let attr = attrNameMap[title];
|
|
|
|
if (/元素伤害/.test(title)) {
|
|
|
|
attr = "dmg";
|
|
|
|
} else if (/物理|物伤/.test(title)) {
|
|
|
|
attr = "phy"
|
|
|
|
}
|
|
|
|
return attr;
|
|
|
|
},
|
|
|
|
getAttrMark(attrMark, ds) {
|
|
|
|
if (!ds || !ds[1]) {
|
|
|
|
return 0;
|
|
|
|
}
|
2022-06-25 23:45:43 +00:00
|
|
|
let attr = Artifact.getAttr(ds);
|
2022-06-09 20:53:38 +00:00
|
|
|
let val = ds[1];
|
|
|
|
return (attrMark[attr] || 0) * val;
|
|
|
|
},
|
|
|
|
getMark(charCfg, posIdx, mainAttr, subAttr) {
|
|
|
|
let ret = 0;
|
|
|
|
let { mark, maxMark, weight } = charCfg;
|
2022-06-25 23:45:43 +00:00
|
|
|
let mAttr = Artifact.getAttr(mainAttr);
|
2022-06-09 20:53:38 +00:00
|
|
|
|
|
|
|
let fixPct = 1;
|
|
|
|
if (posIdx >= 3) {
|
|
|
|
fixPct = Math.max(0, Math.min(1, (weight[mAttr] || 0) / (maxMark['m' + posIdx])));
|
2022-06-25 23:45:43 +00:00
|
|
|
ret += Artifact.getAttrMark(mark, mainAttr) / 4
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lodash.forEach(subAttr, (ds) => {
|
2022-06-25 23:45:43 +00:00
|
|
|
ret += Artifact.getAttrMark(mark, ds)
|
2022-06-09 20:53:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return ret * (1 + fixPct) / 2 / maxMark[posIdx] * 66;
|
|
|
|
},
|
|
|
|
|
|
|
|
getArtisMark(charName = "", artis = {}) {
|
|
|
|
let total = 0;
|
2022-06-25 23:45:43 +00:00
|
|
|
let charCfg = Artifact.getCharCfg(charName);
|
2022-06-09 20:53:38 +00:00
|
|
|
let ret = {}
|
|
|
|
lodash.forEach(artis, (ds, idx) => {
|
|
|
|
idx = idx.replace("arti", "");
|
2022-06-25 23:45:43 +00:00
|
|
|
ret[idx] = Artifact.getMark(charCfg, idx, ds.main, ds.attrs)
|
2022-06-09 20:53:38 +00:00
|
|
|
});
|
|
|
|
return ret;
|
|
|
|
},
|
2022-06-25 23:45:43 +00:00
|
|
|
getMarkClass(mark) {
|
2022-06-09 20:53:38 +00:00
|
|
|
let pct = mark;
|
2022-06-15 21:09:39 +00:00
|
|
|
let scoreMap = [["D", 10], ["C", 16.5], ["B", 23.1], ["A", 29.7], ["S", 36.3], ["SS", 42.9], ["SSS", 49.5], ["ACE", 56.1], ["ACE²", 66]];
|
2022-06-09 20:53:38 +00:00
|
|
|
for (let idx = 0; idx < scoreMap.length; idx++) {
|
|
|
|
if (pct < scoreMap[idx][1]) {
|
|
|
|
return scoreMap[idx][0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getSet(name) {
|
|
|
|
for (let idx in meta) {
|
|
|
|
if (meta[idx].name === name) {
|
|
|
|
return meta[idx];
|
|
|
|
}
|
|
|
|
}
|
2022-06-25 23:45:43 +00:00
|
|
|
},
|
|
|
|
getMeta() {
|
|
|
|
return {
|
|
|
|
attrMap
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
formatArti(ds, markCfg = false, isMain = false) {
|
|
|
|
if (lodash.isArray(ds[0])) {
|
|
|
|
let ret = [];
|
|
|
|
lodash.forEach(ds, (d) => {
|
|
|
|
ret.push(Artifact.formatArti(d, markCfg, isMain));
|
|
|
|
})
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
let title = ds[0], key = "", val = ds[1], num = ds[1];
|
|
|
|
if (!title || title === "undefined") {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
if (/伤害加成/.test(title) && val < 1) {
|
|
|
|
val = Format.pct(val * 100);
|
|
|
|
num = num * 100;
|
|
|
|
} else if (/伤害加成|大|暴|充能|治疗/.test(title)) {
|
|
|
|
val = Format.pct(val);
|
|
|
|
} else {
|
|
|
|
val = Format.comma(val, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (/元素伤害加成/.test(title)) {
|
|
|
|
title = title.replace("元素伤害", "伤");
|
|
|
|
key = "dmg";
|
|
|
|
} else if (title === "物理伤害加成") {
|
|
|
|
title = "物伤加成";
|
|
|
|
key = "phy";
|
|
|
|
}
|
|
|
|
|
|
|
|
key = key || attrNameMap[title];
|
|
|
|
|
|
|
|
let mark = markCfg[key] * num;
|
|
|
|
if (markCfg) {
|
|
|
|
if (isMain) {
|
|
|
|
mark = mark / 4 + 0.01;
|
|
|
|
}
|
|
|
|
mark = Format.comma(mark || 0);
|
|
|
|
}
|
|
|
|
return { title, val, mark };
|
|
|
|
},
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
2022-06-25 23:45:43 +00:00
|
|
|
export default Artifact;
|