clean up tsdocs and fix pokemon hasAbility check

This commit is contained in:
ImperialSympathizer 2024-10-17 14:56:57 -04:00
parent d1c4a2e74c
commit 5fb160c5d6
2 changed files with 8 additions and 6 deletions

View File

@ -2363,8 +2363,8 @@ export default class BattleScene extends SceneBase {
} }
/** /**
* Will search for a specific phase via filter, and remove the first result if a match is found. * Will search for a specific phase in {@linkcode phaseQueuePrepend} via filter, and remove the first result if a match is found.
* @param phaseFilter * @param phaseFilter filter function
*/ */
tryRemoveUnshiftedPhase(phaseFilter: (phase: Phase) => boolean): boolean { tryRemoveUnshiftedPhase(phaseFilter: (phase: Phase) => boolean): boolean {
const phaseIndex = this.phaseQueuePrepend.findIndex(phaseFilter); const phaseIndex = this.phaseQueuePrepend.findIndex(phaseFilter);

View File

@ -15,6 +15,7 @@ import { MysteryEncounterType } from "#enums/mystery-encounter-type";
import { AttackTypeBoosterModifier } from "#app/modifier/modifier"; import { AttackTypeBoosterModifier } from "#app/modifier/modifier";
import { AttackTypeBoosterModifierType } from "#app/modifier/modifier-type"; import { AttackTypeBoosterModifierType } from "#app/modifier/modifier-type";
import { SpeciesFormKey } from "#enums/species-form-key"; import { SpeciesFormKey } from "#enums/species-form-key";
import { Ability } from "#app/data/ability";
export interface EncounterRequirement { export interface EncounterRequirement {
meetsRequirement(scene: BattleScene): boolean; // Boolean to see if a requirement is met meetsRequirement(scene: BattleScene): boolean; // Boolean to see if a requirement is met
@ -587,18 +588,19 @@ export class AbilityRequirement extends EncounterPokemonRequirement {
if (!this.invertQuery) { if (!this.invertQuery) {
return partyPokemon.filter((pokemon) => return partyPokemon.filter((pokemon) =>
(!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) (!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle())
&& this.requiredAbilities.some((ability) => pokemon.getAbility().id === ability || pokemon.getPassiveAbility().id === ability)); && this.requiredAbilities.some((ability) => pokemon.hasAbility(ability, false)));
} else { } else {
// for an inverted query, we only want to get the pokemon that don't have ANY of the listed abilities // for an inverted query, we only want to get the pokemon that don't have ANY of the listed abilities
return partyPokemon.filter((pokemon) => return partyPokemon.filter((pokemon) =>
(!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle()) (!this.excludeDisallowedPokemon || pokemon.isAllowedInBattle())
&& this.requiredAbilities.filter((ability) => pokemon.getAbility().id === ability || pokemon.getPassiveAbility().id === ability).length === 0); && this.requiredAbilities.filter((ability) => pokemon.hasAbility(ability, false)).length === 0);
} }
} }
override getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] { override getDialogueToken(scene: BattleScene, pokemon?: PlayerPokemon): [string, string] {
if (pokemon?.getAbility().id && this.requiredAbilities.some(a => pokemon.getAbility().id === a)) { const matchingAbility = this.requiredAbilities.find(a => pokemon?.hasAbility(a, false));
return [ "ability", pokemon.getAbility().name ]; if (!isNullOrUndefined(matchingAbility)) {
return [ "ability", new Ability(matchingAbility, 3).name ];
} }
return [ "ability", "" ]; return [ "ability", "" ];
} }