From 6f7909d3e303c3d3f8e2b93b86efc79714d320d6 Mon Sep 17 00:00:00 2001 From: Kokomi <102026640+yoimiya-kokomi@users.noreply.github.com> Date: Tue, 15 Nov 2022 01:10:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A3=E9=81=97=E7=89=A9=E8=AF=8D=E6=9D=A1?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E6=AC=A1=E6=95=B0=E6=94=AF=E6=8C=81`#?= =?UTF-8?q?=E5=9C=A3=E9=81=97=E7=89=A9=E5=88=97=E8=A1=A8`=20=E5=9C=A3?= =?UTF-8?q?=E9=81=97=E7=89=A9=E8=AF=8D=E6=9D=A1=E5=8D=87=E7=BA=A7=E6=AC=A1?= =?UTF-8?q?=E6=95=B0=E5=88=A4=E5=AE=9A=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/profile-lib/ArtisMark.js | 45 ++++++++++++++++++++++++----- resources/character/artis-list.html | 4 +-- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/models/profile-lib/ArtisMark.js b/models/profile-lib/ArtisMark.js index 2320ea85..886e0dea 100644 --- a/models/profile-lib/ArtisMark.js +++ b/models/profile-lib/ArtisMark.js @@ -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) { diff --git a/resources/character/artis-list.html b/resources/character/artis-list.html index 7ee60872..d0dff0d0 100644 --- a/resources/character/artis-list.html +++ b/resources/character/artis-list.html @@ -28,8 +28,8 @@ {{each ds.attrs attr}} {{if attr.title}}
  • - {{attr.title}}+{{attr.value}}
  • + {{if attr.upNum}}{{/if}}{{attr.title}} + +{{attr.value}} {{/if}} {{/each}}