2022-06-11 14:10:53 +00:00
|
|
|
import { attrValue, attrNameMap, attrMap, mainAttr, subAttr, usefulAttr }
|
2022-07-30 20:20:10 +00:00
|
|
|
from '../../resources/meta/reliquaries/reliquaries-mark-new.js'
|
|
|
|
import { Character } from '../models.js'
|
|
|
|
import lodash from 'lodash'
|
|
|
|
import Format from '../Format.js'
|
|
|
|
import _Data from '../Data.js'
|
2022-08-07 22:14:24 +00:00
|
|
|
import Data from '../Data.js';
|
2022-06-29 20:40:06 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
let _path = process.cwd()
|
|
|
|
let artis = _Data.readJSON(`${_path}/plugins/miao-plugin/resources/meta/reliquaries/`, 'data.json') || {}
|
2022-06-29 20:40:06 +00:00
|
|
|
|
|
|
|
let artisMap = {}
|
|
|
|
|
|
|
|
lodash.forEach(artis, (ds) => {
|
2022-07-30 20:20:10 +00:00
|
|
|
artisMap[ds.name] = ds
|
2022-06-29 20:40:06 +00:00
|
|
|
})
|
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
let charCfg = {}
|
2022-06-25 23:45:43 +00:00
|
|
|
let Artifact = {
|
2022-07-30 20:20:10 +00:00
|
|
|
getCharCfg (name) {
|
2022-06-09 20:53:38 +00:00
|
|
|
if (charCfg[name]) {
|
|
|
|
return charCfg[name]
|
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
let attrWeight = usefulAttr[name] || { atk: 75, cp: 100, cd: 100 }
|
|
|
|
let attrMark = {}
|
2022-06-09 20:53:38 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
let char = Character.get(name)
|
2022-08-07 22:14:24 +00:00
|
|
|
let baseAttr = char?.lvStat?.detail['90'] || [400, 500, 300]
|
2022-06-09 20:53:38 +00:00
|
|
|
lodash.forEach(attrWeight, (weight, attr) => {
|
2022-07-30 20:20:10 +00:00
|
|
|
attrMark[attr] = weight / attrValue[attr]
|
|
|
|
})
|
2022-06-09 20:53:38 +00:00
|
|
|
|
|
|
|
// let baseAttr = [400, 500, 300];
|
|
|
|
if (attrMark.hp) {
|
2022-07-30 20:20:10 +00:00
|
|
|
attrMark.hpPlus = attrMark.hp / baseAttr[0] * 100
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
|
|
|
if (attrMark.atk) {
|
2022-06-25 23:51:19 +00:00
|
|
|
// 以520作为武器白值均值计算
|
2022-07-30 20:20:10 +00:00
|
|
|
attrMark.atkPlus = attrMark.atk / (baseAttr[1] * 1 + 520) * 100
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
|
|
|
if (attrMark.def) {
|
2022-07-30 20:20:10 +00:00
|
|
|
attrMark.defPlus = attrMark.def / baseAttr[2] * 100
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
let maxMark = Artifact.getMaxMark(attrWeight)
|
2022-08-07 22:14:24 +00:00
|
|
|
let titleMark = {}
|
|
|
|
let titleWeight = {}
|
2022-06-09 20:53:38 +00:00
|
|
|
lodash.forEach(attrMark, (mark, attr) => {
|
2022-07-30 20:20:10 +00:00
|
|
|
let aTitle = attrMap[attr].title
|
2022-06-11 14:10:53 +00:00
|
|
|
if (/小/.test(aTitle)) {
|
2022-07-30 20:20:10 +00:00
|
|
|
return
|
2022-06-11 14:10:53 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
titleMark[aTitle] = mark
|
|
|
|
titleWeight[aTitle] = attrWeight[attr] || 0
|
2022-06-11 14:10:53 +00:00
|
|
|
if (/大/.test(aTitle)) {
|
2022-07-30 20:20:10 +00:00
|
|
|
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
|
2022-07-30 20:20:10 +00:00
|
|
|
}
|
|
|
|
return charCfg[name]
|
2022-06-09 20:53:38 +00:00
|
|
|
},
|
2022-06-29 20:40:06 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
getMaxAttr (charAttr = {}, list2 = [], maxLen = 1, banAttr = '') {
|
|
|
|
let tmp = []
|
2022-06-09 20:53:38 +00:00
|
|
|
lodash.forEach(list2, (attr) => {
|
2022-07-30 20:20:10 +00:00
|
|
|
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)
|
2022-06-09 20:53:38 +00:00
|
|
|
},
|
2022-06-29 20:40:06 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
getMaxMark (attrWeight) {
|
|
|
|
let ret = {}
|
2022-06-09 20:53:38 +00:00
|
|
|
for (let idx = 1; idx <= 5; idx++) {
|
2022-08-07 22:14:24 +00:00
|
|
|
let totalMark = 0;
|
|
|
|
let mMark = 0
|
2022-07-30 20:20:10 +00:00
|
|
|
let mAttr = ''
|
2022-06-09 20:53:38 +00:00
|
|
|
if (idx === 1) {
|
2022-07-30 20:20:10 +00:00
|
|
|
mAttr = 'hpPlus'
|
2022-06-09 20:53:38 +00:00
|
|
|
} else if (idx === 2) {
|
2022-07-30 20:20:10 +00:00
|
|
|
mAttr = 'atkPlus'
|
2022-06-09 20:53:38 +00:00
|
|
|
} else if (idx >= 3) {
|
2022-07-30 20:20:10 +00:00
|
|
|
mAttr = Artifact.getMaxAttr(attrWeight, mainAttr[idx])[0]
|
|
|
|
mMark = attrWeight[mAttr]
|
|
|
|
totalMark += attrWeight[mAttr] * 2
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
|
|
|
|
2022-07-30 20:20:10 +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)
|
2022-07-30 20:20:10 +00:00
|
|
|
})
|
|
|
|
ret[idx] = totalMark
|
|
|
|
ret['m' + idx] = mMark
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
return ret
|
2022-06-09 20:53:38 +00:00
|
|
|
},
|
2022-06-29 20:40:06 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
getAttr (ds) {
|
2022-06-09 20:53:38 +00:00
|
|
|
let title = ds[0]
|
2022-07-30 20:20:10 +00:00
|
|
|
let attr = attrNameMap[title]
|
2022-06-09 20:53:38 +00:00
|
|
|
if (/元素伤害/.test(title)) {
|
2022-07-30 20:20:10 +00:00
|
|
|
attr = 'dmg'
|
2022-06-09 20:53:38 +00:00
|
|
|
} else if (/物理|物伤/.test(title)) {
|
2022-07-30 20:20:10 +00:00
|
|
|
attr = 'phy'
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
return attr
|
2022-06-09 20:53:38 +00:00
|
|
|
},
|
2022-06-29 20:40:06 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
getAttrMark (attrMark, ds) {
|
2022-06-09 20:53:38 +00:00
|
|
|
if (!ds || !ds[1]) {
|
2022-07-30 20:20:10 +00:00
|
|
|
return 0
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
let attr = Artifact.getAttr(ds)
|
|
|
|
let val = ds[1]
|
|
|
|
return (attrMark[attr] || 0) * val
|
2022-06-09 20:53:38 +00:00
|
|
|
},
|
2022-06-29 20:40:06 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
getMark (charCfg, posIdx, mainAttr, subAttr) {
|
|
|
|
let ret = 0
|
|
|
|
let { mark, maxMark, weight } = charCfg
|
|
|
|
let mAttr = Artifact.getAttr(mainAttr)
|
2022-06-09 20:53:38 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
let fixPct = 1
|
2022-06-09 20:53:38 +00:00
|
|
|
if (posIdx >= 3) {
|
2022-07-30 20:20:10 +00:00
|
|
|
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-07-30 20:20:10 +00:00
|
|
|
})
|
2022-06-09 20:53:38 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
return ret * (1 + fixPct) / 2 / maxMark[posIdx] * 66
|
2022-06-09 20:53:38 +00:00
|
|
|
},
|
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
getArtisMark (charName = '', artis = {}) {
|
|
|
|
let charCfg = Artifact.getCharCfg(charName)
|
2022-06-09 20:53:38 +00:00
|
|
|
let ret = {}
|
|
|
|
lodash.forEach(artis, (ds, idx) => {
|
2022-07-30 20:20:10 +00:00
|
|
|
idx = idx.replace('arti', '')
|
2022-06-25 23:45:43 +00:00
|
|
|
ret[idx] = Artifact.getMark(charCfg, idx, ds.main, ds.attrs)
|
2022-07-30 20:20:10 +00:00
|
|
|
})
|
|
|
|
return ret
|
2022-06-09 20:53:38 +00:00
|
|
|
},
|
2022-06-29 20:40:06 +00:00
|
|
|
|
2022-08-07 22:14:24 +00:00
|
|
|
getTotalMark (charName = '', artis) {
|
|
|
|
let artisMark = Artifact.getArtisMark(charName, artis)
|
|
|
|
let mark = 0
|
|
|
|
for (let k in artisMark) {
|
|
|
|
if (artisMark[k]) {
|
|
|
|
mark += artisMark[k]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let sets = {}
|
|
|
|
let setMap = {}
|
|
|
|
lodash.forEach(artis, (arti) => {
|
|
|
|
let setName = Artifact.getSetByArti(arti.name)?.name || 'N/A'
|
|
|
|
if (setName) {
|
|
|
|
sets[setName] = (sets[setName] || 0) + 1
|
|
|
|
}
|
|
|
|
})
|
|
|
|
for (let set in sets) {
|
|
|
|
if (sets[set] >= 4) {
|
|
|
|
setMap[set] = 4
|
|
|
|
} else if (sets[set] >= 2) {
|
|
|
|
setMap[set] = 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let setsRet = []
|
|
|
|
lodash.forEach(setMap, (v, k) => {
|
|
|
|
let name = Artifact.getArtiBySet(k)
|
|
|
|
if (name) {
|
|
|
|
setsRet.push(name)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return {
|
|
|
|
mark: (mark || 0).toFixed(1),
|
|
|
|
markClass: Artifact.getMarkClass(mark / 5),
|
|
|
|
sets: setsRet
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
getMarkClass (mark) {
|
|
|
|
let pct = mark
|
|
|
|
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]) {
|
2022-07-30 20:20:10 +00:00
|
|
|
return scoreMap[idx][0]
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2022-06-29 20:40:06 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
getSetByArti (name) {
|
2022-06-29 20:40:06 +00:00
|
|
|
for (let idx in artisMap) {
|
|
|
|
for (let idx2 in artisMap[idx].sets) {
|
|
|
|
if (artisMap[idx].sets[idx2].name === name) {
|
2022-07-30 20:20:10 +00:00
|
|
|
return artisMap[idx]
|
2022-06-29 20:40:06 +00:00
|
|
|
}
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
return false
|
2022-06-25 23:45:43 +00:00
|
|
|
},
|
2022-06-29 20:40:06 +00:00
|
|
|
|
2022-07-31 21:42:16 +00:00
|
|
|
getArtiBySet (name, idx = 1) {
|
|
|
|
let set = artisMap[name]
|
|
|
|
if (!set) {
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
return set.sets[`arti${idx}`].name
|
|
|
|
},
|
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
getMeta () {
|
2022-06-25 23:45:43 +00:00
|
|
|
return {
|
|
|
|
attrMap
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
formatArti (ds, markCfg = false, isMain = false) {
|
2022-06-25 23:45:43 +00:00
|
|
|
if (lodash.isArray(ds[0])) {
|
2022-07-30 20:20:10 +00:00
|
|
|
let ret = []
|
2022-06-25 23:45:43 +00:00
|
|
|
lodash.forEach(ds, (d) => {
|
2022-07-30 20:20:10 +00:00
|
|
|
ret.push(Artifact.formatArti(d, markCfg, isMain))
|
2022-06-25 23:45:43 +00:00
|
|
|
})
|
2022-07-30 20:20:10 +00:00
|
|
|
return ret
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
2022-08-07 22:14:24 +00:00
|
|
|
let title = ds[0];
|
|
|
|
let key = '';
|
|
|
|
let val = ds[1];
|
|
|
|
let num = ds[1]
|
2022-07-30 20:20:10 +00:00
|
|
|
if (!title || title === 'undefined') {
|
|
|
|
return []
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
|
|
|
if (/伤害加成/.test(title) && val < 1) {
|
2022-07-30 20:20:10 +00:00
|
|
|
val = Format.pct(val * 100)
|
|
|
|
num = num * 100
|
2022-06-25 23:45:43 +00:00
|
|
|
} else if (/伤害加成|大|暴|充能|治疗/.test(title)) {
|
2022-07-30 20:20:10 +00:00
|
|
|
val = Format.pct(val)
|
2022-06-25 23:45:43 +00:00
|
|
|
} else {
|
2022-07-30 20:20:10 +00:00
|
|
|
val = Format.comma(val, 1)
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (/元素伤害加成/.test(title)) {
|
2022-07-30 20:20:10 +00:00
|
|
|
title = title.replace('元素伤害', '伤')
|
|
|
|
key = 'dmg'
|
|
|
|
} else if (title === '物理伤害加成') {
|
|
|
|
title = '物伤加成'
|
|
|
|
key = 'phy'
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
key = key || attrNameMap[title]
|
2022-06-25 23:45:43 +00:00
|
|
|
|
2022-07-30 20:20:10 +00:00
|
|
|
let mark = markCfg[key] * num
|
2022-06-25 23:45:43 +00:00
|
|
|
if (markCfg) {
|
|
|
|
if (isMain) {
|
2022-07-30 20:20:10 +00:00
|
|
|
mark = mark / 4 + 0.01
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
mark = Format.comma(mark || 0)
|
2022-06-25 23:45:43 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
return { title, val, mark }
|
|
|
|
}
|
2022-06-09 20:53:38 +00:00
|
|
|
}
|
2022-07-30 20:20:10 +00:00
|
|
|
export default Artifact
|