PokéRogue
    Preparing search index...

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _pokemon: Pokemon
    _targets: BattlerIndex[]
    battlerIndex: number

    The battler index this phase refers to, or the pokemon ID if greater than 3. TODO: Make this either use IDs or BattlerIndexes, not a weird mix of both

    cancelled: boolean = false

    Whether the current move should fail and retain PP.

    failed: boolean = false

    Whether the current move should fail but still use PP.

    fieldIndex: number

    Remove in favor of battlerIndex pleas for fuck's sake

    moveHistoryEntry: TurnMove

    The move history entry object that is pushed to the pokemon's move history

    Can be edited after being pushed to the history to adjust the result, targets, etc, for this move phase.

    phaseName: "MovePhase"

    The string name of the phase, used to identify the phase type for is

    player: boolean
    thaw?: boolean

    Flag set to true during checkFreeze that indicates that the pokemon will thaw if it passes the failure conditions

    timingModifier: MovePhaseTimingModifier

    The timing modifier of the move (used by Quash and to force called moves to the front of their queue)

    useMode: MoveUseMode

    Accessors

    Methods

    • Handle the freeze status effect check

      Returns boolean

      Whether the move was cancelled due to the pokemon being frozen

      Responsible for the following

      • Checking if the pokemon is frozen
      • Checking if the pokemon will thaw from random chance, OR from a thawing move. Thawing from a freeze move is not applied until AFTER all other failure checks.
      • Activating the freeze status effect (cancelling the move, playing the message, and displaying the animation)
    • Handle move failures due to Gravity, cancelling the move and showing the failure text

      Returns boolean

      Whether the move was cancelled due to Gravity

    • Handle the paralysis status effect check, cancelling the move and queueing the activation message and animation

      Returns boolean

      Whether the move was cancelled due to paralysis

    • Check if the move is usable based on PP

      Returns boolean

      Whether the move was cancelled due to insufficient PP

    • Cancel the move if its pre use condition fails

      Returns boolean

      Whether the move was cancelled due to a pre-use interruption

      The only official move with a pre-use condition is Focus Punch

    • Handle the sleep check

      Returns boolean

      Whether the move was cancelled due to sleep

    • Check if the move is valid and not in an error state

      Returns boolean

      Whether the move was cancelled due to being invalid

      Checks occur in the following order

      1. Move is not implemented
      2. Move is somehow invalid (it is MoveId.NONE or targets is somehow empty)
      3. Move cannot be used by the player due to a challenge
    • Handle the status interactions for sleep and freeze that happen after passing the first failure check

      Returns void

      • If the user is asleep but can use the move, the sleep animation and message is still shown
      • If the user is frozen but is thawed from its move, the user's status is cured and the thaw message is shown
    • Fail the move currently being used. Handles failure messages, pushing to move history, etc.

      Parameters

      • failedDueToTerrain: boolean = false

        Whether the move failed due to terrain (default false)

      Returns void

    • Check the first round of failure checks

      Returns boolean

      Whether the move failed

      Based on battle mechanics research conducted primarily by Smogon, checks happen in the following order (as of Gen 9):

      1. Sleep/Freeze
      2. Disobedience due to overleveled (not implemented in Pokerogue)
      3. Insufficient PP after being selected
      4. (Pokerogue specific) Moves disabled because they are not implemented / prevented from a challenge / somehow have no targets
      5. Sky battle (see PR#5983)
      6. Truant
      7. Focus Punch's loss of focus
      8. Flinch
      9. Move was disabled after being selected
      10. Healing move with heal block
      11. Sound move with throat chop
      12. Failure due to gravity
      13. Move lock from choice items / gorilla tactics
      14. Failure from taunt
      15. Failure from imprison
      16. Failure from confusion
      17. Failure from paralysis
      18. Failure from infatuation
    • Follow up moves need to check a subset of the first failure checks

      Returns boolean

      Based on smogon battle mechanics research, checks happen in the following order:

      1. Invalid move (skipped in pokerogue)
      2. Move prevented by heal block
      3. Move prevented by throat chop
      4. Gravity
      5. Sky Battle (See PR#5983)
    • Applies PP increasing abilities (currently only Pressure) if they exist on the target pokemon. Note that targets must include only active pokemon.

      TODO: This hardcodes the PP increase at 1 per opponent, rather than deferring to the ability.

      Parameters

      Returns number

    • Handles the case where the move was cancelled or failed:

      • Uses PP if the move failed (not cancelled) and should use PP (failed moves are not affected by Pressure)
      • Records a cancelled OR failed move in move history, so abilities like Truant don't trigger on the next turn and soft-lock.
      • Lapses MOVE_EFFECT tags:
        • Semi-invulnerable battler tags (Fly/Dive/etc.) are intended to lapse on move effects, but also need to lapse on move failure/cancellation.

          TODO: ...this seems weird.

      • Lapses AFTER_MOVE tags:
      • Removes the second turn of charge moves

      Returns void

    • Check if the phase is of the given type without requiring instanceof.

      Type Parameters

      • K extends
            | "AddEnemyBuffModifierPhase"
            | "AttemptCapturePhase"
            | "AttemptRunPhase"
            | "BattleEndPhase"
            | "BerryPhase"
            | "CheckInterludePhase"
            | "CheckStatusEffectPhase"
            | "CheckSwitchPhase"
            | "CommandPhase"
            | "CommonAnimPhase"
            | "DamageAnimPhase"
            | "DynamicPhaseMarker"
            | "EggHatchPhase"
            | "EggLapsePhase"
            | "EggSummaryPhase"
            | "EncounterPhase"
            | "EndCardPhase"
            | "EndEvolutionPhase"
            | "EnemyCommandPhase"
            | "EvolutionPhase"
            | "ExpPhase"
            | "FaintPhase"
            | "FormChangePhase"
            | "GameOverPhase"
            | "GameOverModifierRewardPhase"
            | "HideAbilityPhase"
            | "HidePartyExpBarPhase"
            | "InitEncounterPhase"
            | "LearnMovePhase"
            | "LevelCapPhase"
            | "LevelUpPhase"
            | "LoadMoveAnimPhase"
            | "LoginPhase"
            | "MessagePhase"
            | "ModifierRewardPhase"
            | "MoneyRewardPhase"
            | "MoveAnimPhase"
            | "MoveChargePhase"
            | "MoveEffectPhase"
            | "MoveEndPhase"
            | "MoveHeaderPhase"
            | "MovePhase"
            | "MysteryEncounterPhase"
            | "MysteryEncounterOptionSelectedPhase"
            | "MysteryEncounterBattlePhase"
            | "MysteryEncounterBattleStartCleanupPhase"
            | "MysteryEncounterRewardsPhase"
            | "PostMysteryEncounterPhase"
            | "NewBattlePhase"
            | "NewBiomeEncounterPhase"
            | "NextEncounterPhase"
            | "ObtainStatusEffectPhase"
            | "PartyExpPhase"
            | "PartyHealPhase"
            | "PokemonAnimPhase"
            | "PokemonHealPhase"
            | "PokemonTransformPhase"
            | "PositionalTagPhase"
            | "PostGameOverPhase"
            | "PostSummonPhase"
            | "PostTurnStatusEffectPhase"
            | "QuietFormChangePhase"
            | "ReloadSessionPhase"
            | "ResetStatusPhase"
            | "ReturnPhase"
            | "RevivalBlessingPhase"
            | "RibbonModifierRewardPhase"
            | "ScanIvsPhase"
            | "SelectBiomePhase"
            | "SelectChallengePhase"
            | "SelectGenderPhase"
            | "SelectModifierPhase"
            | "SelectStarterPhase"
            | "SelectTargetPhase"
            | "ShinySparklePhase"
            | "ShowAbilityPhase"
            | "ShowPartyExpBarPhase"
            | "ShowTrainerPhase"
            | "StatStageChangePhase"
            | "SummonMissingPhase"
            | "SummonPhase"
            | "SwitchBiomePhase"
            | "SwitchPhase"
            | "SwitchSummonPhase"
            | "TeraPhase"
            | "TitlePhase"
            | "ToggleDoublePositionPhase"
            | "TrainerVictoryPhase"
            | "TurnEndPhase"
            | "TurnInitPhase"
            | "TurnStartPhase"
            | "UnavailablePhase"
            | "UnlockPhase"
            | "VictoryPhase"
            | "WeatherEffectPhase"

      Parameters

      • phase: K

        The string name of the phase to check.

      Returns this is PhaseMap[K]

      Whether this phase is of the provided type.

      This does not check for subclasses! It only checks if the phase is exactly the given type. This method exists to avoid circular import issues, as using instanceof would require importing each phase.

    • Update the targets of any counter-attacking moves with [BattlerIndex.ATTACKER] set to reflect the actual battler index of the user's last attacker.

      If there is no last attacker or they are no longer on the field, a message is displayed and the move is marked for failure

      Returns void

    • Check for cancellation edge cases - no targets remaining

      Returns boolean

      Whether the move fails

    • Modifies this.targets in place, based upon:

      • Move redirection abilities, effects, etc.
      • Counterattacks, which pass a special value into the targets constructor param ([BattlerIndex.ATTACKER]).

      Returns void

    • Second failure check that occurs after the "Pokemon used move" text is shown but BEFORE the move has been registered as being the last move used (for the purposes of something like Copycat)

      Returns boolean

      Other than powder, each failure condition is mutually exclusive (as they are tied to specific moves), so order does not matter. Notably, this failure check only includes failure conditions intrinsic to the move itself, other than Powder (which marks the end of this failure check)

      • Pollen puff used on an ally that is under effect of heal block
      • Burn up / Double shock when the user does not have the required type
      • No Retreat while already under its effects
      • Failure due to primal weather
      • (on cart, not applicable to Pokerogue) Moves that fail if used ON a raid / special boss: selfdestruct/explosion/imprision/power split / guard split
      • (on cart, not applicable to Pokerogue) Moves that fail during a "co-op" battle (like when Arven helps during raid boss): ally switch / teatime

      After all checks, Powder causing the user to explode

    • Display the text for a move failing to execute.

      Parameters

      • failedText: string = ...

        The failure text to display; defaults to "battle:attackFailed" locale key ("But it failed!" in english)

      Returns void

    • Displays the move's usage text to the player as applicable for the move being used.

      Returns void

    • Third failure check is from moves and abilities themselves

      Returns boolean

      Whether the move failed

      • Anything in Move.conditionsSeq3
      • Weather blocking the move
      • Terrain blocking the move
      • Queenly Majesty / Dazzling
      • Damp (which is handled by move conditions in pokerogue rather than the ability, like queenly majesty / dazzling)

      The rest of the failure conditions are marked as sequence 4 and should happen in the move effect phase (though happen here for now)

    • Queue the status activation message, play its animation, and cancel the move

      Parameters

      • effect: StatusEffect

        The effect being triggered

      • cancel: boolean = true

        Whether to cancel the move after triggering the status effect animation message; default true. Set to false for sleep-bypassing moves to avoid cancelling attack.

      Returns void

    • Clear out two turn moves, then schedule the move to be used if it passes the third failure check.

      Parameters

      • charging: boolean = false

      Returns void

    • Deduct PP from the move being used, accounting for Pressure and other effects

      Returns void