diff --git a/index.html b/index.html index bbd668d..67e94a7 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,6 @@ +
+
-
+
+
+ Categories enabled:
+ +
+ +
+ +
+ +

+
+


diff --git a/random.js b/random.js index 695edb5..04419f9 100644 --- a/random.js +++ b/random.js @@ -66,6 +66,12 @@ function getSupportLvlLimit() { } } +function genFromWpnCategories(set) { + var str = ""; + document.querySelectorAll('#categories>[type="checkbox"]:checked').forEach(e=>{str+="|"+e.value}) + return set.filter((e)=>e.category.match(str.slice(1))); +} + function getRandomElement(array) { return array[Math.floor(Math.random() * array.length)]; } @@ -74,6 +80,7 @@ function getRandomWeapons(weaponset, howmany, perk) { var weightmax = (perk == "support" ? getSupportLvlLimit() : 16); var isfirebug = (perk == "firebug" ? true : false); var chosenweapons = []; + var newset = genFromWpnCategories(weaponset); var totalweight = 0; var totalprice = 0; var containsFireAxe = false; @@ -83,7 +90,8 @@ function getRandomWeapons(weaponset, howmany, perk) { i = i + 1; chosenweapons = []; totalweight = 0; - for (let i = 0; i < howmany; i++) { chosenweapons.push(getRandomElement(weaponset)) }; + console.log(newset); + for (let i = 0; i < howmany; i++) { chosenweapons.push(getRandomElement(newset)) }; chosenweapons.forEach(e => { totalweight += e.weight }); if (i < 75000) { if (isfirebug) containsFireAxe = chosenweapons.some(e=>e === vanillaWeapons[1]);