圣遗物词条升级次数支持#圣遗物列表

圣遗物词条升级次数判定逻辑调整
This commit is contained in:
Kokomi 2022-11-15 01:10:52 +08:00
parent 98b6c8a2cc
commit 6f7909d3e3
2 changed files with 39 additions and 10 deletions

View File

@ -32,9 +32,27 @@ let ArtisMark = {
formatArti (ds, markCfg = false, isMain = false) {
if (ds[0] && ds[0].title) {
let ret = []
let totalUpNum = 0
let ltArr = []
lodash.forEach(ds, (d) => {
ret.push(ArtisMark.formatArti(d, markCfg, isMain))
let arti = ArtisMark.formatArti(d, markCfg, isMain)
totalUpNum += arti.upNum
if (arti.hasLt) {
ltArr.push(arti)
}
ret.push(arti)
delete arti.hasLt
delete arti.hasGt
})
ltArr = lodash.sortBy(ltArr, 'upNum').reverse()
for (let arti of ltArr) {
if (totalUpNum > 9) {
arti.upNum = arti.upNum - 1
totalUpNum--
} else {
break
}
}
return ret
}
let title = ds.title || ds[0]
@ -69,7 +87,10 @@ let ArtisMark = {
value: val
}
if (!isMain) {
ret.upNum = ArtisMark.getIncNum(title, value)
let incRet = ArtisMark.getIncNum(title, value)
ret.upNum = incRet.num
ret.hasGt = incRet.hasGt
ret.hasLt = incRet.hasLt
}
if (markCfg) {
@ -85,13 +106,21 @@ let ArtisMark = {
getIncNum (title, value) {
let cfg = attrNameMap[title] && attrMap[attrNameMap[title]]
if (cfg && cfg.value && cfg.valueMin) {
let min = Math.ceil((value / cfg.value).toFixed(1) * 1)
let max = Math.floor((value / cfg.valueMin).toFixed(1) * 1)
let avg = Math.round(value / (cfg.value + cfg.valueMin) * 2)
return Math.max(min, Math.min(max, avg))
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) {
return { num: minNum }
}
let avg = Math.round(value / (cfg.value + cfg.valueMin) * 2)
return {
num: avg,
hasGt: maxNum > avg,
hasLt: minNum < avg
}
return 0
},
getMarkClass (mark) {

View File

@ -28,8 +28,8 @@
{{each ds.attrs attr}}
{{if attr.title}}
<li class="{{ds.usefulMark[attr.title]*1 > 79.9 ?`great`:(ds.usefulMark[attr.title]*1>0 ? `useful`:`nouse`)}}">
<span class="title">{{attr.title}}</span><span
class="val">+{{attr.value}}</span></li>
<span class="title"> {{if attr.upNum}}<i class="up-num up-{{attr.upNum}}"></i>{{/if}}{{attr.title}}</span>
<span class="val">+{{attr.value}}</span></li>
{{/if}}
{{/each}}
</ul>