SHARE
TWEET

Untitled

a guest Jun 17th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <table>
  2.   <tr>
  3.     <td>
  4.       <label>Base Attack (Without any equipment equipped): </label>
  5.     </td>
  6.     <td>
  7.       <input placeholder="e.g: 290" id="abase">
  8.     </td>
  9.   </tr>
  10.   <tr>
  11.     <td>
  12.       <label>Weapon Attack Range: </label>
  13.     </td>
  14.     <td>
  15.       <input placeholder="e.g: 800-1000" id="abaseeq">
  16.     </td>
  17.   </tr>
  18.   <tr>
  19.     <td>
  20.       <label>Weapon + ?</label>
  21.     </td>
  22.     <td>
  23.       <input placeholder="e.g: 9" id="weapon+">
  24.     </td>
  25.   </tr>
  26.   <tr>
  27.     <td>
  28.       <label>Enemy Defence + ? </label>
  29.     </td>
  30.     <td>
  31.       <input placeholder="e.g: 6" id="enemydef+">
  32.     </td>
  33.   </tr>
  34.   <tr>
  35.     <td>
  36.       <button id="calculate">
  37.   Calculate
  38.   </button>
  39.   </td>
  40.   <td>
  41.     <div id="result"></div>
  42.   </td>
  43.   </tr>
  44.  
  45. </table>
  46.      
  47. $(document).ready(function() {
  48.   $('#calculate').on('click', function() {
  49.     var abase = $('#abase').val;
  50.     var abaseEq = $('#abaseeq').val;
  51.     var abaseEqLength = abaseEq.length;
  52.     abaseEqLength -= 1;
  53.     var weaponlvl = $('#weapon+').val;
  54.     var enemydeflvl = $('#enemydef+').val;
  55.     var updifference = weaponlvl - enemydeflvl;
  56.     var plusdifference = [0, '10%', '15%', '22%', '32%', '43%', '54%', '65%', '90%', '120%', '200%'];
  57.     var negdifference = {};
  58.     var result;
  59.     var aeqmin, aeqmax;
  60.     var lowestdamage, maxdamage;
  61.     var negindex;
  62.     var negindexplus = 0;
  63.     for (var i = 0; i <= abaseEqLength; i++) {
  64.       if (abaseEq[i] == '-') {
  65.         negindex = i;
  66.         negindexplus += (negindex + 1);
  67.       }
  68.     }
  69.     for (var x = 0; i < negindex; x++) {
  70.       lowestdamage = lowestdamage + abaseEq[x];
  71.       console.log("Lowest Damage: " + lowestdamage);
  72.     }
  73.     for (var y = negindexplus; y <= abaseEqLength; y++) {
  74.       maxdamage = maxdamage + abaseEq[y];
  75.       console.log("Max Damage: " + maxdamage);
  76.     }
  77.     if (updifference => 0 && updifference <= 10) {
  78.       updifference = plusdifference[updifference];
  79.       result = "pos";
  80.     }
  81.     if (updifference < 0 && updifference >= -10) {
  82.       var negarray = negdifference * -1;
  83.       negdifference[updifference] = plusdifference[negarray];
  84.     }
  85.     var mindamage = parseInt(lowestdamage);
  86.     var maxidamage = parseInt(maxdamage);
  87.     if (result == "pos") {
  88.       aeqmin = mindamage * (1 + plusdifference[updifference]);
  89.       aeqmax = maxidamage * (1 + plusdifference[updifference]);
  90.     }
  91.     if (aeqmax > 0) {
  92.       $('#result').html = aeqmin + "~" + aeqmax;
  93.     }
  94.   }); // calculate on click function
  95. }); // document ready
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top