User:XTCarnage/common.js: Difference between revisions
From Idle Clans wiki
mNo edit summary |
mNo edit summary |
||
Line 19: | Line 19: | ||
var time = $(this).data("time") / 100; | var time = $(this).data("time") / 100; | ||
var percentageChance = 1.2 * 0.000005 * ((levelRequirement / 10) * 1.033); | var percentageChance = 1.2 * 0.000005 * ((levelRequirement / 10) * 1.033); | ||
var chancePerDay = 1 - (1 - percentageChance) | var actionsPerDay = 24 * 3600 / time; | ||
$(this).text(chancePerDay); | var chancePerDay = 1 - Math.pow(((1 - percentageChance)), actionsPerDay); | ||
$(this).text(chancePerDay.toFixed(4) * 100 + "%"); | |||
}); | }); | ||
Revision as of 18:11, 19 February 2025
mw.loader.using(['jquery'], function() { $(document).ready(function() { // Create the slider var slider = $('<input type="range" min="0" max="100" value="0" id="time-slider">'); var sliderLabel = $('<p>Adjust Production Time: <span id="slider-value">0</span>%</p>'); // Append slider to the page $(".mw-slider-md").append(sliderLabel).append(slider); $(".chance-per-action").each(function() { var levelRequirement = $(this).data("level"); var percentageChance = 1.2 * 0.000005 * ((levelRequirement / 10) * 1.033) var textChance = "1 in " + Math.ceil(1 / percentageChance).toLocaleString(); $(this).text(textChance); }); $(".chance-per-day").each(function() { var levelRequirement = $(this).data("level"); var time = $(this).data("time") / 100; var percentageChance = 1.2 * 0.000005 * ((levelRequirement / 10) * 1.033); var actionsPerDay = 24 * 3600 / time; var chancePerDay = 1 - Math.pow(((1 - percentageChance)), actionsPerDay); $(this).text(chancePerDay.toFixed(4) * 100 + "%"); }); // Update the table values when the slider is moved slider.on("input", function() { var sliderValue = $(this).val(); $("#slider-value").text(sliderValue); // Adjust production times based on slider value $(".production-time").each(function() { var originalTime = $(this).data("original-time"); var adjustedTime = originalTime * (1 - sliderValue / 100) * 0.95; $(this).text(adjustedTime.toFixed(2)); // Show the adjusted time with 2 decimals }); }); }); });