made locked equipment selectable
This commit is contained in:
parent
ea32a1df60
commit
1f4894f946
@ -179,7 +179,7 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<li>
|
<li>
|
||||||
<b>Locked Equipment</b>
|
<b>Locked Equipment</b>
|
||||||
<button id="clear-equipment" onclick="update()">Clear Locked Equipment</button>
|
<button id="clear-equipment" onclick="clearEquipment()">Clear Locked Equipment</button>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<table>
|
<table>
|
||||||
@ -193,28 +193,31 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
|
<template id="locked-option">
|
||||||
|
<option value="">Placeholder</option>
|
||||||
|
</template>
|
||||||
<td>
|
<td>
|
||||||
<select type="text" id="select-head" name="locked-equipment"
|
<select type="text" id="select-helmet" name="locked-equipment"
|
||||||
onchange="update()">
|
onchange="update()">
|
||||||
<option>None</option>
|
<option value="none">None</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select type="text" id="select-chest" name="locked-equipment"
|
<select type="text" id="select-chestpiece" name="locked-equipment"
|
||||||
onchange="update()">
|
onchange="update()">
|
||||||
<option>None</option>
|
<option value="none">None</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select type=" text" id="select-hands" name="locked-equipment"
|
<select type=" text" id="select-gauntlets" name="locked-equipment"
|
||||||
onchange="update()">
|
onchange="update()">
|
||||||
<option>None</option>
|
<option value="none">None</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select type="text" id="select-legs" name="locked-equipment"
|
<select type="text" id="select-leggings" name="locked-equipment"
|
||||||
onchange="update()">
|
onchange="update()">
|
||||||
<option>None</option>
|
<option value="none">None</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"gauntlets": [
|
"gauntlets": [
|
||||||
[
|
|
||||||
{
|
{
|
||||||
"id": "all-knowing-gauntlets",
|
"id": "all-knowing-gauntlets",
|
||||||
"name": "All-Knowing Gauntlets",
|
"name": "All-Knowing Gauntlets",
|
||||||
@ -730,5 +729,4 @@
|
|||||||
"weight": 2.3
|
"weight": 2.3
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
const HELMETS = fetch("/data/armor.json")
|
const HELMETS = fetch("/data/helmets.json")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => data.helmets)
|
.then(data => data.helmets)
|
||||||
.catch(error => console.log(error));
|
.catch(error => console.log(error));
|
||||||
const CHESTPIECES = fetch("/data/armor.json")
|
const CHESTPIECES = fetch("/data/chestpieces.json")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => data.chestpieces)
|
.then(data => data.chestpieces)
|
||||||
.catch(error => console.log(error));
|
.catch(error => console.log(error));
|
||||||
const GAUNTLETS = fetch("/data/armor.json")
|
const GAUNTLETS = fetch("/data/gauntlets.json")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => data.gauntlets)
|
.then(data => data.gauntlets)
|
||||||
.catch(error => console.log(error));
|
.catch(error => console.log(error));
|
||||||
const LEGGINGS = fetch("/data/armor.json")
|
const LEGGINGS = fetch("/data/leggings.json")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => data.leggings)
|
.then(data => data.leggings)
|
||||||
.catch(error => console.log(error));
|
.catch(error => console.log(error));
|
||||||
@ -20,19 +20,27 @@ let sortedChestplates;
|
|||||||
let sortedGauntlets;
|
let sortedGauntlets;
|
||||||
let sortedLeggings;
|
let sortedLeggings;
|
||||||
|
|
||||||
const SortingMethod = {
|
// const SortingMethod = {
|
||||||
AVERAGE,
|
// AVERAGE,
|
||||||
PHYSICAL,
|
// POISE,
|
||||||
ELEMENTAL,
|
// PHYSICAL,
|
||||||
IMMUNITIES,
|
// ELEMENTAL,
|
||||||
};
|
// IMMUNITIES,
|
||||||
|
// };
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
|
// populate filter selects
|
||||||
|
populateSelect("locked-option", "select-helmet", await HELMETS);
|
||||||
|
populateSelect("locked-option", "select-chestpiece", await CHESTPIECES);
|
||||||
|
populateSelect("locked-option", "select-gauntlets", await GAUNTLETS);
|
||||||
|
populateSelect("locked-option", "select-leggings", await LEGGINGS);
|
||||||
|
|
||||||
// precompute and sort list of armor pieces
|
// precompute and sort list of armor pieces
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function update() {
|
async function update() {
|
||||||
let sorted = sortedCombinations();
|
// let sorted = sortedCombinations();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSortingMethod() {
|
function updateSortingMethod() {
|
||||||
@ -41,16 +49,34 @@ function updateSortingMethod() {
|
|||||||
|
|
||||||
function fitness(item, order) {
|
function fitness(item, order) {
|
||||||
// return fitness of item based on given order
|
// return fitness of item based on given order
|
||||||
switch (order) {
|
// switch (order) {
|
||||||
case SortingMethod.AVERAGE:
|
// case SortingMethod.AVERAGE:
|
||||||
return item.defenses.reduce((total, value) => total + value, 0) / item.defenses.length;
|
// return item.defenses.reduce((total, value) => total + value, 0) / item.defenses.length;
|
||||||
case SortingMethod.PHYSICAL:
|
// case SortingMethod.PHYSICAL:
|
||||||
break;
|
// break;
|
||||||
case SortingMethod.ELEMENTAL:
|
// case SortingMethod.ELEMENTAL:
|
||||||
break;
|
// break;
|
||||||
case SortingMethod.IMMUNITIES:
|
// case SortingMethod.IMMUNITIES:
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
console.log("error pls fix");
|
// console.log("error pls fix");
|
||||||
}
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
function populateSelect(templateId, destinationId, items) {
|
||||||
|
let template = document.getElementById(templateId);
|
||||||
|
let destination = document.getElementById(destinationId);
|
||||||
|
|
||||||
|
items.forEach(item => {
|
||||||
|
let clone = template.content.cloneNode(true);
|
||||||
|
|
||||||
|
clone.value = item.id;
|
||||||
|
clone.innerHTML = item.name;
|
||||||
|
|
||||||
|
destination.options.add(new Option(item.name, item.id));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearEquipment() {
|
||||||
|
[...document.getElementsByName("locked-equipment")].forEach(select => select.selectedIndex = 0);
|
||||||
}
|
}
|
@ -299,5 +299,8 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.app select {
|
.app select {
|
||||||
|
background-color: var(--secondary);
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
color: var(--font-color);
|
||||||
|
border: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user