diff --git a/browser-compatibility.js b/browser-compatibility.js index eede7f26..fb4111e5 100644 --- a/browser-compatibility.js +++ b/browser-compatibility.js @@ -20,7 +20,7 @@ {name: "CSS selector: :not() / CSS选择器: :not()", version:{firefox:84,chrome:88,safari:9}, url: "https://caniuse.com/css-not-sel-list", test: ()=>supportsPseudoClass(":not(html)")}, //{name: "CSS selector: :has() / CSS选择器: :has()", version:{firefox:121,chrome:105,safari:15.4}, url: "https://caniuse.com/css-has", test: ()=>supportsPseudoClass(":has(html)")}, {name: "Private class fields (#name) / 类私有域(#name)", version:{firefox:90,chrome:74,safari:14.5}, url: "https://caniuse.com/mdn-javascript_classes_private_class_fields", test: ()=>Boolean(runCodeWithFunction("class test {#v = 0;}, true"))}, - // {name: "Dialog element / Dialog 元素", version:{firefox:98,chrome:37,safari:15.4}, url: "https://caniuse.com/dialog", test: ()=>Boolean(eval("HTMLDialogElement"))}, + {name: "Dialog element / Dialog 元素", version:{firefox:98,chrome:37,safari:15.4}, url: "https://caniuse.com/dialog", test: ()=>Boolean(eval("HTMLDialogElement"))}, // {name: "Class static initialization blocks / 静态初始化块", version:{firefox:93,chrome:94,safari:16.4}, url: "https://caniuse.com/mdn-javascript_classes_static_initialization_blocks", test: ()=>supportsPseudoClass(":not(html)")}, ] return features.filter(feature=>{ diff --git a/images/badge.png b/images/badge.png index cde62876..4e5bce5f 100644 Binary files a/images/badge.png and b/images/badge.png differ diff --git a/images/project file/badge.fw.png b/images/project file/badge.fw.png index 76ca8830..c5f3c8d3 100644 Binary files a/images/project file/badge.fw.png and b/images/project file/badge.fw.png differ diff --git a/languages/zh-hans.css b/languages/zh-hans.css index 0349db47..48bf9708 100644 --- a/languages/zh-hans.css +++ b/languages/zh-hans.css @@ -446,7 +446,7 @@ label[for="box-have"]::after .dialog-close::after, .mask-close::after { - content: "关闭"; + content: "取消"; } .dialog .dialog-content .additional-string::before { diff --git a/script-json_data.js b/script-json_data.js index 8ffe39f7..fc64177b 100644 --- a/script-json_data.js +++ b/script-json_data.js @@ -542,6 +542,14 @@ const equivalent_awoken = [ {small:77,big:125,times:2},//暗串 ]; +const PAD_PASS_BADGE = 1<<7 | 1; //本程序的月卡徽章编号,129 +//官方的徽章排列顺序 +const official_badge_sorting = [ + 1, PAD_PASS_BADGE, + 22, 23, 2, 3, 4, 5, 6, + 7, 8, 9, 11, 17, 18, 19, 20, + 21, 10, 12, 13, 14, 24, 25, +] //官方的觉醒排列顺序 const official_awoken_sorting = [ 21, 43, 61, 10, 54, 11, 12, 13, 49, @@ -560,7 +568,6 @@ const official_awoken_sorting = [ 84, 83, 85, 86, 87, 88, 89, 90, 64, 63,128,129,130 ]; -const PAD_PASS_BADGE = 1<<7 | 1; //本程序的月卡徽章编号,129 //排序程序列表 const sort_function_list = [ @@ -4206,7 +4213,15 @@ const specialSearchFunctions = (function() { }, {name:"Will get Team Badge",otLangName:{chs:"能获得队伍徽章",cht:"能獲得隊伍徽章"}, function:cards=>cards.filter(({badgeId})=>badgeId), - addition:({badgeId})=>`ID.${badgeId}` + addition:({badgeId})=>{ + const fragment = document.createDocumentFragment(); + fragment.append(`ID.${badgeId}`); + const icon = document.createElement("icon"); + icon.className = "badge"; + icon.setAttribute("data-badge-icon", badgeId); + fragment.append(icon); + return fragment; + } }, {name:"Hava banner when use skill",otLangName:{chs:"使用技能时有横幅",cht:"使用技能時有橫幅"}, function:cards=>cards.filter(card=>card.skillBanner) diff --git a/script.js b/script.js index 9c378a0f..5e106a63 100644 --- a/script.js +++ b/script.js @@ -4117,28 +4117,36 @@ function initialize() { }); //添加徽章 - const className_ChoseBadges = "show-all-badges"; + const badgeDialog = document.getElementById("badge-choose"); + const teamBadgeUl = badgeDialog.querySelector(".team-badges"); + official_badge_sorting.forEach(bgId=>{ + const li = document.createElement("li"); + const button = li.appendChild(document.createElement("button")); + button.className = "badge"; + button.value = bgId; + button.setAttribute("data-badge-icon", bgId); + teamBadgeUl.appendChild(li); + }); + teamBigBoxs.forEach((teamBigBox, teamIdx) => { //徽章 const teamBadge = teamBigBox.querySelector(".team-badge"); - if (!teamBadge) return; - const badges = Array.from(teamBadge.querySelectorAll(".badge-radio")); - - function setBadge() { - if (teamBadge.classList.contains(className_ChoseBadges)) { - const team = formation.teams[teamIdx]; - teamBadge.classList.remove(className_ChoseBadges); - team[2] = parseInt(this.value, 10); - const teamTotalInfoDom = teamBigBox.querySelector(".team-total-info"); //队伍能力值合计 - if (teamTotalInfoDom) refreshTeamTotalHP(teamTotalInfoDom, team, teamIdx); - const teamAwokenEffectDom = teamBigBox.querySelector(".team-awoken-effect"); //队伍觉醒效果计算 - if (teamAwokenEffectDom) refreshTeamAwokenEfeect(teamAwokenEffectDom, team, teamIdx); - createNewUrl(); - } else { - teamBadge.classList.add(className_ChoseBadges); - } - } - badges.forEach(badge => badge.onclick = setBadge); + const returnFunc = function(event){ + const returnValue = event.target.returnValue; + if (returnValue === "cancel") return; + _badgeThis.setAttribute("data-badge-icon", returnValue); + _badgeThis.value = returnValue; + const team = formation.teams[teamIdx]; + team[2] = parseInt(returnValue, 10); + refreshAll(formation); + //badgeDialog.removeEventListener("close", returnFunc); + }; + teamBadge.onclick = function(){ + _badgeThis = this; + //_badgeThis.value + badgeDialog.addEventListener("close", returnFunc, {once: true}); + badgeDialog.showModal(); + }; }); //显示HP的详细值 @@ -5678,6 +5686,9 @@ function initialize() { } else { const teamTotalInfoDom = teamBigBox.querySelector(".team-total-info"); //队伍能力值合计 if (teamTotalInfoDom) refreshTeamTotalHP(teamTotalInfoDom, teamData, editBox.memberIdx[0]); + + const teamTotalInfoCountDom = teamBigBox.querySelector(".team-total-info-count"); //队伍星级、属性、类型合计 + if (teamTotalInfoCountDom) refreshTeamTotalCount(teamTotalInfoCountDom, teamData, teamNum); const formationTotalInfoDom = formationBox.querySelector(".formation-total-info"); //所有队伍能力值合计 if (formationTotalInfoDom) refreshFormationTotalHP(formationTotalInfoDom, formation.teams); @@ -5759,6 +5770,10 @@ function initialize() { const teamTotalInfoDom = teamBigBox.querySelector(".team-total-info"); //队伍能力值合计 if (teamTotalInfoDom) refreshTeamTotalHP(teamTotalInfoDom, teamData, editBox.memberIdx[0]); + + const teamTotalInfoCountDom = teamBigBox.querySelector(".team-total-info-count"); //队伍星级、属性、类型合计 + if (teamTotalInfoCountDom) refreshTeamTotalCount(teamTotalInfoCountDom, teamData, teamNum); + const formationTotalInfoDom = formationBox.querySelector(".formation-total-info"); //所有队伍能力值合计 if (formationTotalInfoDom) refreshFormationTotalHP(formationTotalInfoDom, formation.teams); @@ -6618,6 +6633,9 @@ function refreshAll(formationData) { const teamTotalInfoDom = teamBigBox.querySelector(".team-total-info"); //队伍能力值合计 if (teamTotalInfoDom) refreshTeamTotalHP(teamTotalInfoDom, teamData, teamNum); + const teamTotalInfoCountDom = teamBigBox.querySelector(".team-total-info-count"); //队伍星级、属性、类型合计 + if (teamTotalInfoCountDom) refreshTeamTotalCount(teamTotalInfoCountDom, teamData, teamNum); + const teamAwokenDom = teamBigBox.querySelector(".team-awoken"); //队伍觉醒合计 if (teamAwokenDom) refreshTeamAwokenCount(teamAwokenDom, teamData); @@ -7386,9 +7404,35 @@ function refreshTeamTotalHP(totalDom, team, teamIdx) { } } - const tRarityDom = totalDom.querySelector(".tIf-rarity"); - const tAttrsDom = totalDom.querySelector(".tIf-attrs"); - const tTypesDom = totalDom.querySelector(".tIf-types"); + if (tEffectDom) { + //76版队长技能不被换队长所影响 + const leader1id_original = members[0].id; + const leader2id_original = teamsCount===2 ? (teamIdx === 1 ? teamsA_members[0].id : teamsB_members[0].id) : members[5].id; + let effect = tIf_Effect(leader1id,leader2id, leader1id_original,leader2id_original); + if (badge == 22) effect.poisonNoEffect = true; + refreshEffectDom(tEffectDom, effect); + } +} +//刷新队伍能力值合计 +function refreshTeamTotalCount(totalCountDom, team, teamIdx) { + //计算总的生命值 + if (!totalCountDom) return; + + const [members, assists, badge, swapId] = team; + + const teams = formation.teams; + const [teamsA=[], teamsB=[], teamsC=[]] = teams; + const [teamsA_members, teamsA_assists, teamsA_badge] = teamsA; + const [teamsB_members, teamsB_assists, teamsB_badge] = teamsB; + + //计算当前队伍,2P时则是需要特殊处理 + const team_2p = teamsCount===2 ? members.concat((teamIdx === 1 ? teamsA_members[0] : teamsB_members[0])) : members; + const assistTeam_2p = teamsCount===2 ? assists.concat((teamIdx === 1 ? teamsA_assists[0] : teamsB_assists[0])) : assists; + + + const tRarityDom = totalCountDom.querySelector(".tIf-rarity"); + const tAttrsDom = totalCountDom.querySelector(".tIf-attrs"); + const tTypesDom = totalCountDom.querySelector(".tIf-types"); //统计队伍稀有度总数 if (tRarityDom) { @@ -7419,15 +7463,6 @@ function refreshTeamTotalHP(totalDom, team, teamIdx) { }); } } - - if (tEffectDom) { - //76版队长技能不被换队长所影响 - const leader1id_original = members[0].id; - const leader2id_original = teamsCount===2 ? (teamIdx === 1 ? teamsA_members[0].id : teamsB_members[0].id) : members[5].id; - let effect = tIf_Effect(leader1id,leader2id, leader1id_original,leader2id_original); - if (badge == 22) effect.poisonNoEffect = true; - refreshEffectDom(tEffectDom, effect); - } } function refreshEffectDom(tEffectDom, effect) { const _76board = tEffectDom.querySelector(".icon-skill[data-icon-type='board-size-change']"); diff --git a/solo.html b/solo.html index b2dd251d..a21a6c0c 100644 --- a/solo.html +++ b/solo.html @@ -76,59 +76,34 @@ const teamsCount = 1;