MediaWiki:Calculators.js

From AoP Wiki
Revision as of 13:59, 18 October 2023 by Zmeja (talk | contribs) (Created page with "function bleedResistanceCalculator() { var st = Number(document.getElementById("st").value); var en = Number(document.getElementById("en").value); var ag = Number(document.getElementById("ag").value); var lk = Number(document.getElementById("lk").value); var bleedRes = Math.floor((((21 - lk)*lk)/2 - 15 + ag + 2*en + 2*st) / 2); bleedRes = Math.floor((((21 - lk)*lk)/2 - 15 + ag + 2*en + 2*st) / 2); var bleedDmg = Math.floor((1.0 - Math.pow(2.0,-1.0/Math.max(...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
function bleedResistanceCalculator() {
  var st = Number(document.getElementById("st").value);
  var en = Number(document.getElementById("en").value);
  var ag = Number(document.getElementById("ag").value);
  var lk = Number(document.getElementById("lk").value);
  var bleedRes = Math.floor((((21 - lk)*lk)/2 - 15 + ag + 2*en + 2*st) / 2);
  bleedRes = Math.floor((((21 - lk)*lk)/2 - 15 + ag + 2*en + 2*st) / 2);
  var bleedDmg = Math.floor((1.0 - Math.pow(2.0,-1.0/Math.max(1.0,bleedRes/5.0)))*100);
  document.getElementById("bleedRes").innerHTML = bleedRes;
  document.getElementById("bleedDmg").innerHTML = bleedDmg;
}

$(function () {
  if ($('#bleedResistanceCalculator').length) {
    document.getElementById('bleedResistanceCalculator').innerHTML =
      '<p>Bleed Resistance Calculator:</p>' +
      'Strength: <input id="st" type="number" value="5" min ="1" max="15" style="width: 40px"><br>' +
      'Endurance: <input id="en" type="number" value="5" min ="1" max="15" style="width: 40px"><br>' +
      'Agility: <input id="ag" type="number" value="5" min ="1" max="15" style="width: 40px"><br>' +
      'Luck: <input id="lk" type="number" value="5" min ="1" max="15" style="width: 40px"><br>' +
      '<button type="button" onclick="bleedResistanceCalculator()">Submit</button>' +
      '<p>Bleed Resistance: <a id="bleedRes"></a></p>' +
      '<p>% of bleed into damage per second: <a id="bleedDmg"></a></p>';
  }
});