2022-08-18 10:13:42 +00:00
|
|
|
import lodash from 'lodash'
|
2023-03-27 20:02:49 +00:00
|
|
|
import { Format } from '#miao'
|
2023-05-16 19:15:00 +00:00
|
|
|
import { attrNameMap, mainAttr, subAttr, attrMap } from '../../resources/meta/artifact/index.js'
|
|
|
|
import {
|
|
|
|
attrMap as attrMapSR
|
|
|
|
} from '../../resources/meta-sr/artifact/meta.js'
|
2022-08-18 10:13:42 +00:00
|
|
|
|
|
|
|
let ArtisMark = {
|
2022-11-23 20:26:07 +00:00
|
|
|
// 根据Key获取标题
|
2023-05-16 19:15:00 +00:00
|
|
|
getKeyByTitle (title, dmg = false, game = 'gs') {
|
2023-02-09 18:54:51 +00:00
|
|
|
if (/元素伤害加成/.test(title) || Format.isElem(title)) {
|
2022-11-24 15:27:03 +00:00
|
|
|
let elem = Format.matchElem(title)
|
2022-11-23 20:26:07 +00:00
|
|
|
return dmg ? 'dmg' : elem
|
|
|
|
} else if (title === '物理伤害加成') {
|
|
|
|
return 'phy'
|
|
|
|
}
|
2023-05-16 19:15:00 +00:00
|
|
|
return (game === 'gs' ? attrNameMap : attrNameMapSR)[title]
|
2022-11-23 20:26:07 +00:00
|
|
|
},
|
|
|
|
|
2023-05-16 19:15:00 +00:00
|
|
|
getKeyTitleMap (game = 'gs') {
|
2022-11-23 20:26:07 +00:00
|
|
|
let ret = {}
|
|
|
|
lodash.forEach(attrMap, (ds, key) => {
|
|
|
|
ret[key] = ds.title
|
|
|
|
})
|
2022-11-24 15:27:03 +00:00
|
|
|
Format.eachElem((key, name) => {
|
2022-11-23 20:26:07 +00:00
|
|
|
ret[key] = `${name}伤加成`
|
2023-05-16 19:15:00 +00:00
|
|
|
}, game)
|
2022-11-23 20:26:07 +00:00
|
|
|
return ret
|
|
|
|
},
|
|
|
|
|
2022-08-18 10:13:42 +00:00
|
|
|
formatAttr (ds) {
|
|
|
|
if (!ds) {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
if (lodash.isArray(ds) && ds[0] && ds[1]) {
|
|
|
|
return {
|
2022-11-23 20:26:07 +00:00
|
|
|
key: ArtisMark.getKeyByTitle(ds[0]),
|
2022-08-18 10:13:42 +00:00
|
|
|
value: ds[1]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!ds.value) {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
return {
|
2022-11-23 20:26:07 +00:00
|
|
|
key: ds.key || ArtisMark.getKeyByTitle(ds.title || ds.name || ds.key || ds.id || ''),
|
2022-08-18 10:13:42 +00:00
|
|
|
value: ds.value || ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-11-14 12:52:16 +00:00
|
|
|
/**
|
|
|
|
* 格式化圣遗物词条
|
|
|
|
* @param ds
|
2023-05-16 19:15:00 +00:00
|
|
|
* @param charAttrCfg
|
2022-11-14 12:52:16 +00:00
|
|
|
* @param isMain
|
|
|
|
* @returns {{title: *, value: string}|*[]}
|
|
|
|
*/
|
2023-05-16 19:15:00 +00:00
|
|
|
formatArti (ds, charAttrCfg = false, isMain = false, game = 'gs') {
|
2022-11-23 20:26:07 +00:00
|
|
|
// 若为attr数组
|
|
|
|
if (ds[0] && (ds[0].title || ds[0].key)) {
|
2022-08-18 10:13:42 +00:00
|
|
|
let ret = []
|
2022-11-14 17:10:52 +00:00
|
|
|
let totalUpNum = 0
|
|
|
|
let ltArr = []
|
2023-02-11 19:51:50 +00:00
|
|
|
let isIdAttr = false
|
|
|
|
|
2022-08-18 10:13:42 +00:00
|
|
|
lodash.forEach(ds, (d) => {
|
2023-02-21 19:49:49 +00:00
|
|
|
isIdAttr = !d.isCalcNum
|
2023-05-16 19:15:00 +00:00
|
|
|
let arti = ArtisMark.formatArti(d, charAttrCfg, isMain, game)
|
2023-02-11 19:51:50 +00:00
|
|
|
ret.push(arti)
|
|
|
|
if (isIdAttr) {
|
|
|
|
return true
|
|
|
|
}
|
2022-11-14 17:10:52 +00:00
|
|
|
totalUpNum += arti.upNum
|
|
|
|
if (arti.hasLt) {
|
|
|
|
ltArr.push(arti)
|
|
|
|
}
|
|
|
|
delete arti.hasLt
|
|
|
|
delete arti.hasGt
|
2022-08-18 10:13:42 +00:00
|
|
|
})
|
2023-02-11 19:51:50 +00:00
|
|
|
if (!isIdAttr) {
|
|
|
|
ltArr = lodash.sortBy(ltArr, 'upNum').reverse()
|
|
|
|
for (let arti of ltArr) {
|
|
|
|
if (totalUpNum > 9) {
|
|
|
|
arti.upNum = arti.upNum - 1
|
|
|
|
totalUpNum--
|
|
|
|
} else {
|
|
|
|
break
|
|
|
|
}
|
2022-11-14 17:10:52 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-18 10:13:42 +00:00
|
|
|
return ret
|
|
|
|
}
|
2022-11-23 20:26:07 +00:00
|
|
|
|
|
|
|
let key = ds.key
|
2022-08-18 10:13:42 +00:00
|
|
|
let title = ds.title || ds[0]
|
2022-11-23 20:26:07 +00:00
|
|
|
if (!key) {
|
|
|
|
key = ArtisMark.getKeyByTitle(title)
|
|
|
|
}
|
|
|
|
let isDmg = Format.isElem(key)
|
2022-08-18 10:13:42 +00:00
|
|
|
let val = ds.value || ds[1]
|
2022-11-14 12:52:16 +00:00
|
|
|
let value = val
|
2022-08-18 10:13:42 +00:00
|
|
|
let num = ds.value || ds[1]
|
2022-11-23 20:26:07 +00:00
|
|
|
if (!key || key === 'undefined') {
|
2022-11-14 12:52:16 +00:00
|
|
|
return {}
|
2022-08-18 10:13:42 +00:00
|
|
|
}
|
2023-05-16 19:15:00 +00:00
|
|
|
let arrCfg = (game === 'gs' ? attrMap : attrMapSR)[isDmg ? 'dmg' : key]
|
|
|
|
console.log(key, arrCfg)
|
|
|
|
val = Format[arrCfg?.format || 'comma'](val, 1)
|
2022-11-14 12:52:16 +00:00
|
|
|
let ret = {
|
2022-11-23 20:26:07 +00:00
|
|
|
key,
|
2023-02-21 19:49:49 +00:00
|
|
|
value: val,
|
2023-04-13 20:13:17 +00:00
|
|
|
upNum: ds.upNum || 0,
|
|
|
|
eff: ds.eff || 0
|
2022-11-14 12:52:16 +00:00
|
|
|
}
|
2023-05-16 19:15:00 +00:00
|
|
|
/* if (!isMain && !ret.upNum) {
|
2022-11-23 20:26:07 +00:00
|
|
|
let incRet = ArtisMark.getIncNum(key, value)
|
2022-11-14 17:10:52 +00:00
|
|
|
ret.upNum = incRet.num
|
2023-04-13 20:13:17 +00:00
|
|
|
ret.eff = incRet.eff
|
2022-11-14 17:10:52 +00:00
|
|
|
ret.hasGt = incRet.hasGt
|
|
|
|
ret.hasLt = incRet.hasLt
|
2023-02-21 19:49:49 +00:00
|
|
|
ret.isCalcNum = true
|
2023-05-16 19:15:00 +00:00
|
|
|
}*/
|
2022-08-18 10:13:42 +00:00
|
|
|
|
2022-11-23 20:26:07 +00:00
|
|
|
if (charAttrCfg) {
|
|
|
|
let mark = charAttrCfg[key]?.mark * num || 0
|
2022-08-18 10:13:42 +00:00
|
|
|
if (isMain) {
|
|
|
|
mark = mark / 4 + 0.01
|
2022-11-22 20:25:36 +00:00
|
|
|
ret.key = key
|
2022-08-18 10:13:42 +00:00
|
|
|
}
|
|
|
|
ret.mark = Format.comma(mark || 0)
|
|
|
|
ret._mark = mark || 0
|
|
|
|
}
|
2023-04-18 19:01:25 +00:00
|
|
|
ret.eff = ret.eff ? Format.comma(ret.eff / 0.85, 1) : '-'
|
2022-08-18 10:13:42 +00:00
|
|
|
return ret
|
|
|
|
},
|
|
|
|
|
2022-11-23 20:26:07 +00:00
|
|
|
// 获取升级次数
|
|
|
|
getIncNum (key, value) {
|
|
|
|
let cfg = attrMap[key]
|
2022-11-14 17:10:52 +00:00
|
|
|
if (!value || !cfg || !cfg.value || !cfg.valueMin) {
|
|
|
|
return { num: 0 }
|
|
|
|
}
|
|
|
|
let maxNum = Math.min(5, Math.floor((value / cfg.valueMin).toFixed(1) * 1))
|
|
|
|
let minNum = Math.max(1, Math.ceil((value / cfg.value).toFixed(1) * 1))
|
|
|
|
// 相等时直接返回
|
|
|
|
if (maxNum === minNum) {
|
2023-04-13 20:13:17 +00:00
|
|
|
return { num: minNum, eff: value / cfg.value }
|
2022-11-14 17:10:52 +00:00
|
|
|
}
|
|
|
|
let avg = Math.round(value / (cfg.value + cfg.valueMin) * 2)
|
|
|
|
return {
|
|
|
|
num: avg,
|
2023-04-13 20:13:17 +00:00
|
|
|
eff: value / cfg.value,
|
2022-11-14 17:10:52 +00:00
|
|
|
hasGt: maxNum > avg,
|
|
|
|
hasLt: minNum < avg
|
2022-11-14 13:10:20 +00:00
|
|
|
}
|
2022-11-14 12:52:16 +00:00
|
|
|
},
|
|
|
|
|
2022-11-23 20:26:07 +00:00
|
|
|
// 获取评分档位
|
2022-08-18 10:13:42 +00:00
|
|
|
getMarkClass (mark) {
|
|
|
|
let pct = mark
|
2023-03-05 07:21:44 +00:00
|
|
|
let scoreMap = [['D', 7], ['C', 14], ['B', 21], ['A', 28], ['S', 35], ['SS', 42], ['SSS', 49], ['ACE', 56], ['ACE²', 66.1]]
|
2022-08-18 10:13:42 +00:00
|
|
|
for (let idx = 0; idx < scoreMap.length; idx++) {
|
|
|
|
if (pct < scoreMap[idx][1]) {
|
|
|
|
return scoreMap[idx][0]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2022-11-23 20:26:07 +00:00
|
|
|
// 获取位置分数
|
2022-11-22 20:25:36 +00:00
|
|
|
getMark (charCfg, posIdx, mainAttr, subAttr, elem = '') {
|
2022-08-18 10:13:42 +00:00
|
|
|
let ret = 0
|
2022-11-23 20:26:07 +00:00
|
|
|
let { attrs, posMaxMark } = charCfg
|
2023-02-09 17:17:18 +00:00
|
|
|
let key = mainAttr?.key
|
2023-02-09 17:50:52 +00:00
|
|
|
if (!key) {
|
|
|
|
return 0
|
|
|
|
}
|
2022-08-18 10:13:42 +00:00
|
|
|
let fixPct = 1
|
2022-11-23 20:26:07 +00:00
|
|
|
posIdx = posIdx * 1
|
2022-08-18 10:13:42 +00:00
|
|
|
if (posIdx >= 3) {
|
2022-11-23 20:26:07 +00:00
|
|
|
let mainKey = key
|
|
|
|
if (key !== 'recharge') {
|
|
|
|
if (posIdx === 4 && Format.isElem(key) && key === elem) {
|
|
|
|
mainKey = 'dmg'
|
|
|
|
}
|
|
|
|
fixPct = Math.max(0, Math.min(1, (attrs[mainKey]?.weight || 0) / (posMaxMark['m' + posIdx])))
|
2022-11-22 20:25:36 +00:00
|
|
|
}
|
2022-11-23 20:26:07 +00:00
|
|
|
ret += (attrs[mainKey]?.mark || 0) * (mainAttr.value || 0) / 4
|
2022-08-18 10:13:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lodash.forEach(subAttr, (ds) => {
|
2022-11-23 20:26:07 +00:00
|
|
|
ret += (attrs[ds.key]?.mark || 0) * (ds.value || 0)
|
2022-08-18 10:13:42 +00:00
|
|
|
})
|
2022-11-23 20:26:07 +00:00
|
|
|
return ret * (1 + fixPct) / 2 / posMaxMark[posIdx] * 66
|
2022-08-18 10:13:42 +00:00
|
|
|
},
|
2023-04-13 20:13:17 +00:00
|
|
|
|
2023-03-27 19:42:50 +00:00
|
|
|
getCritMark (charCfg, posIdx, mainAttr, subAttr, elem = '') {
|
|
|
|
let ret = 0
|
|
|
|
let { attrs, posMaxMark } = charCfg
|
|
|
|
let key = mainAttr?.key
|
|
|
|
if (!key) {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
let fixPct = 1
|
|
|
|
posIdx = posIdx * 1
|
|
|
|
if (posIdx >= 4) {
|
|
|
|
let mainKey = key
|
|
|
|
if (posIdx === 4 && Format.isElem(key) && key === elem) {
|
2023-04-13 20:13:17 +00:00
|
|
|
mainKey = 'dmg'
|
2023-03-27 19:42:50 +00:00
|
|
|
}
|
|
|
|
fixPct = Math.max(0, Math.min(1, (attrs[mainKey]?.weight || 0) / (posMaxMark['m' + posIdx])))
|
|
|
|
}
|
2023-04-13 20:13:17 +00:00
|
|
|
if (key === 'cpct' || key === 'cdmg') {
|
|
|
|
ret += 9.41
|
|
|
|
}
|
2023-03-27 19:42:50 +00:00
|
|
|
|
|
|
|
lodash.forEach(subAttr, (ds) => {
|
2023-04-13 20:13:17 +00:00
|
|
|
if (ds.key === 'cpct' || ds.key === 'cdmg') {
|
|
|
|
let temp_s = (attrs[ds.key]?.mark || 0) * (ds.value || 0) / 85
|
|
|
|
ret += temp_s
|
2023-03-27 19:42:50 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
return ret
|
|
|
|
},
|
2023-04-13 20:13:17 +00:00
|
|
|
|
2023-03-27 19:42:50 +00:00
|
|
|
getValidMark (charCfg, posIdx, mainAttr, subAttr, elem = '') {
|
|
|
|
let ret = 0
|
|
|
|
let { attrs, posMaxMark } = charCfg
|
|
|
|
let key = mainAttr?.key
|
|
|
|
if (!key) {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
let fixPct = 1
|
|
|
|
posIdx = posIdx * 1
|
|
|
|
if (posIdx >= 4) {
|
|
|
|
let mainKey = key
|
|
|
|
if (posIdx === 4 && Format.isElem(key) && key === elem) {
|
2023-04-13 20:13:17 +00:00
|
|
|
mainKey = 'dmg'
|
2023-03-27 19:42:50 +00:00
|
|
|
}
|
2023-04-13 20:13:17 +00:00
|
|
|
|
|
|
|
|
2023-03-27 19:42:50 +00:00
|
|
|
fixPct = Math.max(0, Math.min(1, (attrs[mainKey]?.weight || 0) / (posMaxMark['m' + posIdx])))
|
|
|
|
}
|
|
|
|
lodash.forEach(subAttr, (ds) => {
|
2023-04-13 20:13:17 +00:00
|
|
|
let temp_s = (attrs[ds.key]?.mark || 0) * (ds.value || 0) / 85
|
2023-03-27 19:42:50 +00:00
|
|
|
ret += temp_s
|
|
|
|
})
|
|
|
|
return ret
|
|
|
|
},
|
2022-11-23 20:26:07 +00:00
|
|
|
|
|
|
|
// 获取位置最高分
|
2022-09-14 19:31:10 +00:00
|
|
|
getMaxMark (attrs) {
|
2022-08-18 10:13:42 +00:00
|
|
|
let ret = {}
|
|
|
|
for (let idx = 1; idx <= 5; idx++) {
|
|
|
|
let totalMark = 0
|
|
|
|
let mMark = 0
|
|
|
|
let mAttr = ''
|
|
|
|
if (idx === 1) {
|
|
|
|
mAttr = 'hpPlus'
|
|
|
|
} else if (idx === 2) {
|
|
|
|
mAttr = 'atkPlus'
|
|
|
|
} else if (idx >= 3) {
|
2022-09-14 19:31:10 +00:00
|
|
|
mAttr = ArtisMark.getMaxAttr(attrs, mainAttr[idx])[0]
|
|
|
|
mMark = attrs[mAttr].fixWeight
|
|
|
|
totalMark += attrs[mAttr].fixWeight * 2
|
2022-08-18 10:13:42 +00:00
|
|
|
}
|
|
|
|
|
2022-09-14 19:31:10 +00:00
|
|
|
let sAttr = ArtisMark.getMaxAttr(attrs, subAttr, 4, mAttr)
|
2022-08-18 10:13:42 +00:00
|
|
|
lodash.forEach(sAttr, (attr, aIdx) => {
|
2022-09-14 19:31:10 +00:00
|
|
|
totalMark += attrs[attr].fixWeight * (aIdx === 0 ? 6 : 1)
|
2022-08-18 10:13:42 +00:00
|
|
|
})
|
|
|
|
ret[idx] = totalMark
|
|
|
|
ret['m' + idx] = mMark
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
},
|
2022-11-23 20:26:07 +00:00
|
|
|
|
|
|
|
// 获取最高分的属性
|
2022-09-14 19:31:10 +00:00
|
|
|
getMaxAttr (attrs = {}, list2 = [], maxLen = 1, banAttr = '') {
|
2022-08-18 10:13:42 +00:00
|
|
|
let tmp = []
|
|
|
|
lodash.forEach(list2, (attr) => {
|
|
|
|
if (attr === banAttr) return
|
2022-09-14 19:31:10 +00:00
|
|
|
if (!attrs[attr]) return
|
|
|
|
tmp.push({ attr, mark: attrs[attr].fixWeight })
|
2022-08-18 10:13:42 +00:00
|
|
|
})
|
|
|
|
tmp = lodash.sortBy(tmp, 'mark')
|
|
|
|
tmp = tmp.reverse()
|
|
|
|
let ret = []
|
|
|
|
lodash.forEach(tmp, (ds) => ret.push(ds.attr))
|
|
|
|
return ret.slice(0, maxLen)
|
2023-02-09 18:54:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
hasAttr (artis) {
|
|
|
|
for (let idx = 1; idx <= 5; idx++) {
|
|
|
|
let ds = artis[idx]
|
2023-02-22 17:48:44 +00:00
|
|
|
if (ds) {
|
|
|
|
if (!ds.name || !ds.main || !ds.attrs || !ds?.main?.key) {
|
|
|
|
return false
|
|
|
|
}
|
2023-02-09 18:54:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
2022-08-18 10:13:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ArtisMark
|