"should be pretty much complete by now" - sent in DMs at 16:25 GMT+3

This commit is contained in:
mv 2024-08-11 18:16:54 +03:00
parent 9a23b922d4
commit 759cf9e929
2 changed files with 37 additions and 4 deletions

View File

@ -1,6 +1,6 @@
<script type="text/javascript" src="./random.js"></script>
<select id="perk" style="width: 200px;">
<option class="selection" value="">Perk select</option>
<option class="selection" value="">No perk</option>
<option value="medic">Medic</option>
<option value="support">Support</option>
<option value="sharpshooter">Sharpshooter</option>
@ -10,6 +10,13 @@
</select>
<button id="rollperk">Roll a perk</button>
<div style="margin-bottom:4px;"></div>
<select id="supportlvl" style="width: 283px; display: none;">
<option class="selection" value="">Support Specialist level</option>
<option value="1">Lvl 1 (21Kg carry)</option>
<option value="2">Lvl 2 (23Kg carry)</option>
<option value="3">Lvl 3 (25Kg carry)</option>
</select>
<div style="margin-bottom:4px;"></div>
<select id="set" style="width: 170px;">
<option value="vanilla">Vanilla Weapons</option>
<option value="kfs">KFS Weapons</option>

View File

@ -54,7 +54,16 @@ function areDistinct(arr) {
}
function getSupportLvlLimit() {
return 25; // i wanted to implement support for support lv1 and lv2 but idk what the max weight for those levels are
switch (localStorage.getItem("supportlvl")) {
case '1':
return 21;
break;
case '2':
return 23;
break;
default:
return 25;
}
}
function getRandomElement(array) {
@ -63,18 +72,23 @@ function getRandomElement(array) {
function getRandomWeapons(weaponset, howmany, perk) {
var weightmax = (perk == "support" ? getSupportLvlLimit() : 16);
var isfirebug = (perk == "firebug" ? true : false);
var chosenweapons = [];
var totalweight = 0;
var totalprice = 0;
var i = 0;
console.log(`isfirebug: ${isfirebug}`)
do {
var containsFireAxe = false;
i = i + 1;
chosenweapons = [];
totalweight = 0;
for (let i = 0; i < howmany; i++) { chosenweapons.push(getRandomElement(weaponset)) };
chosenweapons.forEach(e => { totalweight += e.weight });
if (i < 75000) {
totalling = !(areDistinct(chosenweapons) && totalweight < weightmax);
if (isfirebug) containsFireAxe = chosenweapons.some(e=>e === vanillaWeapons[1]);
console.log(`containsFireAxe: ${containsFireAxe}`)
totalling = !(areDistinct(chosenweapons) && totalweight < weightmax && !containsFireAxe);
} else {
totalling = false;
return {};
@ -89,6 +103,10 @@ window.onload = function() {///////////////////////////////////////////
var selperk = document.getElementById("perk");
var selset = document.getElementById("set");
var selnum = document.getElementById("numofweapons");
var selsuplvl = document.getElementById("supportlvl");
var supportlvl = localStorage.getItem("supportlvl");
if (supportlvl != null) selsuplvl.value = supportlvl;
document.getElementById("rollperk").addEventListener("click", () => {
document.getElementById("perk").value = getRandomElement(perks);
@ -97,17 +115,25 @@ document.getElementById("rollperk").addEventListener("click", () => {
function changePerkAndOrSetFunction() {
if (selperk.value == "support") {
if (selset.value == "kfs") selnum.max = 7;
if (selset.value == "kfs" && getSupportLvlLimit() == 25) selnum.max = 7;
else if (selset.value == "kfs" && getSupportLvlLimit() < 25) selnum.max = 6;
else if (getSupportLvlLimit() < 23) selnum.max = 4;
else selnum.max = 5;
selsuplvl.style.display = "";
} else {
if (selset.value == "kfs") selnum.max = 5;
else selnum.max = 3;
selsuplvl.style.display = "none";
}
if (selnum.value > selnum.max) selnum.value = selnum.max;
}
selperk.addEventListener("change", changePerkAndOrSetFunction);
selset.addEventListener("change", changePerkAndOrSetFunction);
selsuplvl.addEventListener("change", () => {
localStorage.setItem("supportlvl", selsuplvl.value);
changePerkAndOrSetFunction()
});
document.getElementById("random").addEventListener("click", () => {
document.querySelectorAll(".row").forEach(e=>{e.remove()});