mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 07:22:19 +02:00
Add newPhase method to phase-manager
This commit is contained in:
parent
75beec12a8
commit
5cd3da3f78
@ -1,286 +1,26 @@
|
|||||||
import type { MoveAnim } from "#app/data/battle-anims";
|
import type { PhaseConstructorMap } from "#app/phase-manager";
|
||||||
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 { BattleEndPhase } from "#app/phases/battle-end-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 { 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 { EggHatchPhase } from "#app/phases/egg-hatch-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 { EndCardPhase } from "#app/phases/end-card-phase";
|
|
||||||
import type { EndEvolutionPhase } from "#app/phases/end-evolution-phase";
|
|
||||||
import type { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
|
|
||||||
import type { EvolutionPhase } from "#app/phases/evolution-phase";
|
|
||||||
import type { ExpPhase } from "#app/phases/exp-phase";
|
|
||||||
import type { FaintPhase } from "#app/phases/faint-phase";
|
|
||||||
import type { FormChangePhase } from "#app/phases/form-change-phase";
|
|
||||||
import type { GameOverModifierRewardPhase } from "#app/phases/game-over-modifier-reward-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 { 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 { MessagePhase } from "#app/phases/message-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 { 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 {
|
|
||||||
MysteryEncounterPhase,
|
|
||||||
MysteryEncounterOptionSelectedPhase,
|
|
||||||
MysteryEncounterBattlePhase,
|
|
||||||
MysteryEncounterRewardsPhase,
|
|
||||||
PostMysteryEncounterPhase,
|
|
||||||
MysteryEncounterBattleStartCleanupPhase,
|
|
||||||
} from "#app/phases/mystery-encounter-phases";
|
|
||||||
import type { NewBattlePhase } from "#app/phases/new-battle-phase";
|
|
||||||
import type { NewBiomeEncounterPhase } from "#app/phases/new-biome-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 { 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 { 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 { 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 { 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 { SelectChallengePhase } from "#app/phases/select-challenge-phase";
|
|
||||||
import type { SelectGenderPhase } from "#app/phases/select-gender-phase";
|
|
||||||
import type { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
|
||||||
import type { SelectStarterPhase } from "#app/phases/select-starter-phase";
|
|
||||||
import type { SelectTargetPhase } from "#app/phases/select-target-phase";
|
|
||||||
import type { ShinySparklePhase } from "#app/phases/shiny-sparkle-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 { SummonMissingPhase } from "#app/phases/summon-missing-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 { 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 { 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 { TurnInitPhase } from "#app/phases/turn-init-phase";
|
|
||||||
import type { TurnStartPhase } from "#app/phases/turn-start-phase";
|
|
||||||
import type { UnavailablePhase } from "#app/phases/unavailable-phase";
|
|
||||||
import type { UnlockPhase } from "#app/phases/unlock-phase";
|
|
||||||
import type { VictoryPhase } from "#app/phases/victory-phase";
|
|
||||||
import type { WeatherEffectPhase } from "#app/phases/weather-effect-phase";
|
|
||||||
|
|
||||||
export type PhaseClass =
|
// Intentionally export the types of everything in phase-manager, as this file is meant to be the centralized
|
||||||
| typeof AddEnemyBuffModifierPhase
|
// type definitions for the phase system.
|
||||||
| typeof AttemptCapturePhase
|
export type * from "#app/phase-manager";
|
||||||
| typeof AttemptRunPhase
|
|
||||||
| 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 MysteryEncounterOptionSelectedPhase
|
|
||||||
| typeof MysteryEncounterBattlePhase
|
|
||||||
| typeof MysteryEncounterRewardsPhase
|
|
||||||
| typeof MysteryEncounterBattleStartCleanupPhase
|
|
||||||
| typeof MysteryEncounterRewardsPhase
|
|
||||||
| typeof PostMysteryEncounterPhase
|
|
||||||
| typeof NewBattlePhase
|
|
||||||
| typeof NewBiomeEncounterPhase
|
|
||||||
| typeof NextEncounterPhase
|
|
||||||
| typeof ObtainStatusEffectPhase
|
|
||||||
| typeof PartyExpPhase
|
|
||||||
| typeof PartyHealPhase
|
|
||||||
| typeof PokemonAnimPhase
|
|
||||||
| typeof PokemonHealPhase
|
|
||||||
| typeof PokemonTransformPhase
|
|
||||||
| typeof PostGameOverPhase
|
|
||||||
| typeof PostSummonPhase
|
|
||||||
| typeof PostTurnStatusEffectPhase
|
|
||||||
| typeof QuietFormChangePhase
|
|
||||||
| typeof ReloadSessionPhase
|
|
||||||
| typeof ResetStatusPhase
|
|
||||||
| typeof ReturnPhase
|
|
||||||
| typeof RevivalBlessingPhase
|
|
||||||
| typeof RibbonModifierRewardPhase
|
|
||||||
| typeof ScanIvsPhase
|
|
||||||
| typeof SelectBiomePhase
|
|
||||||
| typeof SelectChallengePhase
|
|
||||||
| typeof SelectGenderPhase
|
|
||||||
| typeof SelectModifierPhase
|
|
||||||
| typeof SelectStarterPhase
|
|
||||||
| typeof SelectTargetPhase
|
|
||||||
| typeof ShinySparklePhase
|
|
||||||
| typeof ShowAbilityPhase
|
|
||||||
| typeof ShowTrainerPhase
|
|
||||||
| typeof ShowPartyExpBarPhase
|
|
||||||
| typeof StatStageChangePhase
|
|
||||||
| typeof SummonMissingPhase
|
|
||||||
| typeof SummonPhase
|
|
||||||
| typeof SwitchBiomePhase
|
|
||||||
| typeof SwitchPhase
|
|
||||||
| typeof SwitchSummonPhase
|
|
||||||
| typeof TeraPhase
|
|
||||||
| typeof TitlePhase
|
|
||||||
| typeof ToggleDoublePositionPhase
|
|
||||||
| typeof TrainerVictoryPhase
|
|
||||||
| typeof TurnEndPhase
|
|
||||||
| typeof TurnInitPhase
|
|
||||||
| typeof TurnStartPhase
|
|
||||||
| typeof UnavailablePhase
|
|
||||||
| typeof UnlockPhase
|
|
||||||
| typeof VictoryPhase
|
|
||||||
| typeof WeatherEffectPhase;
|
|
||||||
|
|
||||||
/** Typescript map used to map a string phase to the actual phase type */
|
/*
|
||||||
|
This file includes helpful types for the phase system.
|
||||||
|
It intentionally imports the phase constructor map from the phase manager (and re-exports it)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of phase names to constructors for said phase
|
||||||
|
*/
|
||||||
export type PhaseMap = {
|
export type PhaseMap = {
|
||||||
AddEnemyBuffModifierPhase: AddEnemyBuffModifierPhase;
|
[K in keyof PhaseConstructorMap]: InstanceType<PhaseConstructorMap[K]>;
|
||||||
AttemptCapturePhase: AttemptCapturePhase;
|
|
||||||
AttemptRunPhase: AttemptRunPhase;
|
|
||||||
BattleEndPhase: BattleEndPhase;
|
|
||||||
BerryPhase: BerryPhase;
|
|
||||||
CheckStatusEffectPhase: CheckStatusEffectPhase;
|
|
||||||
CheckSwitchPhase: CheckSwitchPhase;
|
|
||||||
CommandPhase: CommandPhase;
|
|
||||||
CommonAnimPhase: CommonAnimPhase;
|
|
||||||
DamageAnimPhase: DamageAnimPhase;
|
|
||||||
EggHatchPhase: EggHatchPhase;
|
|
||||||
EggLapsePhase: EggLapsePhase;
|
|
||||||
EggSummaryPhase: EggSummaryPhase;
|
|
||||||
EncounterPhase: EncounterPhase;
|
|
||||||
EndCardPhase: EndCardPhase;
|
|
||||||
EndEvolutionPhase: EndEvolutionPhase;
|
|
||||||
EnemyCommandPhase: EnemyCommandPhase;
|
|
||||||
EvolutionPhase: EvolutionPhase;
|
|
||||||
ExpPhase: ExpPhase;
|
|
||||||
FaintPhase: FaintPhase;
|
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Union type of all phase constructors.
|
||||||
|
*/
|
||||||
|
export type PhaseClass = PhaseConstructorMap[keyof PhaseConstructorMap];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Union type of all phase names as strings.
|
||||||
|
*/
|
||||||
export type PhaseString = keyof PhaseMap;
|
export type PhaseString = keyof PhaseMap;
|
||||||
|
@ -1,11 +1,101 @@
|
|||||||
import { HideAbilityPhase } from "./phases/hide-ability-phase";
|
|
||||||
import { ShowAbilityPhase } from "./phases/show-ability-phase";
|
|
||||||
import { TurnInitPhase } from "./phases/turn-init-phase";
|
|
||||||
import type { Phase } from "#app/phase";
|
import type { Phase } from "#app/phase";
|
||||||
import type { default as Pokemon } from "#app/field/pokemon";
|
import type { default as Pokemon } from "#app/field/pokemon";
|
||||||
import type { Constructor } from "#app/utils/common";
|
import type { Constructor } from "./utils/common";
|
||||||
import { MessagePhase } from "./phases/message-phase";
|
|
||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
|
import { AddEnemyBuffModifierPhase } from "#app/phases/add-enemy-buff-modifier-phase";
|
||||||
|
import { AttemptCapturePhase } from "#app/phases/attempt-capture-phase";
|
||||||
|
import { AttemptRunPhase } from "#app/phases/attempt-run-phase";
|
||||||
|
import { BattleEndPhase } from "#app/phases/battle-end-phase";
|
||||||
|
import { BerryPhase } from "#app/phases/berry-phase";
|
||||||
|
import { CheckStatusEffectPhase } from "#app/phases/check-status-effect-phase";
|
||||||
|
import { CheckSwitchPhase } from "#app/phases/check-switch-phase";
|
||||||
|
import { CommandPhase } from "#app/phases/command-phase";
|
||||||
|
import { CommonAnimPhase } from "#app/phases/common-anim-phase";
|
||||||
|
import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
|
||||||
|
import { EggHatchPhase } from "#app/phases/egg-hatch-phase";
|
||||||
|
import { EggLapsePhase } from "#app/phases/egg-lapse-phase";
|
||||||
|
import { EggSummaryPhase } from "#app/phases/egg-summary-phase";
|
||||||
|
import { EncounterPhase } from "#app/phases/encounter-phase";
|
||||||
|
import { EndCardPhase } from "#app/phases/end-card-phase";
|
||||||
|
import { EndEvolutionPhase } from "#app/phases/end-evolution-phase";
|
||||||
|
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
|
||||||
|
import { EvolutionPhase } from "#app/phases/evolution-phase";
|
||||||
|
import { ExpPhase } from "#app/phases/exp-phase";
|
||||||
|
import { FaintPhase } from "#app/phases/faint-phase";
|
||||||
|
import { FormChangePhase } from "#app/phases/form-change-phase";
|
||||||
|
import { GameOverModifierRewardPhase } from "#app/phases/game-over-modifier-reward-phase";
|
||||||
|
import { GameOverPhase } from "#app/phases/game-over-phase";
|
||||||
|
import { HideAbilityPhase } from "#app/phases/hide-ability-phase";
|
||||||
|
import { HidePartyExpBarPhase } from "#app/phases/hide-party-exp-bar-phase";
|
||||||
|
import { LearnMovePhase } from "#app/phases/learn-move-phase";
|
||||||
|
import { LevelCapPhase } from "#app/phases/level-cap-phase";
|
||||||
|
import { LevelUpPhase } from "#app/phases/level-up-phase";
|
||||||
|
import { LoadMoveAnimPhase } from "#app/phases/load-move-anim-phase";
|
||||||
|
import { LoginPhase } from "#app/phases/login-phase";
|
||||||
|
import { MessagePhase } from "#app/phases/message-phase";
|
||||||
|
import { ModifierRewardPhase } from "#app/phases/modifier-reward-phase";
|
||||||
|
import { MoneyRewardPhase } from "#app/phases/money-reward-phase";
|
||||||
|
import { MoveAnimPhase } from "#app/phases/move-anim-phase";
|
||||||
|
import { MoveChargePhase } from "#app/phases/move-charge-phase";
|
||||||
|
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
|
||||||
|
import { MoveEndPhase } from "#app/phases/move-end-phase";
|
||||||
|
import { MoveHeaderPhase } from "#app/phases/move-header-phase";
|
||||||
|
import { MovePhase } from "#app/phases/move-phase";
|
||||||
|
import {
|
||||||
|
MysteryEncounterPhase,
|
||||||
|
MysteryEncounterOptionSelectedPhase,
|
||||||
|
MysteryEncounterBattlePhase,
|
||||||
|
MysteryEncounterRewardsPhase,
|
||||||
|
PostMysteryEncounterPhase,
|
||||||
|
MysteryEncounterBattleStartCleanupPhase,
|
||||||
|
} from "#app/phases/mystery-encounter-phases";
|
||||||
|
import { NewBattlePhase } from "#app/phases/new-battle-phase";
|
||||||
|
import { NewBiomeEncounterPhase } from "#app/phases/new-biome-encounter-phase";
|
||||||
|
import { NextEncounterPhase } from "#app/phases/next-encounter-phase";
|
||||||
|
import { ObtainStatusEffectPhase } from "#app/phases/obtain-status-effect-phase";
|
||||||
|
import { PartyExpPhase } from "#app/phases/party-exp-phase";
|
||||||
|
import { PartyHealPhase } from "#app/phases/party-heal-phase";
|
||||||
|
import { PokemonAnimPhase } from "#app/phases/pokemon-anim-phase";
|
||||||
|
import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase";
|
||||||
|
import { PokemonTransformPhase } from "#app/phases/pokemon-transform-phase";
|
||||||
|
import { PostGameOverPhase } from "#app/phases/post-game-over-phase";
|
||||||
|
import { PostSummonPhase } from "#app/phases/post-summon-phase";
|
||||||
|
import { PostTurnStatusEffectPhase } from "#app/phases/post-turn-status-effect-phase";
|
||||||
|
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
|
||||||
|
import { ReloadSessionPhase } from "#app/phases/reload-session-phase";
|
||||||
|
import { ResetStatusPhase } from "#app/phases/reset-status-phase";
|
||||||
|
import { ReturnPhase } from "#app/phases/return-phase";
|
||||||
|
import { RevivalBlessingPhase } from "#app/phases/revival-blessing-phase";
|
||||||
|
import { RibbonModifierRewardPhase } from "#app/phases/ribbon-modifier-reward-phase";
|
||||||
|
import { ScanIvsPhase } from "#app/phases/scan-ivs-phase";
|
||||||
|
import { SelectBiomePhase } from "#app/phases/select-biome-phase";
|
||||||
|
import { SelectChallengePhase } from "#app/phases/select-challenge-phase";
|
||||||
|
import { SelectGenderPhase } from "#app/phases/select-gender-phase";
|
||||||
|
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
||||||
|
import { SelectStarterPhase } from "#app/phases/select-starter-phase";
|
||||||
|
import { SelectTargetPhase } from "#app/phases/select-target-phase";
|
||||||
|
import { ShinySparklePhase } from "#app/phases/shiny-sparkle-phase";
|
||||||
|
import { ShowAbilityPhase } from "#app/phases/show-ability-phase";
|
||||||
|
import { ShowPartyExpBarPhase } from "#app/phases/show-party-exp-bar-phase";
|
||||||
|
import { ShowTrainerPhase } from "#app/phases/show-trainer-phase";
|
||||||
|
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
||||||
|
import { SummonMissingPhase } from "#app/phases/summon-missing-phase";
|
||||||
|
import { SummonPhase } from "#app/phases/summon-phase";
|
||||||
|
import { SwitchBiomePhase } from "#app/phases/switch-biome-phase";
|
||||||
|
import { SwitchPhase } from "#app/phases/switch-phase";
|
||||||
|
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
|
||||||
|
import { TeraPhase } from "#app/phases/tera-phase";
|
||||||
|
import { TitlePhase } from "#app/phases/title-phase";
|
||||||
|
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
|
||||||
|
import { TrainerVictoryPhase } from "#app/phases/trainer-victory-phase";
|
||||||
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
||||||
|
import { TurnInitPhase } from "#app/phases/turn-init-phase";
|
||||||
|
import { TurnStartPhase } from "#app/phases/turn-start-phase";
|
||||||
|
import { UnavailablePhase } from "#app/phases/unavailable-phase";
|
||||||
|
import { UnlockPhase } from "#app/phases/unlock-phase";
|
||||||
|
import { VictoryPhase } from "#app/phases/victory-phase";
|
||||||
|
import { WeatherEffectPhase } from "#app/phases/weather-effect-phase";
|
||||||
|
import type { PhaseString } from "./@types/phase-types";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manager for phases used by battle scene.
|
* Manager for phases used by battle scene.
|
||||||
@ -13,6 +103,115 @@ import { globalScene } from "#app/global-scene";
|
|||||||
* *This file must not be imported or used directly. The manager is exclusively used by the battle scene and is not intended for external use.*
|
* *This file must not be imported or used directly. The manager is exclusively used by the battle scene and is not intended for external use.*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object that holds all of the phase constructors.
|
||||||
|
* This is used to create new phases dynamically using the `newPhase` method in the `PhaseManager`.
|
||||||
|
*
|
||||||
|
* @remarks
|
||||||
|
* The keys of this object are the names of the phases, and the values are the constructors of the phases.
|
||||||
|
* This allows for easy creation of new phases without needing to import each phase individually.
|
||||||
|
*/
|
||||||
|
const Phases = Object.freeze({
|
||||||
|
AddEnemyBuffModifierPhase,
|
||||||
|
AttemptCapturePhase,
|
||||||
|
AttemptRunPhase,
|
||||||
|
BattleEndPhase,
|
||||||
|
BerryPhase,
|
||||||
|
CheckStatusEffectPhase,
|
||||||
|
CheckSwitchPhase,
|
||||||
|
CommandPhase,
|
||||||
|
CommonAnimPhase,
|
||||||
|
DamageAnimPhase,
|
||||||
|
EggHatchPhase,
|
||||||
|
EggLapsePhase,
|
||||||
|
EggSummaryPhase,
|
||||||
|
EncounterPhase,
|
||||||
|
EndCardPhase,
|
||||||
|
EndEvolutionPhase,
|
||||||
|
EnemyCommandPhase,
|
||||||
|
EvolutionPhase,
|
||||||
|
ExpPhase,
|
||||||
|
FaintPhase,
|
||||||
|
FormChangePhase,
|
||||||
|
GameOverPhase,
|
||||||
|
GameOverModifierRewardPhase,
|
||||||
|
HideAbilityPhase,
|
||||||
|
HidePartyExpBarPhase,
|
||||||
|
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,
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
|
||||||
|
// This type export cannot be moved to `@types`, as `Phases` is intentionally private to this file
|
||||||
|
/** Maps Phase strings to their constructors */
|
||||||
|
export type PhaseConstructorMap = typeof Phases;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PhaseManager is responsible for managing the phases in the battle scene
|
||||||
|
*/
|
||||||
export class PhaseManager {
|
export class PhaseManager {
|
||||||
/** PhaseQueue: dequeue/remove the first element to get the next phase */
|
/** PhaseQueue: dequeue/remove the first element to get the next phase */
|
||||||
public phaseQueue: Phase[] = [];
|
public phaseQueue: Phase[] = [];
|
||||||
@ -308,4 +507,27 @@ export class PhaseManager {
|
|||||||
}
|
}
|
||||||
this.phaseQueue.push(new TurnInitPhase());
|
this.phaseQueue.push(new TurnInitPhase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dynamically create the named phase from the provided arguments
|
||||||
|
*
|
||||||
|
* @remarks
|
||||||
|
* Used to avoid importing each phase individually, allowing for dynamic creation of phases.
|
||||||
|
* @param phase - The name of the phase to create.
|
||||||
|
* @param args - The arguments to pass to the phase constructor.
|
||||||
|
* @returns The requested phase instance
|
||||||
|
*/
|
||||||
|
public newPhase<T extends PhaseString>(
|
||||||
|
phase: T,
|
||||||
|
...args: ConstructorParameters<PhaseConstructorMap[T]>
|
||||||
|
): InstanceType<(typeof Phases)[T]> {
|
||||||
|
const PhaseClass = Phases[phase];
|
||||||
|
|
||||||
|
if (!PhaseClass) {
|
||||||
|
throw new Error(`Phase ${phase} does not exist in PhaseMap.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @ts-expect-error: Typescript does not support narrowing the type of operands in generic methods (see https://stackoverflow.com/a/72891234)
|
||||||
|
return new PhaseClass(...args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user