From 4ae7be357a4e51dc35bfe8e7f1f00c36ffe7d6ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=AB=E8=B0=B7=E5=89=91=E4=BB=99?= Date: Thu, 29 Feb 2024 01:58:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E8=B0=83=E6=95=B4=E9=98=9F?= =?UTF-8?q?=E4=BC=8D=E8=A1=80=E9=87=8F=E7=AE=97=E6=B3=95=EF=BC=8C=E5=BA=94?= =?UTF-8?q?=E8=AF=A5=E6=98=AF=E9=98=9F=E9=95=BF=E5=80=8D=E7=8E=87=E5=92=8C?= =?UTF-8?q?=E9=98=9F=E4=BC=8D=E8=A7=89=E9=86=92=E3=80=81=E5=BE=BD=E7=AB=A0?= =?UTF-8?q?=E5=80=8D=E7=8E=87=EF=BC=8C=E9=83=BD=E8=A6=81=E6=94=BE=E5=9C=A8?= =?UTF-8?q?=E4=B8=80=E8=B5=B7=E5=81=9A=E5=9B=9B=E8=88=8D=E4=BA=94=E5=85=A5?= =?UTF-8?q?=E5=90=8E=E6=89=8D=E7=9B=B8=E5=8A=A0=EF=BC=8C=E8=80=8C=E4=B8=8D?= =?UTF-8?q?=E6=98=AF=E7=9B=B8=E5=8A=A0=E5=90=8E=E5=86=8D=E5=9B=9B=E8=88=8D?= =?UTF-8?q?=E4=BA=94=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-universal_function.js | 2 +- script.js | 12 ++++++------ service-worker.js | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/script-universal_function.js b/script-universal_function.js index dff40679..06f2e43f 100644 --- a/script-universal_function.js +++ b/script-universal_function.js @@ -1233,7 +1233,7 @@ function countTeamHp(team, leader1id, leader2id, solo, noAwoken = false) { //演示用代码 //console.log("%s 第1次倍率血量:%s,第2次倍率血量:%s",Cards[m.id].otLangName["chs"],hp1,hp2); - mHpArr.push(Math.round(mulHP)); + mHpArr.push(mulHP); } //console.log('单个队伍血量:',mHpArr,mHpArr.reduce((p,c)=>p+c)); diff --git a/script.js b/script.js index a35a0f3d..e2f9732c 100644 --- a/script.js +++ b/script.js @@ -6689,9 +6689,9 @@ function refreshTeamTotalHP(totalDom, team, teamIdx) { case 20: return 1.10; //全属性 } })(badge); - - let tHP = Math.round(teamHPArr.reduce((pv, v) => pv + v * teamHPAwokenScale * badgeHPScale, 0)); //队伍计算的总HP - let tHPNoAwoken = Math.round(teamHPNoAwokenArr.reduce((pv, v) => pv + v * badgeHPScale, 0)); //队伍计算的总HP无觉醒 + //由于JS的小数和强类型语言不完全一致,+1e-12后再做四舍五入会更准确符合游戏内数字 + let tHP = teamHPArr.reduce((pv, v) => pv + Math.round(v * teamHPAwokenScale * badgeHPScale + 1e-12), 0); //队伍计算的总HP + let tHPNoAwoken = teamHPNoAwokenArr.reduce((pv, v) => pv + Math.round(v * badgeHPScale + 1e-12), 0); //队伍计算的总HP无觉醒 //记录到bar中,方便打开详情时调用 hpBar.reduceAttrRangesWithShieldAwoken = reduceAttrRangesWithShieldAwoken; //有盾觉醒的 @@ -6844,15 +6844,15 @@ function refreshFormationTotalHP(totalDom, teams) { const totalReduce = leastScale.scale; - const tHPArr = teams.map(function(team) { + const tHPArr = teams.map(team=>{ const teamHPArr = countTeamHp(team, leader1id, leader2id, solo); const teamHPAwoken = awokenCountInTeam(team, 46, solo, teamsCount), teamHPAwokenScale = (1 + 0.05 * teamHPAwoken); //全队大血包个数 - const teamTHP = Math.round(teamHPArr.reduce((pv, v) => pv + v * teamHPAwokenScale)); //队伍计算的总HP + const teamTHP = teamHPArr.reduce((pv, v) => pv + Math.round(v * teamHPAwokenScale + 1e-12)); //队伍计算的总HP return teamTHP; }); - const tHPNoAwokenArr = teams.map(function(team) { + const tHPNoAwokenArr = teams.map(team=>{ const teamHPArr = countTeamHp(team, leader1id, leader2id, solo, true); const teamTHP = teamHPArr.reduce((pv, v) => pv + v); //队伍计算的总HP diff --git a/service-worker.js b/service-worker.js index 874936c8..e2996be5 100644 --- a/service-worker.js +++ b/service-worker.js @@ -23199,11 +23199,11 @@ const cachesMap = new Map([ ], [ "script-universal_function.js", - "53b5e9b772192173f139fd58be42eaa8" + "a6bab2bfddb9c42a06ef821959773b71" ], [ "script.js", - "97bc738e6401a40c01f3f5497858d384" + "e48bb870d44c7ced25302d1cb8154d41" ], [ "solo.html",