mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-21 06:49:35 +02:00
clean up tsdocs and fix pokemon hasAbility check
This commit is contained in:
parent
d1c4a2e74c
commit
5fb160c5d6
@ -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.
|
||||
* @param phaseFilter
|
||||
* Will search for a specific phase in {@linkcode phaseQueuePrepend} via filter, and remove the first result if a match is found.
|
||||
* @param phaseFilter filter function
|
||||
*/
|
||||
tryRemoveUnshiftedPhase(phaseFilter: (phase: Phase) => boolean): boolean {
|
||||
const phaseIndex = this.phaseQueuePrepend.findIndex(phaseFilter);
|
||||
|
@ -15,6 +15,7 @@ import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { AttackTypeBoosterModifier } from "#app/modifier/modifier";
|
||||
import { AttackTypeBoosterModifierType } from "#app/modifier/modifier-type";
|
||||
import { SpeciesFormKey } from "#enums/species-form-key";
|
||||
import { Ability } from "#app/data/ability";
|
||||
|
||||
export interface EncounterRequirement {
|
||||
meetsRequirement(scene: BattleScene): boolean; // Boolean to see if a requirement is met
|
||||
@ -587,18 +588,19 @@ export class AbilityRequirement extends EncounterPokemonRequirement {
|
||||
if (!this.invertQuery) {
|
||||
return partyPokemon.filter((pokemon) =>
|
||||
(!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 {
|
||||
// for an inverted query, we only want to get the pokemon that don't have ANY of the listed abilities
|
||||
return partyPokemon.filter((pokemon) =>
|
||||
(!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] {
|
||||
if (pokemon?.getAbility().id && this.requiredAbilities.some(a => pokemon.getAbility().id === a)) {
|
||||
return [ "ability", pokemon.getAbility().name ];
|
||||
const matchingAbility = this.requiredAbilities.find(a => pokemon?.hasAbility(a, false));
|
||||
if (!isNullOrUndefined(matchingAbility)) {
|
||||
return [ "ability", new Ability(matchingAbility, 3).name ];
|
||||
}
|
||||
return [ "ability", "" ];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user