Widget:DropRateCalculator

From Granblue Fantasy Wiki
Jump to navigation Jump to search
<table class="wikitable">
  <tr>
    <th colspan="2">Boost sources</th>
    <th>Total</th>
  </tr>
  <tr>
    <td><label for="bounty-input-boost-mh">
      <img src="/images/thumb/d/dd/WeaponSeries_Class_Champion_Weapons_icon.png/25px-WeaponSeries_Class_Champion_Weapons_icon.png" decoding="async" width="25" height="25" srcset="/images/thumb/d/dd/WeaponSeries_Class_Champion_Weapons_icon.png/38px-WeaponSeries_Class_Champion_Weapons_icon.png 1.5x, /images/thumb/d/dd/WeaponSeries_Class_Champion_Weapons_icon.png/50px-WeaponSeries_Class_Champion_Weapons_icon.png 2x" data-file-width="54" data-file-height="54" />
      Main hand</label></td>
    <td>
      <select id="bounty-input-boost-mh" data-mul="skill">
        <option value="0.0" selected>0%</option>
        <option value="0.01">1%</option>
        <option value="0.02">2%</option>
        <option value="0.03">3%</option>
        <option value="0.04">4%</option>
        <option value="0.05">5%</option>
        <option value="0.06">6%</option>
        <option value="0.07">7%</option>
        <option value="0.08">8%</option>
        <option value="0.09">9%</option>
        <option value="0.10">10%</option>
      </select>
    </td>
    <td rowspan="6" style="text-align: center;"><span id="bounty-output-sum-skill"></span></td>
  </tr>
  <tr>
    <td><label for="bounty-input-boost-ms">
      <img src="/images/thumb/3/32/Summon_s_2030026000.jpg/25px-Summon_s_2030026000.jpg" decoding="async" width="25" height="25" srcset="/images/thumb/3/32/Summon_s_2030026000.jpg/38px-Summon_s_2030026000.jpg 1.5x, /images/thumb/3/32/Summon_s_2030026000.jpg/50px-Summon_s_2030026000.jpg 2x" data-file-width="260" data-file-height="260" />
      Main summon</label></td>
    <td>
      <select id="bounty-input-boost-ms" data-mul="skill">
        <option value="0.0" selected>0%</option>
        <option value="0.10">10%</option>
        <option value="0.15">15%</option>
        <option value="0.20">20%</option>
        <option value="0.25">25%</option>
        <option value="0.30">30%</option>
      </select>
    </td>
  </tr>
  <tr>
    <td><label for="bounty-input-boost-fs">
      <img alt="Summon s 2040114000.jpg" src="/images/thumb/9/97/Summon_s_2040114000.jpg/25px-Summon_s_2040114000.jpg" decoding="async" width="25" height="25" srcset="/images/thumb/9/97/Summon_s_2040114000.jpg/38px-Summon_s_2040114000.jpg 1.5x, /images/thumb/9/97/Summon_s_2040114000.jpg/50px-Summon_s_2040114000.jpg 2x" data-file-width="260" data-file-height="260" />
      Friend summon</label></td>
    <td>
      <select id="bounty-input-boost-fs" data-mul="skill">
        <option value="0.0" selected>0%</option>
        <option value="0.10">10%</option>
        <option value="0.15">15%</option>
        <option value="0.20">20%</option>
        <option value="0.25">25%</option>
        <option value="0.30">30%</option>
      </select>
    </td>
  </tr>
  <tr>
    <td><label for="bounty-input-boost-tien">
      <span class="image_link"><a href="/Tien" title="Tien"><img src="/images/thumb/b/bf/Npc_s_3040039000_01.jpg/25px-Npc_s_3040039000_01.jpg" decoding="async" srcset="/images/thumb/b/bf/Npc_s_3040039000_01.jpg/38px-Npc_s_3040039000_01.jpg 1.5x, /images/thumb/b/bf/Npc_s_3040039000_01.jpg/50px-Npc_s_3040039000_01.jpg 2x" data-file-width="260" data-file-height="260" width="25" height="25"></a> <a href="/Tien" title="Tien">Tien</a></span>
      </label></td>
    <td>
      <select id="bounty-input-boost-tien" data-mul="skill">
        <option value="0.0" selected>No</option>
        <option value="0.05">4★</option>
        <option value="0.10">5★</option>
      </select>
    </td>
  </tr>
  <tr>
    <td><label for="bounty-input-boost-richard">
      <span class="image_link"><a href="/Richard_(SR)" title="Richard (SR)"><img alt="Npc s 3030267000 01.jpg" src="/images/thumb/e/ed/Npc_s_3030267000_01.jpg/25px-Npc_s_3030267000_01.jpg" decoding="async" srcset="/images/thumb/e/ed/Npc_s_3030267000_01.jpg/38px-Npc_s_3030267000_01.jpg 1.5x, /images/thumb/e/ed/Npc_s_3030267000_01.jpg/50px-Npc_s_3030267000_01.jpg 2x" data-file-width="260" data-file-height="260" width="25" height="25"></a> <a href="/Richard_(SR)" title="Richard (SR)">Richard (SR)</a></span>
      </label></td>
    <td>
      <select id="bounty-input-boost-richard" data-mul="skill">
        <option value="0.0" selected>No</option>
        <option value="0.01">Yes</option>
      </select>
    </td>
  </tr>
  <tr>
    <td><label for="bounty-input-boost-barv">
      <span class="image_link"><a href="/Dragon_Bar_V" title="Dragon Bar V"><img src="/images/thumb/c/c0/Dragon_Bar_V_square.jpg/25px-Dragon_Bar_V_square.jpg" decoding="async" srcset="/images/thumb/c/c0/Dragon_Bar_V_square.jpg/38px-Dragon_Bar_V_square.jpg 1.5x, /images/thumb/c/c0/Dragon_Bar_V_square.jpg/50px-Dragon_Bar_V_square.jpg 2x" data-file-width="260" data-file-height="260" width="25" height="25"></a> <a href="/Dragon_Bar_V" title="Dragon Bar V">Dragon Bar V</a></span>
      </label></td>
    <td>
      <select id="bounty-input-boost-barv" data-mul="skill">
        <option value="0.0" selected>No</option>
        <option value="0.03">Yes</option>
      </select>
    </td>
  </tr>
  <tr>
    <td><label for="bounty-input-boost-crew">
      <img alt="Guild parts icon 13.png" src="/images/thumb/3/38/Guild_parts_icon_13.png/25px-Guild_parts_icon_13.png" decoding="async" width="25" height="25" srcset="/images/thumb/3/38/Guild_parts_icon_13.png/38px-Guild_parts_icon_13.png 1.5x, /images/thumb/3/38/Guild_parts_icon_13.png/50px-Guild_parts_icon_13.png 2x" data-file-width="128" data-file-height="128" />
      Crew buff</label></td>
    <td>
      <select id="bounty-input-boost-crew" data-mul="crew">
        <option value="0.0">No</option>
        <option value="0.10">Lvl 1</option>
        <option value="0.15">Lvl 2</option>
        <option value="0.20" selected>Lvl 3</option>
      </select>
    </td>
    <td style="text-align: center;"><span id="bounty-output-sum-crew"></span></td>
  </tr>
  <tr>
    <td><label for="bounty-input-boost-jd">
      <img alt="Support 10301.png" src="/images/thumb/1/15/Support_10301.png/25px-Support_10301.png" decoding="async" width="25" height="25" srcset="/images/thumb/1/15/Support_10301.png/38px-Support_10301.png 1.5x, /images/thumb/1/15/Support_10301.png/50px-Support_10301.png 2x" data-file-width="150" data-file-height="150" />
      Journey drops</label></td>
    <td>
      <select id="bounty-input-boost-jd" data-mul="jd">
        <option value="0.0">No</option>
        <option value="0.025">Lvl 1</option>
        <option value="0.05">Lvl 2</option>
        <option value="0.075">Lvl 3</option>
        <option value="0.10">Lvl 4</option>
        <option value="0.15">Lvl 5</option>
        <option value="0.05">Lvl 1 (Festival)</option>
        <option value="0.10">Lvl 2 (Festival)</option>
        <option value="0.15">Lvl 3 (Festival)</option>
        <option value="0.20">Lvl 4 (Festival)</option>
        <option value="0.30">Lvl 5 (Festival)</option>
      </select>
    </td>
    <td style="text-align: center;"><span id="bounty-output-sum-jd"></span></td>
  </tr>
  <tr>
    <td><label for="bounty-input-boost-th">
      <img alt="Status Bounty.png" src="/images/thumb/c/c7/Status_Bounty.png/25px-Status_Bounty.png" decoding="async" width="25" height="25" srcset="/images/thumb/c/c7/Status_Bounty.png/38px-Status_Bounty.png 1.5x, /images/thumb/c/c7/Status_Bounty.png/50px-Status_Bounty.png 2x" data-file-width="64" data-file-height="64" />
      Bounty</label></td>
    <td>
      <select id="bounty-input-boost-th" data-mul="th">
        <option value="0.0" selected>No</option>
        <option value="0.2">Lvl 1</option>
        <option value="0.22">Lvl 2</option>
        <option value="0.24">Lvl 3</option>
        <option value="0.26">Lvl 4</option>
        <option value="0.28">Lvl 5</option>
        <option value="0.31">Lvl 6</option>
        <option value="0.35">Lvl 7</option>
        <option value="0.40">Lvl 8</option>
        <option value="0.50">Lvl 9</option>
        <option value="0.70">Lvl 10</option>
      </select>
    </td>
    <td style="text-align: center;"><span id="bounty-output-sum-th"></span></td>
  </tr>
  <tr>
    <th colspan="3">
      <label for="bounty-output-sum-total">
        <img alt="Icon Gold Chest.png" src="/images/thumb/3/32/Icon_Gold_Chest.png/25px-Icon_Gold_Chest.png" decoding="async" width="25" height="25" srcset="/images/thumb/3/32/Icon_Gold_Chest.png/38px-Icon_Gold_Chest.png 1.5x, /images/thumb/3/32/Icon_Gold_Chest.png/50px-Icon_Gold_Chest.png 2x" data-file-width="81" data-file-height="81" />
        Total Drop Rate Boost:</label>
      <span id="bounty-output-sum-total"></span>
    </th>
  </tr>
  <tr>
    <th colspan="2">Target</th>
    <th>Expected</th>
  </tr>
  <tr>
    <td>
      <label for="bounty-input-chest-percent">
        <img alt="Icon Gold Chest.png" src="/images/thumb/3/32/Icon_Gold_Chest.png/25px-Icon_Gold_Chest.png" decoding="async" width="25" height="25" srcset="/images/thumb/3/32/Icon_Gold_Chest.png/38px-Icon_Gold_Chest.png 1.5x, /images/thumb/3/32/Icon_Gold_Chest.png/50px-Icon_Gold_Chest.png 2x" data-file-width="81" data-file-height="81" />
        Chest Drop Rate</label>
    </td>
    <td>
      <input id="bounty-input-chest-percent" type="number" value="55" min="0.1" max="100.0" step="0.1"
             style="width: 75px;"/> %
    </td>
    <td style="text-align: center;"><span id="bounty-output-chest-percent"></span></td>
  </tr>
  <tr>
    <td>
      <label for="bounty-input-item-percent">
        <img alt="Icon Gold Chest.png" src="/images/thumb/3/32/Icon_Gold_Chest.png/25px-Icon_Gold_Chest.png" decoding="async" width="25" height="25" srcset="/images/thumb/3/32/Icon_Gold_Chest.png/38px-Icon_Gold_Chest.png 1.5x, /images/thumb/3/32/Icon_Gold_Chest.png/50px-Icon_Gold_Chest.png 2x" data-file-width="81" data-file-height="81" />
        Item Drop Rate</label>
    </td>
    <td>
      <input id="bounty-input-item-percent" type="number" value="7" min="0.1" max="100.0" step="0.1"
             style="width: 75px;"/> %
    </td>
    <td style="text-align: center;"><span id="bounty-output-item-percent"></span></td>
  </tr>
  <tr>
    <td>
      <label for="bounty-input-samples">
        <img alt="Icon Gold Chest.png" src="/images/thumb/3/32/Icon_Gold_Chest.png/25px-Icon_Gold_Chest.png" decoding="async" width="25" height="25" srcset="/images/thumb/3/32/Icon_Gold_Chest.png/38px-Icon_Gold_Chest.png 1.5x, /images/thumb/3/32/Icon_Gold_Chest.png/50px-Icon_Gold_Chest.png 2x" data-file-width="81" data-file-height="81" />
        Number of chests</label>
    </td>
    <td>
      <input id="bounty-input-samples" type="number" value="1" min="1" max="10000" step="1" style="width: 75px;"/>
    </td>
    <td style="text-align: center;"><span id="bounty-output-item-count"></span></td>
  </tr>
