Create isXPhase method and add properties to each phase

This commit is contained in:
Sirz Benjie 2025-05-22 18:46:41 -05:00
parent b872ac6595
commit aef619a699
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E
89 changed files with 342 additions and 112 deletions

View File

@ -1,11 +1,19 @@
import type { MoveAnim } from "#app/data/battle-anims";
import type { AddEnemyBuffModifierPhase } from "#app/phases/add-enemy-buff-modifier-phase";
import type { AttemptCapturePhase } from "#app/phases/attempt-capture-phase";
import type { AttemptRunPhase } from "#app/phases/attempt-run-phase"; import type { AttemptRunPhase } from "#app/phases/attempt-run-phase";
import type { BattleEndPhase } from "#app/phases/battle-end-phase"; import type { BattleEndPhase } from "#app/phases/battle-end-phase";
import type { BerryPhase } from "#app/phases/berry-phase"; import type { BerryPhase } from "#app/phases/berry-phase";
import type { CheckStatusEffectPhase } from "#app/phases/check-status-effect-phase";
import type { CheckSwitchPhase } from "#app/phases/check-switch-phase"; import type { CheckSwitchPhase } from "#app/phases/check-switch-phase";
import type { CommandPhase } from "#app/phases/command-phase"; import type { CommandPhase } from "#app/phases/command-phase";
import type { CommonAnimPhase } from "#app/phases/common-anim-phase";
import type { DamageAnimPhase } from "#app/phases/damage-anim-phase"; import type { DamageAnimPhase } from "#app/phases/damage-anim-phase";
import type { EggHatchPhase } from "#app/phases/egg-hatch-phase";
import type { EggLapsePhase } from "#app/phases/egg-lapse-phase"; import type { EggLapsePhase } from "#app/phases/egg-lapse-phase";
import type { EggSummaryPhase } from "#app/phases/egg-summary-phase";
import type { EncounterPhase } from "#app/phases/encounter-phase"; import type { EncounterPhase } from "#app/phases/encounter-phase";
import type { EndCardPhase } from "#app/phases/end-card-phase";
import type { EndEvolutionPhase } from "#app/phases/end-evolution-phase"; import type { EndEvolutionPhase } from "#app/phases/end-evolution-phase";
import type { EnemyCommandPhase } from "#app/phases/enemy-command-phase"; import type { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import type { EvolutionPhase } from "#app/phases/evolution-phase"; import type { EvolutionPhase } from "#app/phases/evolution-phase";
@ -14,13 +22,21 @@ import type { FaintPhase } from "#app/phases/faint-phase";
import type { FormChangePhase } from "#app/phases/form-change-phase"; import type { FormChangePhase } from "#app/phases/form-change-phase";
import type { GameOverModifierRewardPhase } from "#app/phases/game-over-modifier-reward-phase"; import type { GameOverModifierRewardPhase } from "#app/phases/game-over-modifier-reward-phase";
import type { GameOverPhase } from "#app/phases/game-over-phase"; import type { GameOverPhase } from "#app/phases/game-over-phase";
import type { HideAbilityPhase } from "#app/phases/hide-ability-phase";
import type { HidePartyExpBarPhase } from "#app/phases/hide-party-exp-bar-phase";
import type { LearnMovePhase } from "#app/phases/learn-move-phase"; import type { LearnMovePhase } from "#app/phases/learn-move-phase";
import type { LevelCapPhase } from "#app/phases/level-cap-phase"; import type { LevelCapPhase } from "#app/phases/level-cap-phase";
import type { LevelUpPhase } from "#app/phases/level-up-phase";
import type { LoadMoveAnimPhase } from "#app/phases/load-move-anim-phase";
import type { LoginPhase } from "#app/phases/login-phase"; import type { LoginPhase } from "#app/phases/login-phase";
import type { MessagePhase } from "#app/phases/message-phase"; import type { MessagePhase } from "#app/phases/message-phase";
import type { ModifierRewardPhase } from "#app/phases/modifier-reward-phase"; import type { ModifierRewardPhase } from "#app/phases/modifier-reward-phase";
import type { MoneyRewardPhase } from "#app/phases/money-reward-phase";
import type { MoveAnimPhase } from "#app/phases/move-anim-phase";
import type { MoveChargePhase } from "#app/phases/move-charge-phase";
import type { MoveEffectPhase } from "#app/phases/move-effect-phase"; import type { MoveEffectPhase } from "#app/phases/move-effect-phase";
import type { MoveEndPhase } from "#app/phases/move-end-phase"; import type { MoveEndPhase } from "#app/phases/move-end-phase";
import type { MoveHeaderPhase } from "#app/phases/move-header-phase";
import type { MovePhase } from "#app/phases/move-phase"; import type { MovePhase } from "#app/phases/move-phase";
import type { import type {
MysteryEncounterPhase, MysteryEncounterPhase,
@ -28,153 +44,243 @@ import type {
MysteryEncounterBattlePhase, MysteryEncounterBattlePhase,
MysteryEncounterRewardsPhase, MysteryEncounterRewardsPhase,
PostMysteryEncounterPhase, PostMysteryEncounterPhase,
MysteryEncounterBattleStartCleanupPhase,
} from "#app/phases/mystery-encounter-phases"; } from "#app/phases/mystery-encounter-phases";
import type { NewBattlePhase } from "#app/phases/new-battle-phase"; import type { NewBattlePhase } from "#app/phases/new-battle-phase";
import type { NewBiomeEncounterPhase } from "#app/phases/new-biome-encounter-phase"; import type { NewBiomeEncounterPhase } from "#app/phases/new-biome-encounter-phase";
import type { NextEncounterPhase } from "#app/phases/next-encounter-phase"; import type { NextEncounterPhase } from "#app/phases/next-encounter-phase";
import type { ObtainStatusEffectPhase } from "#app/phases/obtain-status-effect-phase";
import type { PartyExpPhase } from "#app/phases/party-exp-phase"; import type { PartyExpPhase } from "#app/phases/party-exp-phase";
import type { PartyHealPhase } from "#app/phases/party-heal-phase"; import type { PartyHealPhase } from "#app/phases/party-heal-phase";
import type { PokemonAnimPhase } from "#app/phases/pokemon-anim-phase";
import type { PokemonHealPhase } from "#app/phases/pokemon-heal-phase";
import type { PokemonTransformPhase } from "#app/phases/pokemon-transform-phase";
import type { PostGameOverPhase } from "#app/phases/post-game-over-phase"; import type { PostGameOverPhase } from "#app/phases/post-game-over-phase";
import type { PostSummonPhase } from "#app/phases/post-summon-phase"; import type { PostSummonPhase } from "#app/phases/post-summon-phase";
import type { PostTurnStatusEffectPhase } from "#app/phases/post-turn-status-effect-phase";
import type { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase"; import type { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
import type { ReloadSessionPhase } from "#app/phases/reload-session-phase";
import type { ResetStatusPhase } from "#app/phases/reset-status-phase";
import type { ReturnPhase } from "#app/phases/return-phase";
import type { RevivalBlessingPhase } from "#app/phases/revival-blessing-phase"; import type { RevivalBlessingPhase } from "#app/phases/revival-blessing-phase";
import type { RibbonModifierRewardPhase } from "#app/phases/ribbon-modifier-reward-phase"; import type { RibbonModifierRewardPhase } from "#app/phases/ribbon-modifier-reward-phase";
import type { ScanIvsPhase } from "#app/phases/scan-ivs-phase";
import type { SelectBiomePhase } from "#app/phases/select-biome-phase"; import type { SelectBiomePhase } from "#app/phases/select-biome-phase";
import type { SelectChallengePhase } from "#app/phases/select-challenge-phase";
import type { SelectGenderPhase } from "#app/phases/select-gender-phase"; import type { SelectGenderPhase } from "#app/phases/select-gender-phase";
import type { SelectModifierPhase } from "#app/phases/select-modifier-phase"; import type { SelectModifierPhase } from "#app/phases/select-modifier-phase";
import type { SelectStarterPhase } from "#app/phases/select-starter-phase"; import type { SelectStarterPhase } from "#app/phases/select-starter-phase";
import type { SelectTargetPhase } from "#app/phases/select-target-phase"; import type { SelectTargetPhase } from "#app/phases/select-target-phase";
import type { ShinySparklePhase } from "#app/phases/shiny-sparkle-phase"; import type { ShinySparklePhase } from "#app/phases/shiny-sparkle-phase";
import type { ShowAbilityPhase } from "#app/phases/show-ability-phase"; import type { ShowAbilityPhase } from "#app/phases/show-ability-phase";
import type { ShowPartyExpBarPhase } from "#app/phases/show-party-exp-bar-phase";
import type { ShowTrainerPhase } from "#app/phases/show-trainer-phase";
import type { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; import type { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
import type { SummonMissingPhase } from "#app/phases/summon-missing-phase";
import type { SummonPhase } from "#app/phases/summon-phase"; import type { SummonPhase } from "#app/phases/summon-phase";
import type { SwitchBiomePhase } from "#app/phases/switch-biome-phase";
import type { SwitchPhase } from "#app/phases/switch-phase"; import type { SwitchPhase } from "#app/phases/switch-phase";
import type { SwitchSummonPhase } from "#app/phases/switch-summon-phase"; import type { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
import type { TeraPhase } from "#app/phases/tera-phase";
import type { TitlePhase } from "#app/phases/title-phase"; import type { TitlePhase } from "#app/phases/title-phase";
import type { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase"; import type { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
import type { TrainerVictoryPhase } from "#app/phases/trainer-victory-phase";
import type { TurnEndPhase } from "#app/phases/turn-end-phase"; import type { TurnEndPhase } from "#app/phases/turn-end-phase";
import type { TurnInitPhase } from "#app/phases/turn-init-phase"; import type { TurnInitPhase } from "#app/phases/turn-init-phase";
import type { TurnStartPhase } from "#app/phases/turn-start-phase"; import type { TurnStartPhase } from "#app/phases/turn-start-phase";
import type { UnavailablePhase } from "#app/phases/unavailable-phase"; import type { UnavailablePhase } from "#app/phases/unavailable-phase";
import type { UnlockPhase } from "#app/phases/unlock-phase"; import type { UnlockPhase } from "#app/phases/unlock-phase";
import type { VictoryPhase } from "#app/phases/victory-phase"; import type { VictoryPhase } from "#app/phases/victory-phase";
import type { WeatherEffectPhase } from "#app/phases/weather-effect-phase";
export type PhaseKind = "";
export type PhaseClass = export type PhaseClass =
| typeof LoginPhase | typeof AddEnemyBuffModifierPhase
| typeof TitlePhase | typeof AttemptCapturePhase
| typeof SelectGenderPhase
| typeof NewBiomeEncounterPhase
| typeof SelectStarterPhase
| typeof PostSummonPhase
| typeof SummonPhase
| typeof ToggleDoublePositionPhase
| typeof CheckSwitchPhase
| typeof ShowAbilityPhase
| typeof MessagePhase
| typeof TurnInitPhase
| typeof CommandPhase
| typeof EnemyCommandPhase
| typeof TurnStartPhase
| typeof MovePhase
| typeof MoveEffectPhase
| typeof DamageAnimPhase
| typeof FaintPhase
| typeof BerryPhase
| typeof TurnEndPhase
| typeof BattleEndPhase
| typeof EggLapsePhase
| typeof SelectModifierPhase
| typeof NextEncounterPhase
| typeof NewBattlePhase
| typeof VictoryPhase
| typeof LearnMovePhase
| typeof MoveEndPhase
| typeof StatStageChangePhase
| typeof ShinySparklePhase
| typeof SelectTargetPhase
| typeof UnavailablePhase
| typeof QuietFormChangePhase
| typeof SwitchPhase
| typeof SwitchSummonPhase
| typeof PartyHealPhase
| typeof FormChangePhase
| typeof EvolutionPhase
| typeof EndEvolutionPhase
| typeof LevelCapPhase
| typeof AttemptRunPhase | typeof AttemptRunPhase
| typeof SelectBiomePhase | typeof BattleEndPhase
| typeof BerryPhase
| typeof CheckStatusEffectPhase
| typeof CheckSwitchPhase
| typeof CommandPhase
| typeof CommonAnimPhase
| typeof DamageAnimPhase
| typeof EggHatchPhase
| typeof EggLapsePhase
| typeof EggSummaryPhase
| typeof EncounterPhase
| typeof EndCardPhase
| typeof EndEvolutionPhase
| typeof EnemyCommandPhase
| typeof EvolutionPhase
| typeof FormChangePhase
| typeof ExpPhase
| typeof FaintPhase
| typeof FormChangePhase
| typeof GameOverPhase
| typeof GameOverModifierRewardPhase
| typeof HideAbilityPhase
| typeof HidePartyExpBarPhase
| typeof LearnMovePhase
| typeof LevelUpPhase
| typeof LevelCapPhase
| typeof LoadMoveAnimPhase
| typeof LoginPhase
| typeof MessagePhase
| typeof ModifierRewardPhase
| typeof MoneyRewardPhase
| typeof MoveAnimPhase
| typeof MoveChargePhase
| typeof MoveEffectPhase
| typeof MoveEndPhase
| typeof MoveHeaderPhase
| typeof MovePhase
| typeof MysteryEncounterPhase | typeof MysteryEncounterPhase
| typeof MysteryEncounterOptionSelectedPhase | typeof MysteryEncounterOptionSelectedPhase
| typeof MysteryEncounterBattlePhase | typeof MysteryEncounterBattlePhase
| typeof MysteryEncounterRewardsPhase | typeof MysteryEncounterRewardsPhase
| typeof MysteryEncounterBattleStartCleanupPhase
| typeof MysteryEncounterRewardsPhase
| typeof PostMysteryEncounterPhase | typeof PostMysteryEncounterPhase
| typeof RibbonModifierRewardPhase | typeof NewBattlePhase
| typeof GameOverModifierRewardPhase | typeof NewBiomeEncounterPhase
| typeof ModifierRewardPhase | typeof NextEncounterPhase
| typeof ObtainStatusEffectPhase
| typeof PartyExpPhase | typeof PartyExpPhase
| typeof ExpPhase | typeof PartyHealPhase
| typeof EncounterPhase | typeof PokemonAnimPhase
| typeof GameOverPhase | typeof PokemonHealPhase
| typeof UnlockPhase | typeof PokemonTransformPhase
| typeof PostGameOverPhase | typeof PostGameOverPhase
| typeof RevivalBlessingPhase; | typeof PostSummonPhase
export type PhaseString = | typeof PostTurnStatusEffectPhase
| "LoginPhase" | typeof QuietFormChangePhase
| "TitlePhase" | typeof ReloadSessionPhase
| "SelectGenderPhase" | typeof ResetStatusPhase
| "NewBiomeEncounterPhase" | typeof ReturnPhase
| "SelectStarterPhase" | typeof RevivalBlessingPhase
| "PostSummonPhase" | typeof RibbonModifierRewardPhase
| "SummonPhase" | typeof ScanIvsPhase
| "ToggleDoublePositionPhase" | typeof SelectBiomePhase
| "CheckSwitchPhase" | typeof SelectChallengePhase
| "ShowAbilityPhase" | typeof SelectGenderPhase
| "MessagePhase" | typeof SelectModifierPhase
| "TurnInitPhase" | typeof SelectStarterPhase
| "CommandPhase" | typeof SelectTargetPhase
| "EnemyCommandPhase" | typeof ShinySparklePhase
| "TurnStartPhase" | typeof ShowAbilityPhase
| "MovePhase" | typeof ShowTrainerPhase
| "MoveEffectPhase" | typeof ShowPartyExpBarPhase
| "DamageAnimPhase" | typeof StatStageChangePhase
| "FaintPhase" | typeof SummonMissingPhase
| "BerryPhase" | typeof SummonPhase
| "TurnEndPhase" | typeof SwitchBiomePhase
| "BattleEndPhase" | typeof SwitchPhase
| "EggLapsePhase" | typeof SwitchSummonPhase
| "SelectModifierPhase" | typeof TeraPhase
| "NextEncounterPhase" | typeof TitlePhase
| "NewBattlePhase" | typeof ToggleDoublePositionPhase
| "VictoryPhase" | typeof TrainerVictoryPhase
| "LearnMovePhase" | typeof TurnEndPhase
| "MoveEndPhase" | typeof TurnInitPhase
| "StatStageChangePhase" | typeof TurnStartPhase
| "ShinySparklePhase" | typeof UnavailablePhase
| "SelectTargetPhase" | typeof UnlockPhase
| "UnavailablePhase" | typeof VictoryPhase
| "QuietFormChangePhase" | typeof WeatherEffectPhase;
| "SwitchPhase"
| "SwitchSummonPhase" /** Typescript map used to map a string phase to the actual phase type */
| "PartyHealPhase" export type PhaseMap = {
| "FormChangePhase" AddEnemyBuffModifierPhase: AddEnemyBuffModifierPhase;
| "EvolutionPhase" AttemptCapturePhase: AttemptCapturePhase;
| "EndEvolutionPhase" AttemptRunPhase: AttemptRunPhase;
| "LevelCapPhase" BattleEndPhase: BattleEndPhase;
| "AttemptRunPhase" BerryPhase: BerryPhase;
| "SelectBiomePhase" CheckStatusEffectPhase: CheckStatusEffectPhase;
| "MysteryEncounterPhase" CheckSwitchPhase: CheckSwitchPhase;
| "MysteryEncounterOptionSelectedPhase" CommandPhase: CommandPhase;
| "MysteryEncounterBattlePhase" CommonAnimPhase: CommonAnimPhase;
| "MysteryEncounterRewardsPhase" DamageAnimPhase: DamageAnimPhase;
| "PostMysteryEncounterPhase" EggHatchPhase: EggHatchPhase;
| "RibbonModifierRewardPhase" EggLapsePhase: EggLapsePhase;
| "GameOverModifierRewardPhase" EggSummaryPhase: EggSummaryPhase;
| "ModifierRewardPhase" EncounterPhase: EncounterPhase;
| "PartyExpPhase" EndCardPhase: EndCardPhase;
| "ExpPhase" EndEvolutionPhase: EndEvolutionPhase;
| "EncounterPhase" EnemyCommandPhase: EnemyCommandPhase;
| "GameOverPhase" EvolutionPhase: EvolutionPhase;
| "UnlockPhase" ExpPhase: ExpPhase;
| "PostGameOverPhase" FaintPhase: FaintPhase;
| "RevivalBlessingPhase"; FormChangePhase: FormChangePhase;
GameOverPhase: GameOverPhase;
GameOverModifierRewardPhase: GameOverModifierRewardPhase;
HideAbilityPhase: HideAbilityPhase;
HidePartyExpBarPhase: HidePartyExpBarPhase;
LearnMovePhase: LearnMovePhase;
LevelCapPhase: LevelCapPhase;
LevelUpPhase: LevelUpPhase;
LoadMoveAnimPhase: LoadMoveAnimPhase;
LoginPhase: LoginPhase;
MessagePhase: MessagePhase;
ModifierRewardPhase: ModifierRewardPhase;
MoneyRewardPhase: MoneyRewardPhase;
MoveAnimPhase: MoveAnimPhase<MoveAnim>;
MoveChargePhase: MoveChargePhase;
MoveEffectPhase: MoveEffectPhase;
MoveEndPhase: MoveEndPhase;
MoveHeaderPhase: MoveHeaderPhase;
MovePhase: MovePhase;
MysteryEncounterPhase: MysteryEncounterPhase;
MysteryEncounterOptionSelectedPhase: MysteryEncounterOptionSelectedPhase;
MysteryEncounterBattlePhase: MysteryEncounterBattlePhase;
MysteryEncounterBattleStartCleanupPhase: MysteryEncounterBattleStartCleanupPhase;
MysteryEncounterRewardsPhase: MysteryEncounterRewardsPhase;
PostMysteryEncounterPhase: PostMysteryEncounterPhase;
NewBattlePhase: NewBattlePhase;
NewBiomeEncounterPhase: NewBiomeEncounterPhase;
NextEncounterPhase: NextEncounterPhase;
ObtainStatusEffectPhase: ObtainStatusEffectPhase;
PartyExpPhase: PartyExpPhase;
PartyHealPhase: PartyHealPhase;
PokemonAnimPhase: PokemonAnimPhase;
PokemonHealPhase: PokemonHealPhase;
PokemonTransformPhase: PokemonTransformPhase;
PostGameOverPhase: PostGameOverPhase;
PostSummonPhase: PostSummonPhase;
PostTurnStatusEffectPhase: PostTurnStatusEffectPhase;
QuietFormChangePhase: QuietFormChangePhase;
ReloadSessionPhase: ReloadSessionPhase;
ResetStatusPhase: ResetStatusPhase;
ReturnPhase: ReturnPhase;
RevivalBlessingPhase: RevivalBlessingPhase;
RibbonModifierRewardPhase: RibbonModifierRewardPhase;
ScanIvsPhase: ScanIvsPhase;
SelectBiomePhase: SelectBiomePhase;
SelectChallengePhase: SelectChallengePhase;
SelectGenderPhase: SelectGenderPhase;
SelectModifierPhase: SelectModifierPhase;
SelectStarterPhase: SelectStarterPhase;
SelectTargetPhase: SelectTargetPhase;
ShinySparklePhase: ShinySparklePhase;
ShowAbilityPhase: ShowAbilityPhase;
ShowPartyExpBarPhase: ShowPartyExpBarPhase;
ShowTrainerPhase: ShowTrainerPhase;
StatStageChangePhase: StatStageChangePhase;
SummonMissingPhase: SummonMissingPhase;
SummonPhase: SummonPhase;
SwitchBiomePhase: SwitchBiomePhase;
SwitchPhase: SwitchPhase;
SwitchSummonPhase: SwitchSummonPhase;
TeraPhase: TeraPhase;
TitlePhase: TitlePhase;
ToggleDoublePositionPhase: ToggleDoublePositionPhase;
TrainerVictoryPhase: TrainerVictoryPhase;
TurnEndPhase: TurnEndPhase;
TurnInitPhase: TurnInitPhase;
TurnStartPhase: TurnStartPhase;
UnavailablePhase: UnavailablePhase;
UnlockPhase: UnlockPhase;
VictoryPhase: VictoryPhase;
WeatherEffectPhase: WeatherEffectPhase;
};
export type PhaseString = keyof PhaseMap;

View File

@ -1,9 +1,33 @@
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
import type { PhaseMap, PhaseString } from "./@types/phase-types";
export class Phase { export abstract class Phase {
start() {} start() {}
end() { end() {
globalScene.shiftPhase(); globalScene.shiftPhase();
} }
/**
* The string name of the phase, used to identify the phase type for {@linkcode isXPhase}
*
* @privateremarks
*
* When implementing a phase, you must set the `phaseName` property to the name of the phase.
*/
protected abstract readonly phaseName: PhaseString;
/**
* Check if the phase is of the given type without requiring `instanceof`.
*
* @param phase - The string name of the phase to check.
* @returns `true` if this phase is of the given type, `false` otherwise.
*
* @remarks
* 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.
*/
isXPhase<K extends keyof PhaseMap>(phase: K): this is PhaseMap[K] {
return this.phaseName === phase;
}
} }

View File

@ -9,6 +9,7 @@ import { Phase } from "#app/phase";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
export class AddEnemyBuffModifierPhase extends Phase { export class AddEnemyBuffModifierPhase extends Phase {
protected readonly phaseName = "AddEnemyBuffModifierPhase";
start() { start() {
super.start(); super.start();

View File

@ -27,6 +27,7 @@ import { globalScene } from "#app/global-scene";
import { Gender } from "#app/data/gender"; import { Gender } from "#app/data/gender";
export class AttemptCapturePhase extends PokemonPhase { export class AttemptCapturePhase extends PokemonPhase {
protected readonly phaseName = "AttemptCapturePhase";
private pokeballType: PokeballType; private pokeballType: PokeballType;
private pokeball: Phaser.GameObjects.Sprite; private pokeball: Phaser.GameObjects.Sprite;
private originalY: number; private originalY: number;

View File

@ -17,6 +17,7 @@ import { globalScene } from "#app/global-scene";
import { SelectBiomePhase } from "./select-biome-phase"; import { SelectBiomePhase } from "./select-biome-phase";
export class AttemptRunPhase extends PokemonPhase { export class AttemptRunPhase extends PokemonPhase {
protected readonly phaseName = "AttemptRunPhase";
/** For testing purposes: this is to force the pokemon to fail and escape */ /** For testing purposes: this is to force the pokemon to fail and escape */
public forceFailEscape = false; public forceFailEscape = false;

View File

@ -5,6 +5,7 @@ import { BattlePhase } from "./battle-phase";
import { GameOverPhase } from "./game-over-phase"; import { GameOverPhase } from "./game-over-phase";
export class BattleEndPhase extends BattlePhase { export class BattleEndPhase extends BattlePhase {
protected readonly phaseName = "BattleEndPhase";
/** If true, will increment battles won */ /** If true, will increment battles won */
isVictory: boolean; isVictory: boolean;

View File

@ -2,7 +2,7 @@ import { globalScene } from "#app/global-scene";
import { TrainerSlot } from "#enums/trainer-slot"; import { TrainerSlot } from "#enums/trainer-slot";
import { Phase } from "#app/phase"; import { Phase } from "#app/phase";
export class BattlePhase extends Phase { export abstract class BattlePhase extends Phase {
showEnemyTrainer(trainerSlot: TrainerSlot = TrainerSlot.NONE): void { showEnemyTrainer(trainerSlot: TrainerSlot = TrainerSlot.NONE): void {
if (!globalScene.currentBattle.trainer) { if (!globalScene.currentBattle.trainer) {
console.warn("Enemy trainer is missing!"); console.warn("Enemy trainer is missing!");

View File

@ -20,6 +20,7 @@ import type Pokemon from "#app/field/pokemon";
* Also triggers Cud Chew's "repeat berry use" effects * Also triggers Cud Chew's "repeat berry use" effects
*/ */
export class BerryPhase extends FieldPhase { export class BerryPhase extends FieldPhase {
protected readonly phaseName = "BerryPhase";
start() { start() {
super.start(); super.start();

View File

@ -4,6 +4,7 @@ import type { BattlerIndex } from "#app/battle";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
export class CheckStatusEffectPhase extends Phase { export class CheckStatusEffectPhase extends Phase {
protected readonly phaseName = "CheckStatusEffectPhase";
private order: BattlerIndex[]; private order: BattlerIndex[];
constructor(order: BattlerIndex[]) { constructor(order: BattlerIndex[]) {
super(); super();

View File

@ -10,6 +10,7 @@ import { SwitchPhase } from "./switch-phase";
import { SwitchType } from "#enums/switch-type"; import { SwitchType } from "#enums/switch-type";
export class CheckSwitchPhase extends BattlePhase { export class CheckSwitchPhase extends BattlePhase {
protected readonly phaseName = "CheckSwitchPhase";
protected fieldIndex: number; protected fieldIndex: number;
protected useName: boolean; protected useName: boolean;

View File

@ -25,6 +25,7 @@ import { ArenaTagSide } from "#app/data/arena-tag";
import { ArenaTagType } from "#app/enums/arena-tag-type"; import { ArenaTagType } from "#app/enums/arena-tag-type";
export class CommandPhase extends FieldPhase { export class CommandPhase extends FieldPhase {
protected readonly phaseName = "CommandPhase";
protected fieldIndex: number; protected fieldIndex: number;
constructor(fieldIndex: number) { constructor(fieldIndex: number) {

View File

@ -5,6 +5,9 @@ import { CommonBattleAnim } from "#app/data/battle-anims";
import { PokemonPhase } from "./pokemon-phase"; import { PokemonPhase } from "./pokemon-phase";
export class CommonAnimPhase extends PokemonPhase { export class CommonAnimPhase extends PokemonPhase {
// PokemonHealPhase extends CommonAnimPhase, and to make typescript happy,
// we need to allow phaseName to be a union of the two
protected readonly phaseName: "CommonAnimPhase" | "PokemonHealPhase" | "WeatherEffectPhase" = "CommonAnimPhase";
private anim: CommonAnim | null; private anim: CommonAnim | null;
private targetIndex?: BattlerIndex; private targetIndex?: BattlerIndex;
private playOnEmptyField: boolean; private playOnEmptyField: boolean;

View File

@ -6,6 +6,7 @@ import { fixedInt } from "#app/utils/common";
import { PokemonPhase } from "#app/phases/pokemon-phase"; import { PokemonPhase } from "#app/phases/pokemon-phase";
export class DamageAnimPhase extends PokemonPhase { export class DamageAnimPhase extends PokemonPhase {
protected readonly phaseName = "DamageAnimPhase";
private amount: number; private amount: number;
private damageResult: DamageResult; private damageResult: DamageResult;
private critical: boolean; private critical: boolean;

View File

@ -20,6 +20,7 @@ import { doShinySparkleAnim } from "#app/field/anims";
* Class that represents egg hatching * Class that represents egg hatching
*/ */
export class EggHatchPhase extends Phase { export class EggHatchPhase extends Phase {
protected readonly phaseName = "EggHatchPhase";
/** The egg that is hatching */ /** The egg that is hatching */
private egg: Egg; private egg: Egg;
/** The new EggHatchData for the egg/pokemon that hatches */ /** The new EggHatchData for the egg/pokemon that hatches */

View File

@ -16,6 +16,7 @@ import { EggHatchData } from "#app/data/egg-hatch-data";
* Also handles prompts for skipping animation, and calling the egg summary phase * Also handles prompts for skipping animation, and calling the egg summary phase
*/ */
export class EggLapsePhase extends Phase { export class EggLapsePhase extends Phase {
protected readonly phaseName = "EggLapsePhase";
private eggHatchData: EggHatchData[] = []; private eggHatchData: EggHatchData[] = [];
private readonly minEggsToSkip: number = 2; private readonly minEggsToSkip: number = 2;

View File

@ -9,6 +9,7 @@ import type { EggHatchData } from "#app/data/egg-hatch-data";
* Phase is handled mostly by the egg-hatch-scene-handler UI * Phase is handled mostly by the egg-hatch-scene-handler UI
*/ */
export class EggSummaryPhase extends Phase { export class EggSummaryPhase extends Phase {
protected readonly phaseName = "EggSummaryPhase";
private eggHatchData: EggHatchData[]; private eggHatchData: EggHatchData[];
constructor(eggHatchData: EggHatchData[]) { constructor(eggHatchData: EggHatchData[]) {

View File

@ -47,6 +47,7 @@ import { WEIGHT_INCREMENT_ON_SPAWN_MISS } from "#app/data/mystery-encounters/mys
import { getNatureName } from "#app/data/nature"; import { getNatureName } from "#app/data/nature";
export class EncounterPhase extends BattlePhase { export class EncounterPhase extends BattlePhase {
protected readonly phaseName = "EncounterPhase";
private loaded: boolean; private loaded: boolean;
constructor(loaded = false) { constructor(loaded = false) {

View File

@ -5,6 +5,7 @@ import { addTextObject, TextStyle } from "#app/ui/text";
import i18next from "i18next"; import i18next from "i18next";
export class EndCardPhase extends Phase { export class EndCardPhase extends Phase {
protected readonly phaseName = "EndCardPhase";
public endCard: Phaser.GameObjects.Image; public endCard: Phaser.GameObjects.Image;
public text: Phaser.GameObjects.Text; public text: Phaser.GameObjects.Text;
start(): void { start(): void {

View File

@ -3,6 +3,7 @@ import { Phase } from "#app/phase";
import { UiMode } from "#enums/ui-mode"; import { UiMode } from "#enums/ui-mode";
export class EndEvolutionPhase extends Phase { export class EndEvolutionPhase extends Phase {
protected readonly phaseName = "EndEvolutionPhase";
start() { start() {
super.start(); super.start();

View File

@ -15,6 +15,7 @@ import { BattlerTagType } from "#enums/battler-tag-type";
* @see {@linkcode EnemyPokemon.getNextMove} * @see {@linkcode EnemyPokemon.getNextMove}
*/ */
export class EnemyCommandPhase extends FieldPhase { export class EnemyCommandPhase extends FieldPhase {
protected readonly phaseName = "EnemyCommandPhase";
protected fieldIndex: number; protected fieldIndex: number;
protected skipTurn = false; protected skipTurn = false;

View File

@ -19,6 +19,9 @@ import { EndEvolutionPhase } from "#app/phases/end-evolution-phase";
import { EVOLVE_MOVE } from "#app/data/balance/pokemon-level-moves"; import { EVOLVE_MOVE } from "#app/data/balance/pokemon-level-moves";
export class EvolutionPhase extends Phase { export class EvolutionPhase extends Phase {
// FormChangePhase inherits from this, but EvolutionPhase is not abstract.
// We have to use the union here
protected readonly phaseName: "EvolutionPhase" | "FormChangePhase" = "EvolutionPhase";
protected pokemon: PlayerPokemon; protected pokemon: PlayerPokemon;
protected lastLevel: number; protected lastLevel: number;

View File

@ -7,6 +7,7 @@ import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-pha
import { LevelUpPhase } from "./level-up-phase"; import { LevelUpPhase } from "./level-up-phase";
export class ExpPhase extends PlayerPartyMemberPokemonPhase { export class ExpPhase extends PlayerPartyMemberPokemonPhase {
protected readonly phaseName = "ExpPhase";
private expValue: number; private expValue: number;
constructor(partyMemberIndex: number, expValue: number) { constructor(partyMemberIndex: number, expValue: number) {

View File

@ -35,6 +35,7 @@ import { FRIENDSHIP_LOSS_FROM_FAINT } from "#app/data/balance/starters";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
export class FaintPhase extends PokemonPhase { export class FaintPhase extends PokemonPhase {
protected readonly phaseName = "FaintPhase";
/** /**
* Whether or not instant revive should be prevented * Whether or not instant revive should be prevented
*/ */

View File

@ -13,6 +13,7 @@ import { BattlerTagType } from "#enums/battler-tag-type";
import { SpeciesFormKey } from "#enums/species-form-key"; import { SpeciesFormKey } from "#enums/species-form-key";
export class FormChangePhase extends EvolutionPhase { export class FormChangePhase extends EvolutionPhase {
protected readonly phaseName = "FormChangePhase";
private formChange: SpeciesFormChange; private formChange: SpeciesFormChange;
private modal: boolean; private modal: boolean;

View File

@ -4,6 +4,7 @@ import i18next from "i18next";
import { ModifierRewardPhase } from "./modifier-reward-phase"; import { ModifierRewardPhase } from "./modifier-reward-phase";
export class GameOverModifierRewardPhase extends ModifierRewardPhase { export class GameOverModifierRewardPhase extends ModifierRewardPhase {
protected readonly phaseName = "GameOverModifierRewardPhase";
doReward(): Promise<void> { doReward(): Promise<void> {
return new Promise<void>(resolve => { return new Promise<void>(resolve => {
const newModifier = this.modifierType.newModifier(); const newModifier = this.modifierType.newModifier();

View File

@ -34,6 +34,7 @@ import { pokerogueApi } from "#app/plugins/api/pokerogue-api";
import { MessagePhase } from "./message-phase"; import { MessagePhase } from "./message-phase";
export class GameOverPhase extends BattlePhase { export class GameOverPhase extends BattlePhase {
protected readonly phaseName = "GameOverPhase";
private isVictory: boolean; private isVictory: boolean;
private firstRibbons: PokemonSpecies[] = []; private firstRibbons: PokemonSpecies[] = [];

View File

@ -2,6 +2,7 @@ import { globalScene } from "#app/global-scene";
import { Phase } from "#app/phase"; import { Phase } from "#app/phase";
export class HideAbilityPhase extends Phase { export class HideAbilityPhase extends Phase {
protected readonly phaseName = "HideAbilityPhase";
start() { start() {
super.start(); super.start();

View File

@ -2,6 +2,7 @@ import { globalScene } from "#app/global-scene";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
export class HidePartyExpBarPhase extends BattlePhase { export class HidePartyExpBarPhase extends BattlePhase {
protected readonly phaseName = "HidePartyExpBarPhase";
start() { start() {
super.start(); super.start();

View File

@ -24,6 +24,7 @@ export enum LearnMoveType {
} }
export class LearnMovePhase extends PlayerPartyMemberPokemonPhase { export class LearnMovePhase extends PlayerPartyMemberPokemonPhase {
protected readonly phaseName = "LearnMovePhase";
private moveId: MoveId; private moveId: MoveId;
private messageMode: UiMode; private messageMode: UiMode;
private learnMoveType: LearnMoveType; private learnMoveType: LearnMoveType;

View File

@ -4,6 +4,7 @@ import i18next from "i18next";
import { FieldPhase } from "./field-phase"; import { FieldPhase } from "./field-phase";
export class LevelCapPhase extends FieldPhase { export class LevelCapPhase extends FieldPhase {
protected readonly phaseName = "LevelCapPhase";
start(): void { start(): void {
super.start(); super.start();

View File

@ -10,6 +10,7 @@ import { NumberHolder } from "#app/utils/common";
import i18next from "i18next"; import i18next from "i18next";
export class LevelUpPhase extends PlayerPartyMemberPokemonPhase { export class LevelUpPhase extends PlayerPartyMemberPokemonPhase {
protected readonly phaseName = "LevelUpPhase";
protected lastLevel: number; protected lastLevel: number;
protected level: number; protected level: number;
protected pokemon: PlayerPokemon = this.getPlayerPokemon(); protected pokemon: PlayerPokemon = this.getPlayerPokemon();

View File

@ -8,6 +8,7 @@ import { Phase } from "#app/phase";
* isn't already loaded (e.g. for Metronome) * isn't already loaded (e.g. for Metronome)
*/ */
export class LoadMoveAnimPhase extends Phase { export class LoadMoveAnimPhase extends Phase {
protected readonly phaseName = "LoadMoveAnimPhase";
constructor(protected moveId: MoveId) { constructor(protected moveId: MoveId) {
super(); super();
} }

View File

@ -11,6 +11,7 @@ import { SelectGenderPhase } from "./select-gender-phase";
import { UnavailablePhase } from "./unavailable-phase"; import { UnavailablePhase } from "./unavailable-phase";
export class LoginPhase extends Phase { export class LoginPhase extends Phase {
protected readonly phaseName = "LoginPhase";
private showText: boolean; private showText: boolean;
constructor(showText = true) { constructor(showText = true) {

View File

@ -2,6 +2,7 @@ import { globalScene } from "#app/global-scene";
import { Phase } from "#app/phase"; import { Phase } from "#app/phase";
export class MessagePhase extends Phase { export class MessagePhase extends Phase {
protected readonly phaseName = "MessagePhase";
private text: string; private text: string;
private callbackDelay?: number | null; private callbackDelay?: number | null;
private prompt?: boolean | null; private prompt?: boolean | null;

View File

@ -5,6 +5,9 @@ import i18next from "i18next";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
export class ModifierRewardPhase extends BattlePhase { export class ModifierRewardPhase extends BattlePhase {
// RibbonModifierRewardPhase extends ModifierRewardPhase and to make typescript happy
// we need to use a union type here
protected readonly phaseName: "ModifierRewardPhase" | "RibbonModifierRewardPhase" = "ModifierRewardPhase";
protected modifierType: ModifierType; protected modifierType: ModifierType;
constructor(modifierTypeFunc: ModifierTypeFunc) { constructor(modifierTypeFunc: ModifierTypeFunc) {

View File

@ -6,6 +6,7 @@ import { NumberHolder } from "#app/utils/common";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
export class MoneyRewardPhase extends BattlePhase { export class MoneyRewardPhase extends BattlePhase {
protected readonly phaseName = "MoneyRewardPhase";
private moneyMultiplier: number; private moneyMultiplier: number;
constructor(moneyMultiplier: number) { constructor(moneyMultiplier: number) {

View File

@ -12,6 +12,8 @@ export class MoveAnimPhase<Anim extends MoveAnim> extends Phase {
super(); super();
} }
protected readonly phaseName = "MoveAnimPhase";
public override start(): void { public override start(): void {
super.start(); super.start();

View File

@ -16,6 +16,7 @@ import { MoveEndPhase } from "#app/phases/move-end-phase";
* @extends {@linkcode PokemonPhase} * @extends {@linkcode PokemonPhase}
*/ */
export class MoveChargePhase extends PokemonPhase { export class MoveChargePhase extends PokemonPhase {
protected readonly phaseName = "MoveChargePhase";
/** The move instance that this phase applies */ /** The move instance that this phase applies */
public move: PokemonMove; public move: PokemonMove;
/** The field index targeted by the move (Charging moves assume single target) */ /** The field index targeted by the move (Charging moves assume single target) */

View File

@ -82,6 +82,7 @@ import { DamageAchv } from "#app/system/achv";
type HitCheckEntry = [HitCheckResult, TypeDamageMultiplier]; type HitCheckEntry = [HitCheckResult, TypeDamageMultiplier];
export class MoveEffectPhase extends PokemonPhase { export class MoveEffectPhase extends PokemonPhase {
protected readonly phaseName = "MoveEffectPhase";
public move: Move; public move: Move;
private virtual = false; private virtual = false;
protected targets: BattlerIndex[]; protected targets: BattlerIndex[];

View File

@ -6,6 +6,7 @@ import { applyPostSummonAbAttrs, PostSummonRemoveEffectAbAttr } from "#app/data/
import type Pokemon from "#app/field/pokemon"; import type Pokemon from "#app/field/pokemon";
export class MoveEndPhase extends PokemonPhase { export class MoveEndPhase extends PokemonPhase {
protected readonly phaseName = "MoveEndPhase";
private wasFollowUp: boolean; private wasFollowUp: boolean;
/** Targets from the preceding MovePhase */ /** Targets from the preceding MovePhase */

View File

@ -4,6 +4,7 @@ import type Pokemon from "#app/field/pokemon";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
export class MoveHeaderPhase extends BattlePhase { export class MoveHeaderPhase extends BattlePhase {
protected readonly phaseName = "MoveHeaderPhase";
public pokemon: Pokemon; public pokemon: Pokemon;
public move: PokemonMove; public move: PokemonMove;

View File

@ -52,6 +52,7 @@ import { StatusEffect } from "#enums/status-effect";
import i18next from "i18next"; import i18next from "i18next";
export class MovePhase extends BattlePhase { export class MovePhase extends BattlePhase {
protected readonly phaseName = "MovePhase";
protected _pokemon: Pokemon; protected _pokemon: Pokemon;
protected _move: PokemonMove; protected _move: PokemonMove;
protected _targets: BattlerIndex[]; protected _targets: BattlerIndex[];

View File

@ -39,6 +39,7 @@ import { SelectBiomePhase } from "./select-biome-phase";
* - Queuing of the {@linkcode MysteryEncounterOptionSelectedPhase} * - Queuing of the {@linkcode MysteryEncounterOptionSelectedPhase}
*/ */
export class MysteryEncounterPhase extends Phase { export class MysteryEncounterPhase extends Phase {
protected readonly phaseName = "MysteryEncounterPhase";
private readonly FIRST_DIALOGUE_PROMPT_DELAY = 300; private readonly FIRST_DIALOGUE_PROMPT_DELAY = 300;
optionSelectSettings?: OptionSelectSettings; optionSelectSettings?: OptionSelectSettings;
@ -180,6 +181,7 @@ export class MysteryEncounterPhase extends Phase {
* Any phase that is meant to follow this one MUST be queued via the onOptionSelect() logic of the selected option * Any phase that is meant to follow this one MUST be queued via the onOptionSelect() logic of the selected option
*/ */
export class MysteryEncounterOptionSelectedPhase extends Phase { export class MysteryEncounterOptionSelectedPhase extends Phase {
protected readonly phaseName = "MysteryEncounterOptionSelectedPhase";
onOptionSelect: OptionPhaseCallback; onOptionSelect: OptionPhaseCallback;
constructor() { constructor() {
@ -221,6 +223,7 @@ export class MysteryEncounterOptionSelectedPhase extends Phase {
* See {@linkcode TurnEndPhase} for more details * See {@linkcode TurnEndPhase} for more details
*/ */
export class MysteryEncounterBattleStartCleanupPhase extends Phase { export class MysteryEncounterBattleStartCleanupPhase extends Phase {
protected readonly phaseName = "MysteryEncounterBattleStartCleanupPhase";
/** /**
* Cleans up `TURN_END` tags, any {@linkcode PostTurnStatusEffectPhase}s, checks for Pokemon switches, then continues * Cleans up `TURN_END` tags, any {@linkcode PostTurnStatusEffectPhase}s, checks for Pokemon switches, then continues
*/ */
@ -284,6 +287,7 @@ export class MysteryEncounterBattleStartCleanupPhase extends Phase {
* - Queue the {@linkcode SummonPhase}s, {@linkcode PostSummonPhase}s, etc., required to initialize the phase queue for a battle * - Queue the {@linkcode SummonPhase}s, {@linkcode PostSummonPhase}s, etc., required to initialize the phase queue for a battle
*/ */
export class MysteryEncounterBattlePhase extends Phase { export class MysteryEncounterBattlePhase extends Phase {
protected readonly phaseName = "MysteryEncounterBattlePhase";
disableSwitch: boolean; disableSwitch: boolean;
constructor(disableSwitch = false) { constructor(disableSwitch = false) {
@ -513,6 +517,7 @@ export class MysteryEncounterBattlePhase extends Phase {
* - Queuing of the {@linkcode PostMysteryEncounterPhase} * - Queuing of the {@linkcode PostMysteryEncounterPhase}
*/ */
export class MysteryEncounterRewardsPhase extends Phase { export class MysteryEncounterRewardsPhase extends Phase {
protected readonly phaseName = "MysteryEncounterRewardsPhase";
addHealPhase: boolean; addHealPhase: boolean;
constructor(addHealPhase = false) { constructor(addHealPhase = false) {
@ -580,6 +585,7 @@ export class MysteryEncounterRewardsPhase extends Phase {
* - Queuing of the next wave * - Queuing of the next wave
*/ */
export class PostMysteryEncounterPhase extends Phase { export class PostMysteryEncounterPhase extends Phase {
protected readonly phaseName = "PostMysteryEncounterPhase";
private readonly FIRST_DIALOGUE_PROMPT_DELAY = 750; private readonly FIRST_DIALOGUE_PROMPT_DELAY = 750;
onPostOptionSelect?: OptionPhaseCallback; onPostOptionSelect?: OptionPhaseCallback;

View File

@ -2,6 +2,7 @@ import { globalScene } from "#app/global-scene";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
export class NewBattlePhase extends BattlePhase { export class NewBattlePhase extends BattlePhase {
protected readonly phaseName = "NewBattlePhase";
start() { start() {
super.start(); super.start();

View File

@ -4,6 +4,7 @@ import { getRandomWeatherType } from "#app/data/weather";
import { NextEncounterPhase } from "./next-encounter-phase"; import { NextEncounterPhase } from "./next-encounter-phase";
export class NewBiomeEncounterPhase extends NextEncounterPhase { export class NewBiomeEncounterPhase extends NextEncounterPhase {
protected readonly phaseName = "NewBiomeEncounterPhase";
doEncounter(): void { doEncounter(): void {
globalScene.playBgm(undefined, true); globalScene.playBgm(undefined, true);

View File

@ -6,6 +6,7 @@ import { EncounterPhase } from "./encounter-phase";
* Handles generating, loading and preparing for it. * Handles generating, loading and preparing for it.
*/ */
export class NextEncounterPhase extends EncounterPhase { export class NextEncounterPhase extends EncounterPhase {
protected readonly phaseName = "NextEncounterPhase";
start() { start() {
super.start(); super.start();
} }

View File

@ -11,6 +11,7 @@ import { applyPostSetStatusAbAttrs, PostSetStatusAbAttr } from "#app/data/abilit
import { isNullOrUndefined } from "#app/utils/common"; import { isNullOrUndefined } from "#app/utils/common";
export class ObtainStatusEffectPhase extends PokemonPhase { export class ObtainStatusEffectPhase extends PokemonPhase {
protected readonly phaseName = "ObtainStatusEffectPhase";
private statusEffect?: StatusEffect; private statusEffect?: StatusEffect;
private turnsRemaining?: number; private turnsRemaining?: number;
private sourceText?: string | null; private sourceText?: string | null;

View File

@ -6,6 +6,7 @@ import { Phase } from "#app/phase";
* Intended to be used as a more 1-off phase to provide exp to the party (such as during MEs), rather than cleanup a battle entirely * Intended to be used as a more 1-off phase to provide exp to the party (such as during MEs), rather than cleanup a battle entirely
*/ */
export class PartyExpPhase extends Phase { export class PartyExpPhase extends Phase {
protected readonly phaseName = "PartyExpPhase";
expValue: number; expValue: number;
useWaveIndexMultiplier?: boolean; useWaveIndexMultiplier?: boolean;
pokemonParticipantIds?: Set<number>; pokemonParticipantIds?: Set<number>;

View File

@ -3,6 +3,7 @@ import { fixedInt } from "#app/utils/common";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
export class PartyHealPhase extends BattlePhase { export class PartyHealPhase extends BattlePhase {
protected readonly phaseName = "PartyHealPhase";
private resumeBgm: boolean; private resumeBgm: boolean;
constructor(resumeBgm: boolean) { constructor(resumeBgm: boolean) {

View File

@ -7,6 +7,7 @@ import { PokemonAnimType } from "#enums/pokemon-anim-type";
import { SpeciesId } from "#enums/species-id"; import { SpeciesId } from "#enums/species-id";
export class PokemonAnimPhase extends BattlePhase { export class PokemonAnimPhase extends BattlePhase {
protected readonly phaseName = "PokemonAnimPhase";
/** The type of animation to play in this phase */ /** The type of animation to play in this phase */
protected key: PokemonAnimType; protected key: PokemonAnimType;
/** The Pokemon to which this animation applies */ /** The Pokemon to which this animation applies */

View File

@ -14,6 +14,7 @@ import { BattlerTagType } from "#app/enums/battler-tag-type";
import type { HealBlockTag } from "#app/data/battler-tags"; import type { HealBlockTag } from "#app/data/battler-tags";
export class PokemonHealPhase extends CommonAnimPhase { export class PokemonHealPhase extends CommonAnimPhase {
protected readonly phaseName = "PokemonHealPhase";
private hpHealed: number; private hpHealed: number;
private message: string | null; private message: string | null;
private showFullHpMessage: boolean; private showFullHpMessage: boolean;

View File

@ -13,6 +13,7 @@ import i18next from "i18next";
* Used for Transform (move) and Imposter (ability) * Used for Transform (move) and Imposter (ability)
*/ */
export class PokemonTransformPhase extends PokemonPhase { export class PokemonTransformPhase extends PokemonPhase {
protected readonly phaseName = "PokemonTransformPhase";
protected targetIndex: BattlerIndex; protected targetIndex: BattlerIndex;
private playSound: boolean; private playSound: boolean;

View File

@ -4,6 +4,7 @@ import type { EndCardPhase } from "./end-card-phase";
import { TitlePhase } from "./title-phase"; import { TitlePhase } from "./title-phase";
export class PostGameOverPhase extends Phase { export class PostGameOverPhase extends Phase {
protected readonly phaseName = "PostGameOverPhase";
private endCardPhase?: EndCardPhase; private endCardPhase?: EndCardPhase;
constructor(endCardPhase?: EndCardPhase) { constructor(endCardPhase?: EndCardPhase) {

View File

@ -7,6 +7,7 @@ import { MysteryEncounterPostSummonTag } from "#app/data/battler-tags";
import { BattlerTagType } from "#enums/battler-tag-type"; import { BattlerTagType } from "#enums/battler-tag-type";
export class PostSummonPhase extends PokemonPhase { export class PostSummonPhase extends PokemonPhase {
protected readonly phaseName = "PostSummonPhase";
start() { start() {
super.start(); super.start();

View File

@ -17,6 +17,7 @@ import { BooleanHolder, NumberHolder } from "#app/utils/common";
import { PokemonPhase } from "./pokemon-phase"; import { PokemonPhase } from "./pokemon-phase";
export class PostTurnStatusEffectPhase extends PokemonPhase { export class PostTurnStatusEffectPhase extends PokemonPhase {
protected readonly phaseName = "PostTurnStatusEffectPhase";
// biome-ignore lint/complexity/noUselessConstructor: Not unnecessary as it makes battlerIndex required // biome-ignore lint/complexity/noUselessConstructor: Not unnecessary as it makes battlerIndex required
constructor(battlerIndex: BattlerIndex) { constructor(battlerIndex: BattlerIndex) {
super(battlerIndex); super(battlerIndex);

View File

@ -19,6 +19,7 @@ import {
} from "#app/data/abilities/ability"; } from "#app/data/abilities/ability";
export class QuietFormChangePhase extends BattlePhase { export class QuietFormChangePhase extends BattlePhase {
protected readonly phaseName = "QuietFormChangePhase";
protected pokemon: Pokemon; protected pokemon: Pokemon;
protected formChange: SpeciesFormChange; protected formChange: SpeciesFormChange;

View File

@ -4,6 +4,7 @@ import { UiMode } from "#enums/ui-mode";
import { fixedInt } from "#app/utils/common"; import { fixedInt } from "#app/utils/common";
export class ReloadSessionPhase extends Phase { export class ReloadSessionPhase extends Phase {
protected readonly phaseName = "ReloadSessionPhase";
private systemDataStr?: string; private systemDataStr?: string;
constructor(systemDataStr?: string) { constructor(systemDataStr?: string) {

View File

@ -7,6 +7,7 @@ import { BattlePhase } from "#app/phases/battle-phase";
* This is necessary to perform in a phase primarly to ensure that the status icon disappears at the correct time in the battle * This is necessary to perform in a phase primarly to ensure that the status icon disappears at the correct time in the battle
*/ */
export class ResetStatusPhase extends BattlePhase { export class ResetStatusPhase extends BattlePhase {
protected readonly phaseName = "ResetStatusPhase";
private readonly pokemon: Pokemon; private readonly pokemon: Pokemon;
private readonly affectConfusion: boolean; private readonly affectConfusion: boolean;
private readonly reloadAssets: boolean; private readonly reloadAssets: boolean;

View File

@ -4,6 +4,7 @@ import { SwitchType } from "#enums/switch-type";
import { SwitchSummonPhase } from "./switch-summon-phase"; import { SwitchSummonPhase } from "./switch-summon-phase";
export class ReturnPhase extends SwitchSummonPhase { export class ReturnPhase extends SwitchSummonPhase {
protected readonly phaseName = "ReturnPhase";
constructor(fieldIndex: number) { constructor(fieldIndex: number) {
super(SwitchType.SWITCH, fieldIndex, -1, true); super(SwitchType.SWITCH, fieldIndex, -1, true);
} }

View File

@ -15,6 +15,7 @@ import type { PlayerPokemon } from "#app/field/pokemon";
* when used by one of the player's Pokemon. * when used by one of the player's Pokemon.
*/ */
export class RevivalBlessingPhase extends BattlePhase { export class RevivalBlessingPhase extends BattlePhase {
protected readonly phaseName = "RevivalBlessingPhase";
constructor(protected user: PlayerPokemon) { constructor(protected user: PlayerPokemon) {
super(); super();
} }

View File

@ -6,6 +6,7 @@ import i18next from "i18next";
import { ModifierRewardPhase } from "./modifier-reward-phase"; import { ModifierRewardPhase } from "./modifier-reward-phase";
export class RibbonModifierRewardPhase extends ModifierRewardPhase { export class RibbonModifierRewardPhase extends ModifierRewardPhase {
protected readonly phaseName = "RibbonModifierRewardPhase";
private species: PokemonSpecies; private species: PokemonSpecies;
constructor(modifierTypeFunc: ModifierTypeFunc, species: PokemonSpecies) { constructor(modifierTypeFunc: ModifierTypeFunc, species: PokemonSpecies) {

View File

@ -8,6 +8,7 @@ import i18next from "i18next";
import { PokemonPhase } from "./pokemon-phase"; import { PokemonPhase } from "./pokemon-phase";
export class ScanIvsPhase extends PokemonPhase { export class ScanIvsPhase extends PokemonPhase {
protected readonly phaseName = "ScanIvsPhase";
// biome-ignore lint/complexity/noUselessConstructor: This changes `battlerIndex` to be required // biome-ignore lint/complexity/noUselessConstructor: This changes `battlerIndex` to be required
constructor(battlerIndex: BattlerIndex) { constructor(battlerIndex: BattlerIndex) {
super(battlerIndex); super(battlerIndex);

View File

@ -10,6 +10,7 @@ import { PartyHealPhase } from "./party-heal-phase";
import { SwitchBiomePhase } from "./switch-biome-phase"; import { SwitchBiomePhase } from "./switch-biome-phase";
export class SelectBiomePhase extends BattlePhase { export class SelectBiomePhase extends BattlePhase {
protected readonly phaseName = "SelectBiomePhase";
start() { start() {
super.start(); super.start();

View File

@ -3,6 +3,7 @@ import { Phase } from "#app/phase";
import { UiMode } from "#enums/ui-mode"; import { UiMode } from "#enums/ui-mode";
export class SelectChallengePhase extends Phase { export class SelectChallengePhase extends Phase {
protected readonly phaseName = "SelectChallengePhase";
start() { start() {
super.start(); super.start();

View File

@ -6,6 +6,7 @@ import { UiMode } from "#enums/ui-mode";
import i18next from "i18next"; import i18next from "i18next";
export class SelectGenderPhase extends Phase { export class SelectGenderPhase extends Phase {
protected readonly phaseName = "SelectGenderPhase";
start(): void { start(): void {
super.start(); super.start();

View File

@ -32,6 +32,7 @@ import type { CustomModifierSettings } from "#app/modifier/modifier-type";
import { isNullOrUndefined, NumberHolder } from "#app/utils/common"; import { isNullOrUndefined, NumberHolder } from "#app/utils/common";
export class SelectModifierPhase extends BattlePhase { export class SelectModifierPhase extends BattlePhase {
protected readonly phaseName = "SelectModifierPhase";
private rerollCount: number; private rerollCount: number;
private modifierTiers?: ModifierTier[]; private modifierTiers?: ModifierTier[];
private customModifierSettings?: CustomModifierSettings; private customModifierSettings?: CustomModifierSettings;

View File

@ -15,6 +15,7 @@ import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import { isNullOrUndefined } from "#app/utils/common"; import { isNullOrUndefined } from "#app/utils/common";
export class SelectStarterPhase extends Phase { export class SelectStarterPhase extends Phase {
protected readonly phaseName = "SelectStarterPhase";
start() { start() {
super.start(); super.start();

View File

@ -8,6 +8,7 @@ import i18next from "#app/plugins/i18n";
import { allMoves } from "#app/data/data-lists"; import { allMoves } from "#app/data/data-lists";
export class SelectTargetPhase extends PokemonPhase { export class SelectTargetPhase extends PokemonPhase {
protected readonly phaseName = "SelectTargetPhase";
// biome-ignore lint/complexity/noUselessConstructor: This makes `fieldIndex` required // biome-ignore lint/complexity/noUselessConstructor: This makes `fieldIndex` required
constructor(fieldIndex: number) { constructor(fieldIndex: number) {
super(fieldIndex); super(fieldIndex);

View File

@ -3,6 +3,7 @@ import type { BattlerIndex } from "#app/battle";
import { PokemonPhase } from "./pokemon-phase"; import { PokemonPhase } from "./pokemon-phase";
export class ShinySparklePhase extends PokemonPhase { export class ShinySparklePhase extends PokemonPhase {
protected readonly phaseName = "ShinySparklePhase";
// biome-ignore lint/complexity/noUselessConstructor: This makes `battlerIndex` required // biome-ignore lint/complexity/noUselessConstructor: This makes `battlerIndex` required
constructor(battlerIndex: BattlerIndex) { constructor(battlerIndex: BattlerIndex) {
super(battlerIndex); super(battlerIndex);

View File

@ -5,6 +5,7 @@ import { getPokemonNameWithAffix } from "#app/messages";
import { HideAbilityPhase } from "#app/phases/hide-ability-phase"; import { HideAbilityPhase } from "#app/phases/hide-ability-phase";
export class ShowAbilityPhase extends PokemonPhase { export class ShowAbilityPhase extends PokemonPhase {
protected readonly phaseName = "ShowAbilityPhase";
private passive: boolean; private passive: boolean;
private pokemonName: string; private pokemonName: string;
private abilityName: string; private abilityName: string;

View File

@ -8,6 +8,7 @@ import { LevelUpPhase } from "./level-up-phase";
import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-phase"; import { PlayerPartyMemberPokemonPhase } from "./player-party-member-pokemon-phase";
export class ShowPartyExpBarPhase extends PlayerPartyMemberPokemonPhase { export class ShowPartyExpBarPhase extends PlayerPartyMemberPokemonPhase {
protected readonly phaseName = "ShowPartyExpBarPhase";
private expValue: number; private expValue: number;
constructor(partyMemberIndex: number, expValue: number) { constructor(partyMemberIndex: number, expValue: number) {

View File

@ -3,6 +3,7 @@ import { PlayerGender } from "#app/enums/player-gender";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
export class ShowTrainerPhase extends BattlePhase { export class ShowTrainerPhase extends BattlePhase {
protected readonly phaseName = "ShowTrainerPhase";
start() { start() {
super.start(); super.start();

View File

@ -31,6 +31,7 @@ export type StatStageChangeCallback = (
) => void; ) => void;
export class StatStageChangePhase extends PokemonPhase { export class StatStageChangePhase extends PokemonPhase {
protected readonly phaseName = "StatStageChangePhase";
private stats: BattleStat[]; private stats: BattleStat[];
private selfTarget: boolean; private selfTarget: boolean;
private stages: number; private stages: number;

View File

@ -4,6 +4,7 @@ import { SummonPhase } from "./summon-phase";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
export class SummonMissingPhase extends SummonPhase { export class SummonMissingPhase extends SummonPhase {
protected readonly phaseName = "SummonMissingPhase";
preSummon(): void { preSummon(): void {
globalScene.ui.showText( globalScene.ui.showText(
i18next.t("battle:sendOutPokemon", { i18next.t("battle:sendOutPokemon", {

View File

@ -17,6 +17,9 @@ import { applyPreSummonAbAttrs, PreSummonAbAttr } from "#app/data/abilities/abil
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
export class SummonPhase extends PartyMemberPokemonPhase { export class SummonPhase extends PartyMemberPokemonPhase {
// Both SwitchSummonPhase and SummonMissingPhase extend this class and so we must use a
// union type to make typescript happy.
protected readonly phaseName: "SummonPhase" | "SummonMissingPhase" | "SwitchSummonPhase" = "SummonPhase";
private loaded: boolean; private loaded: boolean;
constructor(fieldIndex: number, player = true, loaded = false) { constructor(fieldIndex: number, player = true, loaded = false) {

View File

@ -4,6 +4,7 @@ import { getBiomeKey } from "#app/field/arena";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
export class SwitchBiomePhase extends BattlePhase { export class SwitchBiomePhase extends BattlePhase {
protected readonly phaseName = "SwitchBiomePhase";
private nextBiome: BiomeId; private nextBiome: BiomeId;
constructor(nextBiome: BiomeId) { constructor(nextBiome: BiomeId) {

View File

@ -11,6 +11,7 @@ import { SwitchSummonPhase } from "./switch-summon-phase";
* for the player (if a switch would be valid for the current battle state). * for the player (if a switch would be valid for the current battle state).
*/ */
export class SwitchPhase extends BattlePhase { export class SwitchPhase extends BattlePhase {
protected readonly phaseName = "SwitchPhase";
protected readonly fieldIndex: number; protected readonly fieldIndex: number;
private readonly switchType: SwitchType; private readonly switchType: SwitchType;
private readonly isModal: boolean; private readonly isModal: boolean;

View File

@ -22,6 +22,7 @@ import { SubstituteTag } from "#app/data/battler-tags";
import { SwitchType } from "#enums/switch-type"; import { SwitchType } from "#enums/switch-type";
export class SwitchSummonPhase extends SummonPhase { export class SwitchSummonPhase extends SummonPhase {
protected readonly phaseName = "SwitchSummonPhase";
private readonly switchType: SwitchType; private readonly switchType: SwitchType;
private readonly slotIndex: number; private readonly slotIndex: number;
private readonly doReturn: boolean; private readonly doReturn: boolean;

View File

@ -9,6 +9,7 @@ import { SpeciesFormChangeTeraTrigger } from "#app/data/pokemon-forms";
import { CommonAnim, CommonBattleAnim } from "#app/data/battle-anims"; import { CommonAnim, CommonBattleAnim } from "#app/data/battle-anims";
export class TeraPhase extends BattlePhase { export class TeraPhase extends BattlePhase {
protected readonly phaseName = "TeraPhase";
public pokemon: Pokemon; public pokemon: Pokemon;
constructor(pokemon: Pokemon) { constructor(pokemon: Pokemon) {

View File

@ -29,6 +29,7 @@ import { globalScene } from "#app/global-scene";
import Overrides from "#app/overrides"; import Overrides from "#app/overrides";
export class TitlePhase extends Phase { export class TitlePhase extends Phase {
protected readonly phaseName = "TitlePhase";
private loaded = false; private loaded = false;
private lastSessionData: SessionSaveData; private lastSessionData: SessionSaveData;
public gameMode: GameModes; public gameMode: GameModes;

View File

@ -3,6 +3,7 @@ import { FieldPosition } from "#app/field/pokemon";
import { BattlePhase } from "./battle-phase"; import { BattlePhase } from "./battle-phase";
export class ToggleDoublePositionPhase extends BattlePhase { export class ToggleDoublePositionPhase extends BattlePhase {
protected readonly phaseName = "ToggleDoublePositionPhase";
private double: boolean; private double: boolean;
constructor(double: boolean) { constructor(double: boolean) {

View File

@ -14,6 +14,7 @@ import { achvs } from "#app/system/achv";
import { timedEventManager } from "#app/global-event-manager"; import { timedEventManager } from "#app/global-event-manager";
export class TrainerVictoryPhase extends BattlePhase { export class TrainerVictoryPhase extends BattlePhase {
protected readonly phaseName = "TrainerVictoryPhase";
start() { start() {
globalScene.disableMenu = true; globalScene.disableMenu = true;

View File

@ -18,6 +18,7 @@ import { PokemonHealPhase } from "./pokemon-heal-phase";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
export class TurnEndPhase extends FieldPhase { export class TurnEndPhase extends FieldPhase {
protected readonly phaseName = "TurnEndPhase";
start() { start() {
super.start(); super.start();

View File

@ -15,6 +15,7 @@ import { TurnStartPhase } from "./turn-start-phase";
import { globalScene } from "#app/global-scene"; import { globalScene } from "#app/global-scene";
export class TurnInitPhase extends FieldPhase { export class TurnInitPhase extends FieldPhase {
protected readonly phaseName = "TurnInitPhase";
start() { start() {
super.start(); super.start();

View File

@ -25,6 +25,7 @@ import { globalScene } from "#app/global-scene";
import { TeraPhase } from "./tera-phase"; import { TeraPhase } from "./tera-phase";
export class TurnStartPhase extends FieldPhase { export class TurnStartPhase extends FieldPhase {
protected readonly phaseName = "TurnStartPhase";
/** /**
* This orders the active Pokemon on the field by speed into an BattlerIndex array and returns that array. * This orders the active Pokemon on the field by speed into an BattlerIndex array and returns that array.
* It also checks for Trick Room and reverses the array if it is present. * It also checks for Trick Room and reverses the array if it is present.

View File

@ -4,6 +4,7 @@ import { UiMode } from "#enums/ui-mode";
import { LoginPhase } from "./login-phase"; import { LoginPhase } from "./login-phase";
export class UnavailablePhase extends Phase { export class UnavailablePhase extends Phase {
protected readonly phaseName = "UnavailablePhase";
start(): void { start(): void {
globalScene.ui.setMode(UiMode.UNAVAILABLE, () => { globalScene.ui.setMode(UiMode.UNAVAILABLE, () => {
globalScene.unshiftPhase(new LoginPhase(true)); globalScene.unshiftPhase(new LoginPhase(true));

View File

@ -6,6 +6,7 @@ import { UiMode } from "#enums/ui-mode";
import i18next from "i18next"; import i18next from "i18next";
export class UnlockPhase extends Phase { export class UnlockPhase extends Phase {
protected readonly phaseName = "UnlockPhase";
private unlockable: Unlockables; private unlockable: Unlockables;
constructor(unlockable: Unlockables) { constructor(unlockable: Unlockables) {

View File

@ -18,6 +18,7 @@ import { timedEventManager } from "#app/global-event-manager";
import { SelectBiomePhase } from "./select-biome-phase"; import { SelectBiomePhase } from "./select-biome-phase";
export class VictoryPhase extends PokemonPhase { export class VictoryPhase extends PokemonPhase {
protected readonly phaseName = "VictoryPhase";
/** If true, indicates that the phase is intended for EXP purposes only, and not to continue a battle to next phase */ /** If true, indicates that the phase is intended for EXP purposes only, and not to continue a battle to next phase */
isExpOnly: boolean; isExpOnly: boolean;

View File

@ -19,6 +19,7 @@ import { BooleanHolder, toDmgValue } from "#app/utils/common";
import { CommonAnimPhase } from "./common-anim-phase"; import { CommonAnimPhase } from "./common-anim-phase";
export class WeatherEffectPhase extends CommonAnimPhase { export class WeatherEffectPhase extends CommonAnimPhase {
protected readonly phaseName = "WeatherEffectPhase";
public weather: Weather | null; public weather: Weather | null;
constructor() { constructor() {