"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> <script type="text/javascript" src="./random.js"></script>
<select id="perk" style="width: 200px;"> <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="medic">Medic</option>
<option value="support">Support</option> <option value="support">Support</option>
<option value="sharpshooter">Sharpshooter</option> <option value="sharpshooter">Sharpshooter</option>
@ -10,6 +10,13 @@
</select> </select>
<button id="rollperk">Roll a perk</button> <button id="rollperk">Roll a perk</button>
<div style="margin-bottom:4px;"></div> <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;"> <select id="set" style="width: 170px;">
<option value="vanilla">Vanilla Weapons</option> <option value="vanilla">Vanilla Weapons</option>
<option value="kfs">KFS Weapons</option> <option value="kfs">KFS Weapons</option>

View File

@ -54,7 +54,16 @@ function areDistinct(arr) {
} }
function getSupportLvlLimit() { 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) { function getRandomElement(array) {
@ -63,18 +72,23 @@ function getRandomElement(array) {
function getRandomWeapons(weaponset, howmany, perk) { function getRandomWeapons(weaponset, howmany, perk) {
var weightmax = (perk == "support" ? getSupportLvlLimit() : 16); var weightmax = (perk == "support" ? getSupportLvlLimit() : 16);
var isfirebug = (perk == "firebug" ? true : false);
var chosenweapons = []; var chosenweapons = [];
var totalweight = 0; var totalweight = 0;
var totalprice = 0; var totalprice = 0;
var i = 0; var i = 0;
console.log(`isfirebug: ${isfirebug}`)
do { do {
var containsFireAxe = false;
i = i + 1; i = i + 1;
chosenweapons = []; chosenweapons = [];
totalweight = 0; totalweight = 0;
for (let i = 0; i < howmany; i++) { chosenweapons.push(getRandomElement(weaponset)) }; for (let i = 0; i < howmany; i++) { chosenweapons.push(getRandomElement(weaponset)) };
chosenweapons.forEach(e => { totalweight += e.weight }); chosenweapons.forEach(e => { totalweight += e.weight });
if (i < 75000) { 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 { } else {
totalling = false; totalling = false;
return {}; return {};
@ -89,6 +103,10 @@ window.onload = function() {///////////////////////////////////////////
var selperk = document.getElementById("perk"); var selperk = document.getElementById("perk");
var selset = document.getElementById("set"); var selset = document.getElementById("set");
var selnum = document.getElementById("numofweapons"); 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("rollperk").addEventListener("click", () => {
document.getElementById("perk").value = getRandomElement(perks); document.getElementById("perk").value = getRandomElement(perks);
@ -97,17 +115,25 @@ document.getElementById("rollperk").addEventListener("click", () => {
function changePerkAndOrSetFunction() { function changePerkAndOrSetFunction() {
if (selperk.value == "support") { 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; else selnum.max = 5;
selsuplvl.style.display = "";
} else { } else {
if (selset.value == "kfs") selnum.max = 5; if (selset.value == "kfs") selnum.max = 5;
else selnum.max = 3; else selnum.max = 3;
selsuplvl.style.display = "none";
} }
if (selnum.value > selnum.max) selnum.value = selnum.max; if (selnum.value > selnum.max) selnum.value = selnum.max;
} }
selperk.addEventListener("change", changePerkAndOrSetFunction); selperk.addEventListener("change", changePerkAndOrSetFunction);
selset.addEventListener("change", changePerkAndOrSetFunction); selset.addEventListener("change", changePerkAndOrSetFunction);
selsuplvl.addEventListener("change", () => {
localStorage.setItem("supportlvl", selsuplvl.value);
changePerkAndOrSetFunction()
});
document.getElementById("random").addEventListener("click", () => { document.getElementById("random").addEventListener("click", () => {
document.querySelectorAll(".row").forEach(e=>{e.remove()}); document.querySelectorAll(".row").forEach(e=>{e.remove()});