</table>
<script type="application/javascript">
  (function () {
    let selects = document.querySelectorAll('select[id^="bounty-input-boost-"]');

    let inputChestPercent = document.querySelector('#bounty-input-chest-percent');
    let inputItemPercent = document.querySelector('#bounty-input-item-percent');
    let inputSamples = document.querySelector('#bounty-input-samples');

    let outputTotalBoost = document.querySelector('#bounty-output-sum-total');
    let outputChestPercent = document.querySelector('#bounty-output-chest-percent');
    let outputItemPercent = document.querySelector('#bounty-output-item-percent');
    let outputItemCount = document.querySelector('#bounty-output-item-count');

    let multipliers = {};

    function change(event) {
      for (let key in multipliers)
        multipliers[key] = 1;

      selects.forEach(function (select, index) {
        let value = parseFloat(select.options[select.selectedIndex].value);
        multipliers[select.dataset.mul] += value;
      });

      let multiplier = 1;
      for (let key in multipliers) {
        multiplier *= multipliers[key];
        let input = document.querySelector(`[id="bounty-output-sum-${key}"]`);

        input.innerHTML = ((multipliers[key]-1) * 100).toFixed(0) + '%';
      }
      let total = (multiplier-1) * 100
      if (total >= 200) {
        outputTotalBoost.innerHTML = '200% [×' + Math.min(multiplier, 3).toFixed(2) + '] (<u>capped</u>, ' + total.toFixed(0) + '% [×' + multiplier.toFixed(2) + '])';
      } else {
        outputTotalBoost.innerHTML = total.toFixed(0) + '% [×' + multiplier.toFixed(2) + ']';
      }
      multiplier = Math.min(multiplier, 3);

      let chestDropRate = parseFloat(inputChestPercent.value) / 100;
      let chestExpectedRate = Math.min(100 * multiplier * chestDropRate, 100);
      outputChestPercent.innerHTML = chestExpectedRate.toFixed(1) + '%';

      let itemDropRate = parseFloat(inputItemPercent.value) / 100;
      let itemExpectedRate = chestExpectedRate * itemDropRate;
      outputItemPercent.innerHTML = itemExpectedRate.toFixed(1) + '%';

      let chestCount = parseFloat(inputSamples.value);
      let itemsExpected = chestCount * (itemExpectedRate / 100);
      outputItemCount.innerHTML = itemsExpected.toFixed(2);
    }

    function init() {
      selects.forEach(function (select, index) {
        multipliers[select.dataset.mul] = 0;
        select.addEventListener('change', change);
      });
      inputChestPercent.addEventListener('change', change);
      inputItemPercent.addEventListener('change', change);
      inputSamples.addEventListener('change', change);
    }

    init();
    change(null);
  })();
</script>