From 7b173c8c71514cf8d3103d27236b79ed2ea97ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=AB=E8=B0=B7=E5=89=91=E4=BB=99?= Date: Tue, 13 Oct 2020 19:24:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E8=BA=AB=E5=90=8E=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=9B=9E=E5=8F=98=E8=BA=AB=E5=89=8D=EF=BC=8C=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=89=93=E7=9A=84=E6=BD=9C=E8=A7=89=E5=92=8C?= =?UTF-8?q?=E8=B6=85=E8=A7=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-universal_function.js | 17 +++++++++++++++++ script.js | 16 ++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/script-universal_function.js b/script-universal_function.js index 1818a38c..720f8573 100644 --- a/script-universal_function.js +++ b/script-universal_function.js @@ -481,6 +481,23 @@ function isReincarnated(card) { return card.is8Latent && !card.isUltEvo && (card.evoBaseId || card.evoRootId) != card.id && (card.awakenings.includes(49) ? isReincarnated(Cards[card.evoBaseId]) : true); } +//获取类型允许的潜觉 +function getAllowLatent(types) +{ + const latentSet = new Set(); + types.filter(i => i >= 0) + .map(type => type_allowable_latent[type]) + .forEach(tA => tA.forEach(t => latentSet.add(t))); + return Array.from(latentSet); +} +//筛选出允许的潜觉 +function filterAllowLatent(latent, allowLatent) +{ + const allKillerLatent = typekiller_for_type.map(type => type.latent); + return latent.filter(lat => + !allKillerLatent.includes(lat) || //保留不属于杀的潜觉 + allKillerLatent.includes(lat) && allowLatent.includes(lat)); //属于杀的潜觉则只保留允许的 +} //计算队伍中有多少血量 function countTeamHp(memberArr, leader1id, leader2id, solo, noAwoken=false) { diff --git a/script.js b/script.js index 16b3fad6..3a7650ee 100644 --- a/script.js +++ b/script.js @@ -350,6 +350,9 @@ function swapHenshin(self) const _card = Cards[card.evoRootId]; member.id = card.evoRootId; member.awoken = _card.awakenings.length; + member.sawoken = null; + const allowLatent = getAllowLatent(_card.types); + member.latent = filterAllowLatent(member.latent,allowLatent); } }); }); @@ -2138,16 +2141,12 @@ function editBoxChangeMonId(id) { const rowLatent = settingBox.querySelector(".row-mon-latent"); const monLatentAllowUl = rowLatent.querySelector(".m-latent-allowable-ul"); //该宠Type允许的杀,set不会出现重复的 - const allowLatent = new Set(); - card.types - .filter(i => i >= 0) - .map(type => type_allowable_latent[type]) - .forEach(tA => tA.forEach(t => allowLatent.add(t))); + const allowLatent = getAllowLatent(card.types); typekiller_for_type.forEach(type => { //显示允许的杀,隐藏不允许的杀 const latentDom = monLatentAllowUl.querySelector(`.latent-icon[data-latent-icon='${type.latent}']`); if (!latentDom) return; - if (allowLatent.has(type.latent)) { + if (allowLatent.includes(type.latent)) { latentDom.classList.remove("unallowable-latent"); } else { latentDom.classList.add("unallowable-latent"); @@ -2221,11 +2220,8 @@ function editBoxChangeMonId(id) { } } - const allKillerLatent = typekiller_for_type.map(type => type.latent); //去除所有不能再打的潜觉 - editBox.latent = editBox.latent.filter(lat => - !allKillerLatent.includes(lat) || - allKillerLatent.includes(lat) && allowLatent.has(lat)); + editBox.latent = filterAllowLatent(editBox.latent,allowLatent); editBox.refreshLatent(editBox.latent, id); editBox.reCalculateExp(); editBox.reCalculateAbility();