diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 1b38be6296c..d1041b790ef 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -98,9 +98,12 @@ export interface TerrainBattlerTag { } /** - * Base class for tags that disable moves. Descendants can override {@linkcode moveIsDisabled} to disable moves that - * match a condition. A disabled move gets cancelled before it is used. Players and enemies should not be allowed - * to select disabled moves. + * Base class for tags that restrict the usage of moves. This effect is generally referred to as "disabling" a move + * in-game. This is not to be confused with {@linkcode Moves.DISABLE}. + * + * Descendants can override {@linkcode isMoveRestricted} to restrict moves that + * match a condition. A restricted move gets cancelled before it is used. Players and enemies should not be allowed + * to select restricted moves. */ export abstract class MoveRestrictionBattlerTag extends BattlerTag { constructor(tagType: BattlerTagType, turnCount: integer, sourceMove?: Moves, sourceId?: integer) { @@ -113,7 +116,7 @@ export abstract class MoveRestrictionBattlerTag extends BattlerTag { const phase = pokemon.scene.getCurrentPhase() as MovePhase; const move = phase.move; - if (this.moveIsDisabled(move.moveId)) { + if (this.isMoveRestricted(move.moveId)) { pokemon.scene.queueMessage(this.interruptedText(pokemon, move.moveId)); phase.cancel(); } @@ -124,29 +127,29 @@ export abstract class MoveRestrictionBattlerTag extends BattlerTag { return super.lapse(pokemon, lapseType); } - /** Determines whether to disable a move. */ - abstract moveIsDisabled(move: Moves): boolean; + /** Determines whether to restrict a move. */ + abstract isMoveRestricted(move: Moves): boolean; - /** The text to display when the player attempts to select a move disabled by this tag. */ + /** The text to display when the player attempts to select a move that is restricted by this tag. */ abstract selectionDeniedText(pokemon: Pokemon, move: Moves): string; /** - * The text to display when a move's execution is prevented as a result of the disable. - * Because disabling effects also prevent selection of the move, this situation can only arise if a - * pokemon first selects a move, then gets outsped by a pokemon using a move that disables the selected move. + * The text to display when a move's execution is prevented as a result of the restriction. + * Because restriction effects also prevent selection of the move, this situation can only arise if a + * pokemon first selects a move, then gets outsped by a pokemon using a move that restricts the selected move. */ abstract interruptedText(pokemon: Pokemon, move: Moves): string; } /** * Tag representing the "disabling" effect performed by {@linkcode Moves.DISABLE} and {@linkcode Abilities.CURSED_BODY}. - * When the tag is added, the last used move of the tag holder is set as the disabled move. + * When the tag is added, the last-used move of the tag holder is set as the disabled move. */ export class DisabledTag extends MoveRestrictionBattlerTag { /** The move being disabled. Gets set when {@linkcode onAdd} is called for this tag. */ public moveId: Moves = Moves.NONE; - public override moveIsDisabled(move: Moves): boolean { + public override isMoveRestricted(move: Moves): boolean { return move === this.moveId; } diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 5a32d31d04e..ed141439843 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -2553,16 +2553,16 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * @param moveId {@linkcode Moves} The ID of the move to check * @see {@linkcode MoveRestrictionBattlerTag} */ - isMoveDisabled(moveId: Moves): boolean { - return this.getDisablingTag(moveId) !== null; + isMoveRestricted(moveId: Moves): boolean { + return this.getRestrictingTag(moveId) !== null; } /** - * Gets the {@link MoveRestrictionBattlerTag} that is disabling the given move, or null if that move is not disabled. + * Gets the {@link MoveRestrictionBattlerTag} that is restricting the given move, or null if that move is not restricted. */ - getDisablingTag(moveId: Moves): MoveRestrictionBattlerTag | null { + getRestrictingTag(moveId: Moves): MoveRestrictionBattlerTag | null { for (const tag of this.findTags(t => t instanceof MoveRestrictionBattlerTag)) { - if ((tag as MoveRestrictionBattlerTag).moveIsDisabled(moveId)) { + if ((tag as MoveRestrictionBattlerTag).isMoveRestricted(moveId)) { return tag as MoveRestrictionBattlerTag; } } @@ -4434,7 +4434,7 @@ export type DamageResult = HitResult.EFFECTIVE | HitResult.SUPER_EFFECTIVE | Hit * It links to {@linkcode Move} class via the move ID. * Compared to {@linkcode Move}, this class also tracks if a move has received. * PP Ups, amount of PP used, and things like that. - * @see {@linkcode isUsable} - checks if move is disabled, out of PP, or not implemented. + * @see {@linkcode isUsable} - checks if move is restricted, out of PP, or not implemented. * @see {@linkcode getMove} - returns {@linkcode Move} object by looking it up via ID. * @see {@linkcode usePp} - removes a point of PP from the move. * @see {@linkcode getMovePp} - returns amount of PP a move currently has. @@ -4456,14 +4456,14 @@ export class PokemonMove { /** * 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 + * The move is unusable if it is out of PP, restricted by an effect, or unimplemented. + * @param pokemon {@linkcode Pokemon} The Pokemon that would be using this move * @param ignorePp If true, skips the PP check - * @param ignoreDisableTags If true, skips the check for move-disabling tags + * @param ignoreRestrictionTags If true, skips the check for move restriction tags * @returns True if the move can be selected and used by the Pokemon, otherwise false. */ - isUsable(pokemon: Pokemon, ignorePp?: boolean, ignoreDisableTags?: boolean): boolean { - if (this.moveId && !ignoreDisableTags && pokemon.isMoveDisabled(this.moveId)) { + isUsable(pokemon: Pokemon, ignorePp?: boolean, ignoreRestrictionTags?: boolean): boolean { + if (this.moveId && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId)) { return false; } diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index 9d7808af7f4..47d212aa598 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -107,8 +107,8 @@ export class CommandPhase extends FieldPhase { // Decides between a Disabled, Not Implemented, or No PP translation message const errorMessage = - playerPokemon.isMoveDisabled(move.moveId) - ? playerPokemon.getDisablingTag(move.moveId)!.selectionDeniedText(playerPokemon, move.moveId) + playerPokemon.isMoveRestricted(move.moveId) + ? playerPokemon.getRestrictingTag(move.moveId)!.selectionDeniedText(playerPokemon, move.moveId) : move.getName().endsWith(" (N)") ? "battle:moveNotImplemented" : "battle:moveNoPP"; const moveName = move.getName().replace(" (N)", ""); // Trims off the indicator diff --git a/src/test/moves/disable.test.ts b/src/test/moves/disable.test.ts index 8abb4601844..9db6e4f92d8 100644 --- a/src/test/moves/disable.test.ts +++ b/src/test/moves/disable.test.ts @@ -64,7 +64,7 @@ describe("Moves - Disable", () => { expect(playerMon.getMoveHistory()).toHaveLength(1); expect(enemyMon.getMoveHistory()).toHaveLength(1); expect(playerMon.getMoveHistory()[0]).toMatchObject({ move: Moves.DISABLE, result: MoveResult.SUCCESS }); - expect(enemyMon.isMoveDisabled(Moves.SPLASH)).toBe(true); + expect(enemyMon.isMoveRestricted(Moves.SPLASH)).toBe(true); }); it("fails if enemy has no move history", async() => { @@ -118,7 +118,7 @@ describe("Moves - Disable", () => { expect(playerMon.getLastXMoves()[0].result).toBe(MoveResult.FAIL); expect(enemyMon.getLastXMoves()[0].move).toBe(Moves.STRUGGLE); - expect(enemyMon.isMoveDisabled(Moves.STRUGGLE)).toBe(false); + expect(enemyMon.isMoveRestricted(Moves.STRUGGLE)).toBe(false); }, 20000); it("interrupts target's move when target moves after", async() => { @@ -157,7 +157,7 @@ describe("Moves - Disable", () => { _useMove(Moves.DISABLE); await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(CommandPhase); - expect(enemyMon.isMoveDisabled(Moves.NATURE_POWER)).toBe(true); - expect(enemyMon.isMoveDisabled(enemyMon.getLastXMoves(2)[1].move)).toBe(false); + expect(enemyMon.isMoveRestricted(Moves.NATURE_POWER)).toBe(true); + expect(enemyMon.isMoveRestricted(enemyMon.getLastXMoves(2)[1].move)).toBe(false); }, 20000); });