diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index 85ab9a55843..9ccb06c70ba 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -23,7 +23,7 @@ import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase"; import { ShowAbilityPhase } from "#app/phases/show-ability-phase"; import { StatStageChangePhase, StatStageChangeCallback } from "#app/phases/stat-stage-change-phase"; import { PokemonAnimType } from "#app/enums/pokemon-anim-type"; -import { BattleScene } from "#app/battle-scene"; +import BattleScene from "#app/battle-scene"; export enum BattlerTagLapseType { FAINT, @@ -2524,6 +2524,9 @@ export class TormentTag extends MoveRestrictionBattlerTag { * @returns `true` if there is valid consecutive usage | `false` if the moves are different from each other */ override isMoveRestricted(move: Moves, user: Pokemon): boolean { + if (!user) { + return false; + } const lastMove = user.getLastXMoves(1)[0]; if ( !lastMove ) { return false; diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 2252b353dcd..e51d3596831 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -3025,8 +3025,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { * * @see {@linkcode MoveRestrictionBattlerTag} */ - isMoveRestricted(moveId: Moves): boolean { - return this.getRestrictingTag(moveId) !== null; + isMoveRestricted(moveId: Moves, pokemon: Pokemon): boolean { + return this.getRestrictingTag(moveId, pokemon) !== null; } /** @@ -5096,7 +5096,7 @@ export class PokemonMove { * @returns `true` if the move can be selected and used by the Pokemon, otherwise `false`. */ isUsable(pokemon: Pokemon, ignorePp?: boolean, ignoreRestrictionTags?: boolean): boolean { - if (this.moveId && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId)) { + if (this.moveId && !ignoreRestrictionTags && pokemon.isMoveRestricted(this.moveId, pokemon)) { return false; } diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index a374f885d3f..256fa5784d2 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -114,8 +114,8 @@ export class CommandPhase extends FieldPhase { // Decides between a Disabled, Not Implemented, or No PP translation message const errorMessage = - playerPokemon.isMoveRestricted(move.moveId) - ? playerPokemon.getRestrictingTag(move.moveId)!.selectionDeniedText(playerPokemon, move.moveId) + playerPokemon.isMoveRestricted(move.moveId, playerPokemon) + ? playerPokemon.getRestrictingTag(move.moveId, playerPokemon)!.selectionDeniedText(playerPokemon, move.moveId) : move.getName().endsWith(" (N)") ? "battle:moveNotImplemented" : "battle:moveNoPP"; const moveName = move.getName().replace(" (N)", ""); // Trims off the indicator