Last active
November 12, 2021 02:49
-
-
Save logikv/d3e1cccae050c067b58c2ae2be068819 to your computer and use it in GitHub Desktop.
https://case-battle.one/ case average price
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let priceArray = [] | |
var casePrice = 0 | |
let items = document.getElementsByClassName("unit"); | |
for (var i=0; i<items.length; i++){ | |
let item = items[i]; | |
let price = item.getElementsByClassName("price")[0].children[0].innerText.slice(2).replace(" ",""); | |
priceArray.push(parseInt(price)); | |
} | |
console.warn("All items prices: ", priceArray.sort(function(a, b) {return a - b;})) | |
const average = (array) => array.reduce((a, b) => a + b) / array.length; | |
console.error("Average item price is: ", average(priceArray)); | |
if (document.getElementById("btns-before-open-holder")){ | |
let casePriceTxt = document.getElementById("btns-before-open-holder").children[0].innerText; | |
casePrice = parseInt(casePriceTxt.slice(11,-4)); | |
} else { | |
casePrice = parseInt(document.getElementById("info-block-holder").getElementsByTagName("span")[0].innerText) | |
} | |
console.info("Case open price is: ", casePrice); | |
var lowPricePrizes = priceArray.filter(function isBigEnough(value) { | |
return value < casePrice; | |
}); | |
var doublePricePrizes = priceArray.filter(function isBigEnough(value) { | |
return (value >= casePrice*2); | |
}); | |
console.info("All prizes count: ", priceArray.length ); | |
console.info("Prizes with lower price then case: ", lowPricePrizes.length ); | |
console.info("Prizes with more then double case price: ", doublePricePrizes.length ); | |
console.warn("Chance to lose money: " + (lowPricePrizes.length/priceArray.length)*100 + "%") | |
console.warn("Chance to double money: " + (doublePricePrizes.length/priceArray.length)*100 + "%") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment