diff --git a/src/enums/move-use-type.ts b/src/enums/move-use-type.ts index 6c688a7eab9..30c97ea85f9 100644 --- a/src/enums/move-use-type.ts +++ b/src/enums/move-use-type.ts @@ -9,7 +9,7 @@ import type { PostDancingMoveAbAttr } from "#app/data/abilities/ability"; * Callers should refrain from performing non-equality checks on `MoveUseTypes` directly, * instead using the available helper functions - * ({@linkcode isVirtual}, {@linkcode isIgnorePP} and {@linkcode isReflected}). + * ({@linkcode isVirtual}, {@linkcode isIgnoreStatus}, {@linkcode isIgnorePP} and {@linkcode isReflected}). */ export enum MoveUseType { /** @@ -78,7 +78,7 @@ export enum MoveUseType { * @returns Whether {@linkcode useType} is virtual. * @remarks * This function is equivalent to the following truth table: - + * * | Use Type | Returns | * |------------------------------------|---------| * | {@linkcode MoveUseType.NORMAL} | `false` | @@ -91,6 +91,25 @@ export function isVirtual(useType: MoveUseType): boolean { return useType >= MoveUseType.INDIRECT } +/** + * Check if a given {@linkcode MoveUseType} should ignore pre-move cancellation checks. + * @param useType - The {@linkcode MoveUseType} to check. + * @returns Whether {@linkcode useType} should ignore status checks. + * @remarks + * This function is equivalent to the following truth table: + * + * | Use Type | Returns | + * |------------------------------------|---------| + * | {@linkcode MoveUseType.NORMAL} | `false` | + * | {@linkcode MoveUseType.IGNORE_PP} | `false` | + * | {@linkcode MoveUseType.INDIRECT} | `false` | + * | {@linkcode MoveUseType.FOLLOW_UP} | `true` | + * | {@linkcode MoveUseType.REFLECTED} | `true` | + */ +export function isIgnoreStatus(useType: MoveUseType): boolean { + return useType >= MoveUseType.FOLLOW_UP; +} + /** * Check if a given {@linkcode MoveUseType} should ignore PP. * PP-ignoring moves will ignore normal PP consumption as well as associated failure checks. @@ -98,7 +117,7 @@ export function isVirtual(useType: MoveUseType): boolean { * @returns Whether {@linkcode useType} ignores PP. * @remarks * This function is equivalent to the following truth table: - + * * | Use Type | Returns | * |------------------------------------|---------| * | {@linkcode MoveUseType.NORMAL} | `false` | diff --git a/src/phases/command-phase.ts b/src/phases/command-phase.ts index a60fa037020..77d0c52d2c6 100644 --- a/src/phases/command-phase.ts +++ b/src/phases/command-phase.ts @@ -162,7 +162,7 @@ export class CommandPhase extends FieldPhase { const turnMove: TurnMove | undefined = args.length === 2 ? (args[1] as TurnMove) : undefined; if ( cursor === -1 || - playerPokemon.trySelectMove(cursor, (args[0] as MoveUseType) >= MoveUseType.IGNORE_PP) || + playerPokemon.trySelectMove(cursor, isIgnorePP(args[0] as MoveUseType)) || (useStruggle = cursor > -1 && !playerPokemon.getMoveset().filter(m => m.isUsable(playerPokemon)).length) ) { let moveId: Moves; diff --git a/src/phases/move-phase.ts b/src/phases/move-phase.ts index 9614667ba6b..dcac4486ba3 100644 --- a/src/phases/move-phase.ts +++ b/src/phases/move-phase.ts @@ -50,7 +50,7 @@ import { BattlerTagType } from "#enums/battler-tag-type"; import { Moves } from "#enums/moves"; import { StatusEffect } from "#enums/status-effect"; import i18next from "i18next"; -import { isVirtual, isIgnorePP, isReflected, MoveUseType } from "#enums/move-use-type"; +import { isVirtual, isIgnorePP, isReflected, MoveUseType, isIgnoreStatus } from "#enums/move-use-type"; export class MovePhase extends BattlePhase { protected _pokemon: Pokemon; @@ -234,7 +234,7 @@ export class MovePhase extends BattlePhase { */ protected resolvePreMoveStatusEffects(): void { // Skip for follow ups/reflected moves, no status condition or post turn statuses (e.g. Poison/Toxic) - if (!this.pokemon.status || this.pokemon.status?.isPostTurn() || this.useType >= MoveUseType.FOLLOW_UP) { + if (!this.pokemon.status || this.pokemon.status?.isPostTurn() || isIgnoreStatus(this.useType)) { return; } @@ -321,7 +321,7 @@ export class MovePhase extends BattlePhase { // TODO: does this intentionally happen before the no targets/Moves.NONE on queue cancellation case is checked? // (In other words, check if truant can proc on a move w/o targets) - if (!isVirtual(this.useType) && this.canMove() && !this.cancelled) { + if (!isIgnoreStatus(this.useType) && this.canMove() && !this.cancelled) { this.pokemon.lapseTags(BattlerTagLapseType.MOVE); } }