From 0f6d01e030d02d7a1b96de7c616932b9e902be6b Mon Sep 17 00:00:00 2001 From: Zach Day Date: Mon, 10 Jun 2024 19:39:49 -0400 Subject: [PATCH] Clean up and document PokemonMove.isUsable --- src/field/pokemon.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 8bbf9c7a378..a1e44a06567 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3853,18 +3853,28 @@ export class PokemonMove { this.virtual = !!virtual; } + /** + * Checks whether the move can be selected or performed by a Pokemon, without consideration for the move's targets. + * The move is unusable if it is out of PP, disabled by an effect, or unimplemented. + * + * @param {Pokemon} pokemon The Pokemon that would be using this move + * @param ignorePp If true, skips the PP check + * @returns True if the move can be selected and used by the Pokemon, otherwise false. + */ isUsable(pokemon: Pokemon, ignorePp?: boolean): boolean { if (!this.moveId) { return false; } - for (const tag of pokemon.findTags(t => t instanceof DisablingBattlerTag)) { - if ((tag as DisablingBattlerTag).moveIsDisabled(this.moveId)) { - return false; - } + if (pokemon.isMoveDisabled(this.moveId)) { + return false; } - return (ignorePp || this.ppUsed < this.getMovePp() || this.getMove().pp === -1) && !this.getMove().name.endsWith(" (N)"); + if (this.getMove().name.endsWith(" (N)")) { + return false; + } + + return (ignorePp || this.ppUsed < this.getMovePp() || this.getMove().pp === -1); } getMove(): Move {