updated weapon handedness parameters

This commit is contained in:
Frederik Palmø 2022-04-07 17:27:00 +02:00
parent 8cc402f5fd
commit 4d3f1bfb6d
2 changed files with 32 additions and 7 deletions

View File

@ -15,11 +15,13 @@ async function init() {
function update() { function update() {
// get parameters // get parameters
let requireStats = document.getElementById("requirements").checked; let requireStats = document.getElementById("requirements").checked;
let twoHanding = document.getElementById("2handing").checked; let oneHandable = document.getElementById("2h-sometimes").checked;
let twoHanding = document.getElementById("2h-always").checked || oneHandable;
let allowedInfusions = [...document.getElementsByName("infusion")] let allowedInfusions = [...document.getElementsByName("infusion")]
.filter(elem => elem.checked) .filter(elem => elem.checked)
.map(elem => elem.value); .map(elem => elem.value);
let categories = [...document.getElementsByName("category")].filter(el => el.checked).map(el => el.id); let categories = [...document.getElementsByName("category")].filter(el => el.checked).map(el => el.id);
let onlyBuffable = document.getElementById("buffable").checked;
// get upgrade level // get upgrade level
let upgraded = document.getElementById("max-upgrade").checked; let upgraded = document.getElementById("max-upgrade").checked;
@ -48,8 +50,10 @@ function update() {
// filter out weapons that don't fit the current parameters // filter out weapons that don't fit the current parameters
return ( return (
(weapon.requirements.every((stat, i) => stat <= stats[i]) || !requireStats) && (weapon.requirements.every((stat, i) => stat <= stats[i]) || !requireStats) &&
(weapon.requirements[0] <= Math.ceil(stats[0] / 1.5) || !oneHandable) &&
categories.includes(weapon.category) && categories.includes(weapon.category) &&
allowedInfusions.some(id => weapon.infusions[id] != undefined) allowedInfusions.some(id => weapon.infusions[id] != undefined) &&
(!onlyBuffable || Object.values(weapon.infusions).some(inf => inf.buffable))
); );
}) })
.map(weapon => { .map(weapon => {
@ -57,7 +61,11 @@ function update() {
let attackRatings = Object.values(INFUSIONS) let attackRatings = Object.values(INFUSIONS)
.filter(inf => allowedInfusions.includes(inf.id)) .filter(inf => allowedInfusions.includes(inf.id))
.map(inf => { .map(inf => {
return weapon.infusions[inf.id] != null ? damage(weapon, INFUSIONS[inf.id], upgraded, stats) : 0; return weapon.infusions[inf.id] != null
? !onlyBuffable || weapon.infusions[inf.id].buffable
? damage(weapon, INFUSIONS[inf.id], upgraded, stats)
: 0
: 0;
}); });
let max = Math.max(0, ...attackRatings); let max = Math.max(0, ...attackRatings);

View File

@ -85,16 +85,33 @@
</div> </div>
<div> <div>
<span> <span>
<input id="2handing" type="checkbox" <input type="checkbox" id="buffable"
onchange="update()" /> onchange="update()" />
<label for="2handing">2-handing (1.5x strength)</label> <label for="buffable">Buffable Only</label>
</span>
</div>
<hr>
<b>Handedness</b>
<div>
<span>
<input type="radio" id="2h-never" name="handedness"
onchange="update()" checked>
<label for="2h-never">One-handing</label>
</span> </span>
</div> </div>
<div> <div>
<span> <span>
<input type="checkbox" id="buffable" <input type="radio" id="2h-sometimes" name="handedness"
onchange="update()" /> onchange="update()" />
<label for="buffable">Only Buffable</label> <label for="2h-sometimes">Usable
One-Handed</label>
</span>
</div>
<div>
<span>
<input id="2h-always" type="radio" name="handedness"
onchange="update()" name="two-handing" />
<label for="2h-always">Two-handing</label>
</span> </span>
</div> </div>
<hr /> <hr />