diff --git a/script.js b/script.js index 9c4eddfd..b1f99761 100644 --- a/script.js +++ b/script.js @@ -180,17 +180,18 @@ Member.prototype.getAttrsTypesWithWeapon = function(assist) { let changeAttr, appendTypes; if (assistAwakenings?.includes(49)) { //如果有武器 //更改副属性 - changeAttr = assistAwakenings.find(ak=>ak >= 91 && ak <= 95); - if (changeAttr) attrs[1] = changeAttr - 91; + changeAttr = assistAwakenings.find(ak=>ak >= 91 && ak <= 95); //筛选出武器觉醒 + if (changeAttr) attrs[1] = changeAttr - 91; //变换为属性 //添加类型 - appendTypes = assistAwakenings.filter(ak=>ak >= 83 && ak <= 90); - appendTypes = appendTypes.map(type=> + appendTypes = assistAwakenings.filter(ak=>ak >= 83 && ak <= 90); //筛选出武器觉醒 + appendTypes = appendTypes.map(type=> //变换为类型 typekiller_for_type.find(t=>(type - 52) === t.awoken).type); - appendTypes.forEach(appendType=>types.add(appendType)); + appendTypes = appendTypes.filter(ak=>!types.has(ak)); //去除重复的 + appendTypes.forEach(appendType=>types.add(appendType)); //添加到类型里 } return { - attrs: attrs, changeAttr: Boolean(changeAttr), - types: Array.from(types), appendType: Boolean(appendTypes?.length) + attrs: attrs, isChangeAttr: Boolean(changeAttr), + types: Array.from(types), isAppendType: Boolean(appendTypes?.length), appendTypes }; } Member.prototype.outObj = function() { @@ -294,11 +295,11 @@ MemberTeam.prototype.loadFromMember = function(m) { this.id = m.id; if (m.level != undefined) this.level = m.level; if (m.awoken != undefined) this.awoken = m.awoken; - if (m.plus != undefined && Array.isArray(m.plus) && m.plus.length >= 3 && (m.plus[0] + m.plus[1] + m.plus[2]) > 0) this.plus = JSON.parse(JSON.stringify(m.plus)); - if (m.latent != undefined && Array.isArray(m.latent) && m.latent.length >= 1) this.latent = JSON.parse(JSON.stringify(m.latent)); + if (Array.isArray(m?.plus) && m.plus.length >= 3 && (m.plus[0] + m.plus[1] + m.plus[2]) > 0) this.plus = JSON.parse(JSON.stringify(m.plus)); + if (Array.isArray(m?.latent) && m.latent.length >= 1) this.latent = JSON.parse(JSON.stringify(m.latent)); if (m.sawoken != undefined) this.sawoken = m.sawoken; - if (m.ability != undefined && Array.isArray(m.ability) && m.plus.length >= 3) this.ability = JSON.parse(JSON.stringify(m.ability)); - if (m.abilityNoAwoken != undefined && Array.isArray(m.abilityNoAwoken) && m.plus.length >= 3) this.abilityNoAwoken = JSON.parse(JSON.stringify(m.abilityNoAwoken)); + if (Array.isArray(m?.ability) && m.ability.length >= 3) this.ability = JSON.parse(JSON.stringify(m.ability)); + if (Array.isArray(m?.abilityNoAwoken) && m.abilityNoAwoken.length >= 3) this.abilityNoAwoken = JSON.parse(JSON.stringify(m.abilityNoAwoken)); if (m.skilllevel != undefined) this.skilllevel = m.skilllevel; }; @@ -6022,20 +6023,28 @@ function refreshMemberTypes(memberTypesDom, team, idx) { if (!memberTypesDom) return; //如果没有dom,直接跳过 const member = team[0][idx]; const assist = team[1][idx]; - let {types = [], appendType = false} = member.getAttrsTypesWithWeapon(assist) || {}; - appendType = appendType && (types.length > member.card.types.length); //appendType还需要满足type数量大于角色真实的type - const memberTypesUl = memberTypesDom.querySelector(`.member-types-${idx + 1} .types-ul`); - memberTypesUl.innerHTML = ''; - for (let i = 0;i < types.length; i++) { + let {types = [], isAppendType = false, appendTypes} = member.getAttrsTypesWithWeapon(assist) || {}; + + function typeIcon(tid, isAppendType = false) { const iconLi = document.createElement("li"); const icon = iconLi.appendChild(document.createElement("icon")) icon.className = "type-icon"; - icon.setAttribute("data-type-icon", types[i]); - if (appendType && i == (types.length - 1)) { + icon.setAttribute("data-type-icon", tid); + if (isAppendType) { iconLi.classList.add('append-type'); } - memberTypesUl.appendChild(iconLi); + return iconLi; } + + const fragment = document.createDocumentFragment(); + member.card.types.forEach(tid=>fragment.appendChild(typeIcon(tid))); + if (isAppendType) { + appendTypes.forEach(tid=>fragment.appendChild(typeIcon(tid, true))); + } + + const memberTypesUl = memberTypesDom.querySelector(`.member-types-${idx + 1} .types-ul`); + memberTypesUl.innerHTML = ''; + memberTypesUl.appendChild(fragment); } //刷新队员觉醒 function refreshMemberAwoken(memberAwokenDom, assistAwokenDom, team, idx) { diff --git a/service-worker.js b/service-worker.js index d5227524..4607b466 100644 --- a/service-worker.js +++ b/service-worker.js @@ -22791,7 +22791,7 @@ const cachesMap = new Map([ ], [ "script.js", - "fee71c0f81ee582aab89420dab23c006" + "6d6700b0ccb0da3aa92f6dbaf785320c" ], [ "solo.html", @@ -22803,7 +22803,7 @@ const cachesMap = new Map([ ], [ "style.css", - "11b4a3fd65e597fe3ff3bbdb043f0911" + "060af75969aef562fc587f09231a01a3" ], [ "temp.js", diff --git a/style.css b/style.css index 0e44d3cb..f2f1f71b 100644 --- a/style.css +++ b/style.css @@ -532,10 +532,14 @@ ul{ font-family: var(--game-font-family); content: "+"; font-size: 15px; - line-height: 10px; + line-height: 15px; + vertical-align: top; color: yellow; text-shadow: black 0 0 1px,black 0 0 2px, black 2px 2px 0; } +.member-types .append-type+.append-type::before{ + display: none; +} .member-types .append-type .type-icon{ background-color: lightgreen; box-shadow: 1px 1px 3px lightgreen,1px 1px 3px lightgreen,1px 1px 3px lightgreen;