From 42ce89e9fc02f026a36ea85d9ae6560734b223a7 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, 21 Aug 2021 03:14:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=9C=B0=E4=B8=8B=E5=9F=8E?= =?UTF-8?q?=E5=BC=BA=E5=8C=96=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-universal_function.js | 31 +++++++++++++++++++------------ script.js | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/script-universal_function.js b/script-universal_function.js index d2a09e31..a93dae41 100644 --- a/script-universal_function.js +++ b/script-universal_function.js @@ -131,6 +131,10 @@ function flags(num) { } return arr; } +//将二进制flag转为数组 +function reflags(arr) { + return arr.reduce((pre,cur)=>pre | 1 << cur, 0); +} //带标签的模板字符串 function tp(strings, ...keys) { @@ -464,8 +468,16 @@ function calculateAbility(member, assist = null, solo = true, teamsCount = 1) { reValue = reValue * latterAwokenScale[idx].reduce(calculateAwokenScale, 1); //都要做四舍五入 - reValue = Math.round(reValue); - reValueNoAwoken = Math.round(reValueNoAwoken); + if (formation.dungeonEnchance.rate !== 1) + { + let rate = (memberCard.attrs.some(attr=>formation.dungeonEnchance.attrs.includes(attr)) || memberCard.types.some(type=>formation.dungeonEnchance.types.includes(type))) ? formation.dungeonEnchance.rate : 1; + reValue = Math.round(reValue * rate); + reValueNoAwoken = Math.round(reValueNoAwoken * rate); + }else + { + reValue = Math.round(reValue); + reValueNoAwoken = Math.round(reValueNoAwoken); + } if (idx < 2) //idx顺序为HP、ATK、RCV { //HP和ATK最低为1 reValue = Math.max(reValue, 1); @@ -713,17 +725,12 @@ function countTeamHp(memberArr, leader1id, leader2id, solo, noAwoken = false) { let hp = ability ? ability[0] : 0; if (!hp) return 0; const card = Cards[m.id] || Cards[0]; - hp = hp1 = Math.round(hp * memberHpMul(card, ls2, memberArr, solo)); //战友队长技 - hp = hp2 = Math.round(hp * memberHpMul(card, ls1, memberArr, solo)); //我方队长技 + let hp1 = hp = Math.round(hp * memberHpMul(card, ls2, memberArr, solo)); //战友队长技 + let hp2 = hp = Math.round(hp * memberHpMul(card, ls1, memberArr, solo)); //我方队长技 - /* 演示用代码 - let hp1,hp2; - hp1 = hp * memberHpMul(card,ls2,memberArr,solo); - hp = Math.round(hp1); - hp2 = hp * memberHpMul(card,ls1,memberArr,solo); - hp = Math.round(hp2); - console.log("%s 第1次倍率血量:%s(%s),第2次倍率血量:%s(%s)",Cards[m.id].otLangName["chs"],Math.round(hp1),hp1,Math.round(hp2),hp2); - */ + //演示用代码 + console.log("%s 第1次倍率血量:%s,第2次倍率血量:%s",Cards[m.id].otLangName["chs"],hp1,hp2); + return hp; }); diff --git a/script.js b/script.js index 7cfca3b6..365c8188 100644 --- a/script.js +++ b/script.js @@ -249,6 +249,11 @@ var Formation = function(teamCount, memberCount) { this.title = ""; this.detail = ""; this.teams = []; + this.dungeonEnchance = { + attrs: [], + types: [], + rate: 1, + } for (let ti = 0; ti < teamCount; ti++) { const team = [ [], //队员 @@ -279,6 +284,11 @@ Formation.prototype.outObj = function() { if (t[3]) teamArr[3] = t[3]; return teamArr; }); + if (this.dungeonEnchance.rate != 1) obj.r = [ + this.dungeonEnchance.rate, //比例 + reflags(this.dungeonEnchance.types) //优先添加Type + ]; + if (this.dungeonEnchance.attrs.length) obj.r.push(reflags(this.dungeonEnchance.attrs)); //有Attr.才添加 obj.v = dataStructure; /*if (obj.f.every(team=>team[0].length == 0 && team[1].length == 0 && team[2] == undefined) && !obj.t && @@ -301,6 +311,9 @@ Formation.prototype.loadObj = function(f) { t[2] = 0; t[3] = 0; }); + this.dungeonEnchance.rate = 1; + this.dungeonEnchance.attrs.length = 0; + this.dungeonEnchance.types.length = 0; return; } const dataVeision = f.v ? f.v : (f.f ? 2 : 1); //是第几版格式 @@ -322,6 +335,12 @@ Formation.prototype.loadObj = function(f) { t[3] = tf[3] || 0; //队长 } }); + if (f.r) + { + this.dungeonEnchance.rate = f.r[0] ?? 1; + this.dungeonEnchance.types = flags(f.r[1] ?? 0); + this.dungeonEnchance.attrs = flags(f.r[2] ?? 0); + } if (f.b) this.teams[0][2] = f.b; //原来模式的徽章 };