Merge pull request #13 from phantamanta44/adv-item-search-tweaks

Adv item search fixes
This commit is contained in:
hppeng-wynn 2021-03-22 12:39:42 -05:00 committed by GitHub
commit 8ad3847941
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View file

@ -36,7 +36,7 @@
<p>The advanced item search interface uses two separate expressions: one for filtering items and the other for sorting them. The idea is that you can filter for items matching a set of criteria that are absolutely necessary for the item you want, then sort the remaining items to find the optimal build component. The expressions themselves are mathematical formulae that compute values from the properties of items, such as their damage values and identifications.</p>
<p>As an example, suppose you want a helmet granting at least 10 intelligence that maximizes spell damage gain for a build using the Nepta Floodbringer. We would start by writing a filter for helmets with our desired bound on intelligence:</p>
<pre class="hl-expr">{prop:type} {op:=} {str:"helmet"} {op:&} {prop:int} {op:&gt;=} {num:10}</pre>
<p>Then, wee would write an expression that computes the amount of damage we get from the helmet. To do this, we first check the damage numbers for the Nepta Floodbringer: assuming we aren't using any powders, we have 96&ndash;112 water damage scaled by the super-fast attack speed modifier of 4.3, giving us a total of <span class="math">4.3 &times; (96 + 112) &div; 2 = 447.2</span>. We then multiply in the spell damage and water damage modifiers and add raw spell damage, giving us:</p>
<p>Then, we would write an expression that computes the amount of damage we get from the helmet. To do this, we first check the damage numbers for the Nepta Floodbringer: assuming we aren't using any powders, we have 96&ndash;112 water damage scaled by the super-fast attack speed modifier of 4.3, giving us a total of <span class="math">4.3 &times; (96 + 112) &div; 2 = 447.2</span>. We then multiply in the spell damage and water damage modifiers and add raw spell damage, giving us:</p>
<pre class="hl-expr">{prop:sdRaw} {op:+} {num:447.2} {op:*} {op:(}{prop:sdPct} {op:+} {prop:wDamPct}{op:)} {op:/} {num:100}</pre>
<p>And, voilà! In the blink of an eye, we've discovered that Caesura is the best helmet for our criteria, granting 448.14 spell damage.</p>
</div>

View file

@ -344,16 +344,25 @@ class EqualityTerm extends BinaryOpTerm {
constructor(left, right) {
super('boolean', 'any', left, 'any', right);
}
apply(a, b) {
return (typeof a === 'string' && typeof b === 'string')
? this.compare(a.toLowerCase(), b.toLowerCase()) : this.compare(a, b);
}
compare(a, b) {
throw new Error('Abstract method!');
}
}
class EqTerm extends EqualityTerm {
apply(a, b) {
compare(a, b) {
return a === b;
}
}
class NeqTerm extends EqualityTerm {
apply(a, b) {
compare(a, b) {
return a !== b;
}
}
@ -376,7 +385,8 @@ class InequalityTerm extends BinaryOpTerm {
apply(a, b) {
checkComparable(a);
checkComparable(b);
return this.compare(a, b);
return (typeof a === 'string' && typeof b === 'string')
? this.compare(a.toLowerCase(), b.toLowerCase()) : this.compare(a, b);
}
compare(a, b) {
@ -434,7 +444,7 @@ class MulTerm extends ArithmeticTerm {
class DivTerm extends ArithmeticTerm {
apply(a, b) {
return a / b;
return a / b;
}
}