Anonymous
×
Create a new article
Write your page title here:
We currently have 496 articles on WIKI - Idle Pixel. Type your article name above or click on one of the titles below and start writing!



WIKI - Idle Pixel
Revision as of 06:35, 4 November 2024 by Dounford (talk | contribs)
(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.
//Variable with Weapon DPS used on Weapons Page
var weaponDPS = {
    WithoutWeapon: [0,0.125,0.375,0.750,1.250,1.875,2.625,3.125],
    WoodenSword: [0.125,0.250,0.500,0.875,1.375,2.000,2.750,3.250],
    Stinger: [0.250,0.375,0.625,1.000,1.500,2.125,2.875,3.375],
    PoisonStinger: [0.333,0.458,0.708,1.083,1.583,2.208,2.958,3.458],
    IronDagger: [0.333,0.500,0.833,1.333,2.000,2.833,3.833,4.500],
    SkeletonSword: [0.625,0.750,1.000,1.375,1.875,2.500,3.250,3.750],
    Club: [0.667,0.750,0.917,1.167,1.500,1.917,2.417,2.750],
    SpikedClub: [1.000,1.083,1.250,1.500,1.833,2.250,2.750,3.083],
    Scythe: [1.000,1.125,1.375,1.750,2.250,2.875,3.625,4.125],
    ScythePlus: [1.000,1.125,1.375,1.750,2.250,2.875,3.625,4.125],
    StingerDagger: [0.375,0.563,0.938,1.500,2.250,3.188,4.313,5.063],
    PoisonStingerDagger: [0.708,0.896,1.271,1.833,2.583,3.521,4.646,5.396],
	BattleAxe: [0.875,1.000,1.250,1.625,2.125,2.750,3.500,4.000],
	LongSpear: [0.583,0.667,0.833,1.083,1.417,1.833,2.333,2.667],
	Trident: [0.875,1.000,1.250,1.625,2.125,2.750,3.500,4.000],
	LongTrident: [0.875,1.000,1.250,1.625,2.125,2.750,3.500,4.000],
    Rapier: [1.500,1.625,1.875,2.250,2.750,3.375,4.125,4.625],
    PoisonRapier: [1.917,2.042,2.292,2.667,3.167,3.792,4.542,5.042],
    DenseClub: [1.667,1.750,1.917,2.167,2.500,2.917,3.417,3.750],
    SpikedDenseClub: [2.500,2.583,2.750,3.000,3.333,3.750,4.250,4.583],
    GoldenRapier: [2.000,2.167,2.500,3.000,3.667,4.500,5.500,6.167],
    PoisonGoldenRapier: [2.778,2.944,3.278,3.778,4.444,5.278,6.278,6.944],
    Ballista: [1.167,1.333,1.667,2.167,2.833,3.667,4.667,5.333],
    HauntedBow: [0.875,1.000,1.250,1.625,2.125,2.750,3.500,4.000]
}

// Function to change values on Weapons page table
function compareDPS(value,id) {
	document.getElementById('compareDPST0Row'+id).innerText = Math.round(weaponDPS[value][0] * 100) / 100;
	document.getElementById('compareDPST1Row'+id).innerText = Math.round(weaponDPS[value][1] * 100) / 100;
	document.getElementById('compareDPST2Row'+id).innerText = Math.round(weaponDPS[value][2] * 100) / 100;
	document.getElementById('compareDPST3Row'+id).innerText = Math.round(weaponDPS[value][3] * 100) / 100;
	document.getElementById('compareDPST4Row'+id).innerText = Math.round(weaponDPS[value][4] * 100) / 100;
	document.getElementById('compareDPST5Row'+id).innerText = Math.round(weaponDPS[value][5] * 100) / 100;
	document.getElementById('compareDPST6Row'+id).innerText = Math.round(weaponDPS[value][6] * 100) / 100;
	document.getElementById('compareDPST7Row'+id).innerText = Math.round(weaponDPS[value][7] * 100) / 100;
}

// Event listeners for weapon change
if (document.querySelector('[id^="compareDPS"]')) {
	document.getElementById('compareSelect1').addEventListener("change", function() {
		compareDPS(document.getElementById('compareSelect1').value,1)
	});
	document.getElementById('compareSelect2').addEventListener("change", function() {
		compareDPS(document.getElementById('compareSelect2').value,2)
	});
	console.log('DPS select listeners added')
}

// Update Log Iframe
if (document.getElementById('updateLogs')) {
	document.getElementById('updateLogs').innerHTML = '<iframe src="/custom/updateLogs.php" width="100%" height="600px"></iframe>'
}

// Highlight code using Module Lua {{#invoke:Lua|code|CODE HERE}}

	mw.loader.getScript(
		'../custom/highlight.min.js'
	).then( function () {
		hljs.highlightAll();
		console.log('Code highlighted');
	});


// Function to show Hit Change 
function hitRateCalc(attacker) {
	var defense = document.getElementById("defense" + attacker).value;
	var accuracy = document.getElementById("accuracy" + attacker).value;
	var darkness = document.getElementById("darkness" + attacker).checked;

	var hitChance = 0;

	if (((defense / 2) - accuracy) > 4) {
		hitChance = 1 / (Math.max(1, ((defense / 2) - accuracy)) + 1);
	} else if (((defense / 2) - accuracy) <= 0) {
		hitChance = 1;
	} else {
		hitChance = 1 - (((defense / 2) - accuracy) * 2 / 10);
	}

	var hitChancePercentage = (hitChance * 100).toFixed(2);
	hitChancePercentage = darkness == true ? '50.00' : hitChancePercentage;
	document.getElementById("hitRate" + attacker).innerText = hitChancePercentage;
};

// Event listeners for accuracy or defense change on Hit Chance calculator
if (document.querySelector('[class="hitChance"]')) {
	Array.prototype.forEach.call(document.getElementsByClassName('hitChance'), function(el) {
		var attacker = el.getAttribute('data-hit') || ''
		document.getElementById('accuracy'+attacker).addEventListener("input", function() {
			hitRateCalc(attacker)
		});
		document.getElementById('defense'+attacker).addEventListener("input", function() {
			hitRateCalc(attacker)
		});
		document.getElementById('darkness'+attacker).addEventListener("change", function() {
			hitRateCalc(attacker)
		});
		hitRateCalc(attacker);
	})
	console.log('hitChange listeners added')
}
console.log('Page loaded')