From 5bb6e1a2815ead4dbc945fb34d92632758a2e88f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=AB=E8=B0=B7=E5=89=91=E4=BB=99?= Date: Sat, 19 Dec 2020 02:31:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E5=8A=A0=E5=85=A52P=E5=AF=B9?= =?UTF-8?q?=E5=BF=83=E8=BF=BD=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- multi.html | 14 +++++++++++ script.js | 70 +++++++++++++++++++++++++++++++----------------------- 2 files changed, 54 insertions(+), 30 deletions(-) diff --git a/multi.html b/multi.html index a4c1b5af..c44fc771 100644 --- a/multi.html +++ b/multi.html @@ -56,6 +56,13 @@ var formation = new Formation(teamsCount,5);
diff --git a/script.js b/script.js index 8ac4e3f0..96f9a18a 100644 --- a/script.js +++ b/script.js @@ -2821,24 +2821,29 @@ function refreshTeamAwokenCount(awokenDom, team) { const awokenUL = fragment.appendChild(awokenDom.querySelector(".awoken-ul")); const aicons = Array.from(awokenUL.querySelectorAll(`.awoken-icon[data-awoken-icon]`)); - aicons.forEach(aicon=>{ + const acs = aicons.map(aicon=>{ const ai = parseInt(aicon.getAttribute("data-awoken-icon"),10); + let totalNum = 0; //搜索等效觉醒 - const equalIndex = equivalent_awoken.findIndex(eak => eak.small === ai || eak.big === ai); - if (equalIndex >= 0) { - const equivalentAwoken = equivalent_awoken[equalIndex]; - if (equivalentAwoken.small === ai) { - const totalNum = awokenCountInTeam(team, equivalentAwoken.small, solo, teamsCount) + - awokenCountInTeam(team, equivalentAwoken.big, solo, teamsCount) * equivalentAwoken.times; - awokenSetCount(aicon, totalNum); - } else { - return; - } - } else { - awokenSetCount(aicon, awokenCountInTeam(team, ai, solo, teamsCount)); + const equivalentAwoken = equivalent_awoken.find(eak => eak.small === ai || eak.big === ai); + if (equivalentAwoken && equivalentAwoken.small === ai) + { + totalNum = awokenCountInTeam(team, equivalentAwoken.small, solo, teamsCount) + + awokenCountInTeam(team, equivalentAwoken.big, solo, teamsCount) * equivalentAwoken.times; + } else + { + totalNum = awokenCountInTeam(team, ai, solo, teamsCount); } - }) - + awokenSetCount(aicon, totalNum); + return {a:ai,c:totalNum}; + }); + if (acs.every(ac=>ac.c==0)) + { + awokenDom.classList.add(className_displayNone); + } else + { + awokenDom.classList.remove(className_displayNone); + } awokenDom.appendChild(fragment); } //刷新阵型觉醒统计 @@ -2847,24 +2852,29 @@ function refreshFormationAwokenCount(awokenDom, teams) { const awokenUL = fragment.appendChild(awokenDom.querySelector(".awoken-ul")); const aicons = Array.from(awokenUL.querySelectorAll(`.awoken-icon[data-awoken-icon]`)); - aicons.forEach(aicon=>{ + const acs = aicons.map(aicon=>{ const ai = parseInt(aicon.getAttribute("data-awoken-icon"),10); + let totalNum = 0; //搜索等效觉醒 - const equalIndex = equivalent_awoken.findIndex(eak => eak.small === ai || eak.big === ai); - if (equalIndex >= 0) { - const equivalentAwoken = equivalent_awoken[equalIndex]; - if (equivalentAwoken.small === ai) { - const totalNum = awokenCountInFormation(teams, equivalentAwoken.small, solo) + - awokenCountInFormation(teams, equivalentAwoken.big, solo) * equivalentAwoken.times; - awokenSetCount(aicon, totalNum); - } else { - return; - } - } else { - awokenSetCount(aicon, awokenCountInFormation(teams, ai, solo)); + const equivalentAwoken = equivalent_awoken.find(eak => eak.small === ai || eak.big === ai); + if (equivalentAwoken && equivalentAwoken.small === ai) + { + totalNum = awokenCountInFormation(teams, equivalentAwoken.small, solo) + + awokenCountInFormation(teams, equivalentAwoken.big, solo) * equivalentAwoken.times; + } else + { + totalNum = awokenCountInFormation(teams, ai, solo); } - }) - + awokenSetCount(aicon, totalNum); + return {a:ai,c:totalNum}; + }); + if (acs.every(ac=>ac.c==0)) + { + awokenDom.classList.add(className_displayNone); + } else + { + awokenDom.classList.remove(className_displayNone); + } awokenDom.appendChild(fragment); } //刷新能力值