Skip to content

Instantly share code, notes, and snippets.

@inkedawn inkedawn/calc.html
Created Jan 13, 2019

Embed
What would you like to do?
剑网3 会心/伤害(治疗)秘籍收益计算
<!DOCTYPE html>
<html>
<head>
<title>会心/伤害(治疗)秘籍收益计算</title>
</head>
<body>
<label for="criticalEffect">输入会效(%):</label>
<input type="text" placeholder="如175" id="criticalEffect" value="175">
<p>秘籍收益(从大到小排序):</p>
<div id="result">
</div>
<script>
function esoterica(type, value) {
this.type = type; // damage or critical
this.value = value; // percentage
}
esoterica.prototype.calcRatio = function(criticalEffect) {
if (this.type === "damage") return 1*this.value;
if (this.type === "critical") return (criticalEffect-1)*this.value;
return 0;
}
esoterica.prototype.toString = function() {
if (this.type === "damage") return this.value.toString()+"%伤害(或治疗)";
if (this.type === "critical") return this.value.toString()+"%会心";
return "unknown esoterica";
}
function clearResult() {
let result = document.querySelector("#result");
for (elem of result.childNodes) {
result.removeChild(elem);
}
}
document.querySelector("#criticalEffect").addEventListener("input", function(){
let effect = parseInt(document.querySelector("#criticalEffect").value)/100;
let eso = [];
for (var i=1; i<=6; i++) {
eso.push(new esoterica("damage", i));
eso.push(new esoterica("critical", i));
}
eso.sort((a,b)=>b.calcRatio(effect)-a.calcRatio(effect));
console.log(eso);
result.innerText = eso.join(" > ");
});
document.querySelector("#criticalEffect").dispatchEvent(new Event("input"));
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.