加入盾觉醒的HP计算
This commit is contained in:
parent
bd562be3bb
commit
fae99df43e
|
@ -8,6 +8,7 @@ Number.prototype.bigNumberToString = function() {
|
|||
|
||||
let numTemp = negative ? Math.abs(this) : this.valueOf();
|
||||
if (!numTemp) return "0";
|
||||
if (numTemp == Infinity) return "Infinity";
|
||||
const grouping = 1e3;
|
||||
const unit = ['', 'K', 'M', 'G', 'T', 'P'];
|
||||
const numParts = [];
|
||||
|
|
|
@ -394,6 +394,7 @@ Number.prototype.bigNumberToString = function() {
|
|||
|
||||
let numTemp = negative ? Math.abs(this) : this.valueOf();
|
||||
if (!numTemp) return "0";
|
||||
if (numTemp == Infinity) return "無窮大";
|
||||
const grouping = 1e4;
|
||||
const unit = ['','萬','億','兆','京','垓'];
|
||||
const numParts = [];
|
||||
|
|
|
@ -393,6 +393,7 @@ Number.prototype.bigNumberToString = function() {
|
|||
|
||||
let numTemp = negative ? Math.abs(this) : this.valueOf();
|
||||
if (!numTemp) return "0";
|
||||
if (numTemp == Infinity) return "无穷大";
|
||||
const grouping = 1e4;
|
||||
const unit = ['', '万', '亿', '兆', '京', '垓'];
|
||||
const numParts = [];
|
||||
|
|
|
@ -1391,7 +1391,7 @@ function countMoveTime(team, leader1id, leader2id, teamIdx) {
|
|||
|
||||
moveTime.duration.awoken += latentMoveTime.reduce((duration, la) =>
|
||||
duration + team[0].reduce((count, member) =>
|
||||
count + (member.latent ? member.latent.filter(l => l == la.index).length : 0), 0) * la.value, 0);
|
||||
count + (member?.latent?.filter(l => l == la.index)?.length ?? 0), 0) * la.value, 0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1464,6 +1464,36 @@ function getReduceRange(reduceScales)
|
|||
});
|
||||
return attrsRanges;
|
||||
}
|
||||
//获取盾潜觉的减伤比例组
|
||||
function getAttrShieldAwokenReduceScales(team) {
|
||||
//5种盾潜觉
|
||||
return [
|
||||
{awoken:4,latent1:6,latent2:32},
|
||||
{awoken:5,latent1:7,latent2:33},
|
||||
{awoken:6,latent1:8,latent2:34},
|
||||
{awoken:7,latent1:9,latent2:35},
|
||||
{awoken:8,latent1:10,latent2:36},
|
||||
].map((shield, attrIdx)=>{
|
||||
const akNum = awokenCountInTeam(team, shield.awoken, solo, teamsCount); //获取盾觉醒个数,没有大觉醒
|
||||
const latent1Num = team[0].reduce((count, member) => count + (member?.latent?.filter(l => l == shield.latent1)?.length ?? 0), 0);
|
||||
const latent2Num = team[0].reduce((count, member) => count + (member?.latent?.filter(l => l == shield.latent2)?.length ?? 0), 0);
|
||||
|
||||
const reduce = {
|
||||
scale: 0,
|
||||
hp: {
|
||||
max: 100,
|
||||
min: 0
|
||||
},
|
||||
probability: 1,
|
||||
attrs: 31, //5色是31
|
||||
};
|
||||
|
||||
reduce.scale = Math.min(akNum * 0.07 + latent1Num * 0.01 + latent2Num * 0.025, 1);
|
||||
if (reduce.scale == 0) return false;
|
||||
reduce.attrs = 1 << attrIdx;
|
||||
return reduce;
|
||||
}).filter(Boolean);
|
||||
}
|
||||
//获取盾减伤比例组
|
||||
function getReduceScales(leaderid) {
|
||||
const searchTypeArray = [16, 17, 36, 38, 43, 129, 163, 130, 131, 178, 151, 169, 198, 170, 182, 193, 171, 183, 235];
|
||||
|
|
46
script.js
46
script.js
|
@ -2724,12 +2724,12 @@ function initialize() {
|
|||
|
||||
//显示HP的详细值
|
||||
const hpDetailDialog = formationBox.querySelector(".dialog-hp-detail");
|
||||
hpDetailDialog.initialing = function(reduceAttrRanges, tHP, tHPNoAwoken)
|
||||
hpDetailDialog.initialing = function(reduceAttrRanges, reduceAttrRangesWithOutAwoken, tHP, tHPNoAwoken)
|
||||
{
|
||||
const dialogContent = this.querySelector(".dialog-content");
|
||||
const fragment = document.createDocumentFragment();
|
||||
|
||||
function insertHpRangeTable(reduceRanges, tHP, tHPNoAwoken, attr)
|
||||
function insertHpRangeTable(reduceRanges, reduceRangesWithOutAwoken, tHP, tHPNoAwoken, attr)
|
||||
{
|
||||
const table = document.createElement("table");
|
||||
table.className = "hp-range-table";
|
||||
|
@ -2751,11 +2751,17 @@ function initialize() {
|
|||
reduceRow.appendChild(document.createElement("th"));
|
||||
const reduceHpRow = tBody.insertRow();
|
||||
reduceHpRow.className = "reduce-general";
|
||||
reduceHpRow.appendChild(document.createElement("th"));
|
||||
const reduceHpRowTitle = reduceHpRow.appendChild(document.createElement("th"));
|
||||
const reduceHpRowTitleSheild = reduceHpRowTitle.appendChild(document.createElement("icon"));
|
||||
reduceHpRowTitleSheild.className = "sheild";
|
||||
const reduceHpNoAwokenRow = tBody.insertRow();
|
||||
reduceHpNoAwokenRow.className = "reduce-awoken-bind";
|
||||
reduceHpNoAwokenRow.appendChild(document.createElement("th"));
|
||||
reduceRanges.forEach(range=>{
|
||||
const reduceHpNoAwokenRowTitle = reduceHpNoAwokenRow.appendChild(document.createElement("th"));
|
||||
const reduceHpNoAwokenRowTitleSheild = reduceHpNoAwokenRowTitle.appendChild(document.createElement("icon"));
|
||||
reduceHpNoAwokenRowTitleSheild.className = "sheild";
|
||||
for (let ri=0;ri<reduceRanges.length;ri++) {
|
||||
const range = reduceRanges[ri];
|
||||
const rangeWOA = reduceRangesWithOutAwoken[ri];
|
||||
const hpRange = rangeRow.insertCell();
|
||||
const hpRangeMin = hpRange.appendChild(document.createElement("span"));
|
||||
hpRangeMin.className = "hp-range-min";
|
||||
|
@ -2774,6 +2780,11 @@ function initialize() {
|
|||
const reduce = reduceRow.insertCell();
|
||||
const reduceScale = reduce.appendChild(document.createElement("span"));
|
||||
reduceScale.textContent = `${parseFloat((range.scale * 100).toFixed(2))}`;
|
||||
if (rangeWOA.scale !== range.scale) {
|
||||
reduce.appendChild(document.createTextNode("/"));
|
||||
const reduceScaleWithOutAwoken = reduce.appendChild(document.createElement("span"));
|
||||
reduceScaleWithOutAwoken.textContent = `${parseFloat((rangeWOA.scale * 100).toFixed(2))}`;
|
||||
}
|
||||
|
||||
if (range.probability < 1)
|
||||
{
|
||||
|
@ -2788,18 +2799,19 @@ function initialize() {
|
|||
reduceGeneral.textContent = `${Math.round(tHP * (range.min / 100) / (1 - range.scale)).bigNumberToString()} ~ ${Math.round(tHP * (range.max/100) / (1 - range.scale)).bigNumberToString()}`;
|
||||
|
||||
const reduceAwokenBind = reduceHpNoAwokenRow.insertCell();
|
||||
reduceAwokenBind.textContent = `${Math.round(tHPNoAwoken * (range.min / 100) / (1 - range.scale)).bigNumberToString()} ~ ${Math.round(tHPNoAwoken * (range.max/100) / (1 - range.scale)).bigNumberToString()}`;
|
||||
});
|
||||
reduceAwokenBind.textContent = `${Math.round(tHPNoAwoken * (rangeWOA.min / 100) / (1 - rangeWOA.scale)).bigNumberToString()} ~ ${Math.round(tHPNoAwoken * (rangeWOA.max/100) / (1 - rangeWOA.scale)).bigNumberToString()}`;
|
||||
}
|
||||
return table;
|
||||
}
|
||||
if (reduceAttrRanges.some(r=>r != reduceAttrRanges[0])) //有指定属性减伤
|
||||
{
|
||||
reduceAttrRanges.forEach((reduceRanges, ridx)=>fragment.appendChild(insertHpRangeTable(reduceRanges, tHP, tHPNoAwoken, ridx)));
|
||||
for (let ri=0;ri<reduceAttrRanges.length;ri++) {
|
||||
fragment.appendChild(insertHpRangeTable(reduceAttrRanges[ri], reduceAttrRangesWithOutAwoken[ri], tHP, tHPNoAwoken, ri));
|
||||
}
|
||||
}
|
||||
else //只有阶梯盾
|
||||
{
|
||||
const reduceRanges = reduceAttrRanges[0];
|
||||
fragment.appendChild(insertHpRangeTable(reduceRanges, tHP, tHPNoAwoken, 31));
|
||||
fragment.appendChild(insertHpRangeTable(reduceAttrRanges[0], reduceAttrRangesWithOutAwoken[0], tHP, tHPNoAwoken, 31));
|
||||
}
|
||||
|
||||
dialogContent.innerHTML = "";
|
||||
|
@ -2811,7 +2823,7 @@ function initialize() {
|
|||
const reduceDetailsBars = Array.from(formationBox.querySelectorAll(".tIf-total-hp .reduce-details"));
|
||||
reduceDetailsBars.forEach(bar => {
|
||||
bar.onclick = function(){
|
||||
hpDetailDialog.show(this.reduceAttrRanges, this.tHP, this.tHPNoAwoken);
|
||||
hpDetailDialog.show(this.reduceAttrRangesWithShieldAwoken, this.reduceAttrRanges, this.tHP, this.tHPNoAwoken);
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -5338,15 +5350,19 @@ function refreshTeamTotalHP(totalDom, team, teamIdx) {
|
|||
if (tHpDom) {
|
||||
const reduceScales1 = getReduceScales(leader1id);
|
||||
const reduceScales2 = getReduceScales(leader2id);
|
||||
const reduceAttrSeildAwokenScales = getAttrShieldAwokenReduceScales(team);
|
||||
const reduceAttrRanges = getReduceRange(reduceScales1.concat(reduceScales2));
|
||||
const reduceAttrRangesWithShieldAwoken = getReduceRange(reduceScales1.concat(reduceScales2, reduceAttrSeildAwokenScales));
|
||||
//将所有范围平铺,然后选择盾最少那个作为基础盾值
|
||||
const leastScale = reduceAttrRanges.flat().sort((a,b)=>a.scale-b.scale)[0];
|
||||
|
||||
const hpBar = totalDom.querySelector(".reduce-details");
|
||||
|
||||
if (reduceAttrRanges.some(r=>r != reduceAttrRanges[0]) || reduceAttrRanges[0].length > 1 || reduceAttrRanges[0][0].probability < 1) //有阶梯盾或者有指定属性减伤或者减伤比例不是100%
|
||||
if (reduceAttrRangesWithShieldAwoken.some(r=>r != reduceAttrRangesWithShieldAwoken[0]) ||
|
||||
reduceAttrRangesWithShieldAwoken[0].length > 1 ||
|
||||
reduceAttrRangesWithShieldAwoken[0][0].probability < 1) //有HP阶梯盾或者有指定属性减伤或者减伤几率不是100%
|
||||
{
|
||||
drawHpInfo(hpBar, reduceAttrRanges);
|
||||
drawHpInfo(hpBar, reduceAttrRangesWithShieldAwoken);
|
||||
hpBar.classList.remove(className_displayNone);
|
||||
}else
|
||||
{
|
||||
|
@ -5377,11 +5393,13 @@ function refreshTeamTotalHP(totalDom, team, teamIdx) {
|
|||
tHPNoAwoken = Math.round(Math.round(tHPNoAwoken) * badgeHPScale);
|
||||
|
||||
//记录到bar中,方便打开详情时调用
|
||||
hpBar.reduceAttrRanges = reduceAttrRanges;
|
||||
hpBar.reduceAttrRangesWithShieldAwoken = reduceAttrRangesWithShieldAwoken; //有盾觉醒的
|
||||
hpBar.reduceAttrRanges = reduceAttrRanges; //没有盾觉醒的
|
||||
hpBar.tHP = tHP;
|
||||
hpBar.tHPNoAwoken = tHPNoAwoken;
|
||||
|
||||
const tReduceHP = Math.floor(tHP / (1 - totalReduce)); //队伍正常满血加上盾能承受的最大伤害
|
||||
|
||||
const tReduceHPNoAwoken = Math.floor(tHPNoAwoken / (1 - totalReduce)); //队伍封觉醒满血加上盾能承受的最大伤害
|
||||
|
||||
const tHpDom_general = tHpDom.querySelector(".general");
|
||||
|
|
|
@ -8043,7 +8043,7 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"browser-compatibility.js",
|
||||
"cd34f33d1c77c7fff4ae17b448eac5ad"
|
||||
"1d3c87e415212a226eb81ed0de77e4ed"
|
||||
],
|
||||
[
|
||||
"index.html",
|
||||
|
@ -8067,11 +8067,11 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"script-universal_function.js",
|
||||
"a586571c5e43f8f52bc2fe1d36b1afd7"
|
||||
"429cfed7bc5fc12a2152555e45241e61"
|
||||
],
|
||||
[
|
||||
"script.js",
|
||||
"a4090df41cf38ae6903771338aa84ac1"
|
||||
"d51fccfd2c12a45a632b10313a58520b"
|
||||
],
|
||||
[
|
||||
"solo.html",
|
||||
|
@ -8091,7 +8091,7 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"triple.html",
|
||||
"a7858b668418ca1c2f37f75c85fd0dac"
|
||||
"a5deb7b8a7a1c2a9e077e079fb18271c"
|
||||
],
|
||||
[
|
||||
"languages/en.css",
|
||||
|
@ -8099,7 +8099,7 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"languages/en.js",
|
||||
"aee402fff8b70ee1fa4ad042cf05fb53"
|
||||
"e4985277782847d8a82be1da633a4d3d"
|
||||
],
|
||||
[
|
||||
"languages/ja.css",
|
||||
|
@ -8135,7 +8135,7 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"languages/zh-TW.js",
|
||||
"ee248d17912a7986676f190f7fb215d6"
|
||||
"b97067d6ff6412a2ace98f8aa425dc08"
|
||||
],
|
||||
[
|
||||
"languages/zh.css",
|
||||
|
@ -8143,7 +8143,7 @@ const cachesMap = new Map([
|
|||
],
|
||||
[
|
||||
"languages/zh.js",
|
||||
"8b4ac347a5894174b258b95e84799f75"
|
||||
"c7d9f3adbcaf1d71bb8326ea2b33f0af"
|
||||
],
|
||||
[
|
||||
"images/attrs.png",
|
||||
|
|
Loading…
Reference in New Issue