Skip to content

Commit

Permalink
[Core] Update spellAvailable to properly adjust behaviour to inverse
Browse files Browse the repository at this point in the history
Additionally move it to an options object
  • Loading branch information
Pewtro committed Sep 15, 2024
1 parent 1ffbda2 commit d2bd5cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/CHANGELOG.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import SpellLink from 'interface/SpellLink';

// prettier-ignore
export default [
change(date(2024, 9, 16), 'Updated spellAvailable APL function to properly adjust validation behaviour based on inverse options, and turn it into an options object rather than a straight boolean', Putro),
change(date(2024, 9, 15), 'Adding TWW weapon enchants, removing DF-specific items (e.g. Fyralath, Call To Dominance, Voice of the Silent Star, etc)', Seriousnes),
change(date(2024, 9, 12), 'Fixed crash when analyzing reports where 0 procs of certain effects ocurred.', emallson),
change(date(2024, 9, 12), 'Add support for Earthen characters.', ToppleTheNun),
Expand Down
11 changes: 9 additions & 2 deletions src/parser/shared/metrics/apl/conditions/spellAvailable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import { UpdateSpellUsableEvent, EventType } from 'parser/core/Events';

import { Condition, tenseAlt } from '../index';

interface SpellAvailableOptions {
inverse?: boolean;
}

export default function spellAvailable(
spell: Spell,
inverse: boolean = false,
options: SpellAvailableOptions = {},
): Condition<UpdateSpellUsableEvent | null> {
const inverse = !!options.inverse;

Check warning on line 15 in src/parser/shared/metrics/apl/conditions/spellAvailable.tsx

View workflow job for this annotation

GitHub Actions / ESLint

use `Boolean(options.inverse)` instead

return {
key: `spellAvailable-${spell.id}`,
init: () => null,
Expand All @@ -18,7 +24,8 @@ export default function spellAvailable(
return state;
}
},
validate: (state, _event) => state === null || state.isAvailable,
validate: (state, _event) =>
state === null || state.isAvailable || (inverse && !state.isAvailable),
describe: (tense) => (
<>
<SpellLink spell={spell.id} /> {tenseAlt(tense, 'is', 'was')} {inverse ? 'on' : 'off'}{' '}
Expand Down

0 comments on commit d2bd5cc

Please sign in to comment.