欢迎来到猴子VS气球的史诗级冒险!
除特殊说明外,本站内容采用CC BY-NC-SA 4.0协议。
本站编辑权限开放,欢迎各位直接动手或者到留言板留言。
欢迎有合作意向者加入QQ群:950568164
欢迎来到气球塔防6 BWIKI!
除特殊说明外,本站内容采用CC BY-NC-SA 4.0协议。
欢迎各位到留言板留言或者加入QQ群:950568164
Widget:RoundCalculator
实现详见回合列表
<script>
(() => {
const maxEndRound = parseInt(document.querySelector('#max-end-round')?.innerText) || 140;
const validateInputs = () => {
let start = parseInt(document.querySelector('#start-round').value);
let end = parseInt(document.querySelector('#end-round').value);
if (start > maxEndRound) {
start = maxEndRound;
document.querySelector('#start-round').value = start;
}
if (end > maxEndRound) {
end = maxEndRound;
document.querySelector('#end-round').value = end;
}
if (start > end) {
start = end;
document.querySelector('#start-round').value = start;
}
return { start: start, end: end }
}
const calculate = () => {
const lines = document.getElementsByClassName('roundtableline');
const rounds = validateInputs();
let totalCash = 0, totalXP = 0, totalRBE = 0, totalLength = 0;
for (let i = 0; i < lines.length; i++) {
const e = lines[i];
const round = parseInt(e.dataset.round);
if (round < rounds.start || round > rounds.end) {
e.style.display = 'none';
continue;
}
e.style.removeProperty('display');
if (!e.dataset.meta) continue;
let dom = e.children;
totalCash += Number(dom[1].innerText);
totalXP += Number(dom[2].innerText);
totalRBE += Number(dom[3].innerText);
totalLength += Number(dom[4].innerText);
}
document.querySelector('#total-cash').innerHTML = Math.round(totalCash * 100) / 100;
document.querySelector('#total-xp').innerHTML = totalXP;
document.querySelector('#total-rbe').innerHTML = totalRBE;
document.querySelector('#total-time').innerHTML = Math.round(totalLength * 10000) / 10000;
}
// add elements
const startRoundInput = document.createElement('input');
startRoundInput.style.width = "100%";
startRoundInput.type = "number";
startRoundInput.min = 1;
startRoundInput.max = maxEndRound;
startRoundInput.value = 1;
startRoundInput.id = "start-round";
const endRoundInput = document.createElement('input');
endRoundInput.style.width = "100%";
endRoundInput.type = "number";
endRoundInput.min = 1;
endRoundInput.max = maxEndRound;
endRoundInput.value = maxEndRound == 31 ? 30 : maxEndRound;
endRoundInput.id = "end-round";
const calcBtn = document.createElement('button');
calcBtn.style.width = "100%"
calcBtn.innerText = "计算"
calcBtn.onclick = calculate;
document.querySelector('#start-round-cell').appendChild(startRoundInput);
document.querySelector('#end-round-cell').appendChild(endRoundInput);
document.querySelector('#calc-btn-cell').appendChild(calcBtn);
calculate();
})();
</script>