mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 07:22:19 +02:00
Replace many instantiations of new phase with phase manager
This commit is contained in:
parent
df6b754b2a
commit
ce779dfe3f
@ -108,7 +108,6 @@ import {
|
||||
SpeciesFormChangeManualTrigger,
|
||||
SpeciesFormChangeTimeOfDayTrigger,
|
||||
} from "#app/data/pokemon-forms";
|
||||
import { FormChangePhase } from "#app/phases/form-change-phase";
|
||||
import { getTypeRgb } from "#app/data/type";
|
||||
import { PokemonType } from "#enums/pokemon-type";
|
||||
import PokemonSpriteSparkleHandler from "#app/field/pokemon-sprite-sparkle-handler";
|
||||
@ -142,18 +141,7 @@ import i18next from "i18next";
|
||||
import { TrainerType } from "#enums/trainer-type";
|
||||
import { battleSpecDialogue } from "#app/data/dialogue";
|
||||
import { LoadingScene } from "#app/loading-scene";
|
||||
import { LevelCapPhase } from "#app/phases/level-cap-phase";
|
||||
import { LoginPhase } from "#app/phases/login-phase";
|
||||
import type { MovePhase } from "#app/phases/move-phase";
|
||||
import { NewBiomeEncounterPhase } from "#app/phases/new-biome-encounter-phase";
|
||||
import { NextEncounterPhase } from "#app/phases/next-encounter-phase";
|
||||
import { PokemonAnimPhase } from "#app/phases/pokemon-anim-phase";
|
||||
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
|
||||
import { ReturnPhase } from "#app/phases/return-phase";
|
||||
import { ShowTrainerPhase } from "#app/phases/show-trainer-phase";
|
||||
import { SummonPhase } from "#app/phases/summon-phase";
|
||||
import { TitlePhase } from "#app/phases/title-phase";
|
||||
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
|
||||
import { ShopCursorTarget } from "#app/enums/shop-cursor-target";
|
||||
import MysteryEncounter from "#app/data/mystery-encounters/mystery-encounter";
|
||||
import {
|
||||
@ -168,8 +156,6 @@ import { MysteryEncounterSaveData } from "#app/data/mystery-encounters/mystery-e
|
||||
import { MysteryEncounterType } from "#enums/mystery-encounter-type";
|
||||
import { MysteryEncounterTier } from "#enums/mystery-encounter-tier";
|
||||
import type HeldModifierConfig from "#app/@types/held-modifier-config";
|
||||
import { ExpPhase } from "#app/phases/exp-phase";
|
||||
import { ShowPartyExpBarPhase } from "#app/phases/show-party-exp-bar-phase";
|
||||
import { MysteryEncounterMode } from "#enums/mystery-encounter-mode";
|
||||
import { ExpGainsSpeed } from "#enums/exp-gains-speed";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
@ -699,8 +685,8 @@ export default class BattleScene extends SceneBase {
|
||||
).then(() => loadMoveAnimAssets(defaultMoves, true)),
|
||||
this.initStarterColors(),
|
||||
]).then(() => {
|
||||
this.phaseManager.pushPhase(new LoginPhase());
|
||||
this.phaseManager.pushPhase(new TitlePhase());
|
||||
this.phaseManager.createAndPush("LoginPhase");
|
||||
this.phaseManager.createAndPush("TitlePhase");
|
||||
|
||||
this.phaseManager.shiftPhase();
|
||||
});
|
||||
@ -1475,7 +1461,7 @@ export default class BattleScene extends SceneBase {
|
||||
|
||||
playerField.forEach((pokemon, p) => {
|
||||
if (pokemon.isOnField()) {
|
||||
this.phaseManager.pushPhase(new ReturnPhase(p));
|
||||
this.phaseManager.createAndPush("ReturnPhase", p);
|
||||
}
|
||||
});
|
||||
|
||||
@ -1492,7 +1478,7 @@ export default class BattleScene extends SceneBase {
|
||||
}
|
||||
|
||||
if (!this.trainer.visible) {
|
||||
this.phaseManager.pushPhase(new ShowTrainerPhase());
|
||||
this.phaseManager.createAndPush("ShowTrainerPhase");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1501,13 +1487,13 @@ export default class BattleScene extends SceneBase {
|
||||
}
|
||||
|
||||
if (!this.gameMode.hasRandomBiomes && !isNewBiome) {
|
||||
this.phaseManager.pushPhase(new NextEncounterPhase());
|
||||
this.phaseManager.createAndPush("NextEncounterPhase");
|
||||
} else {
|
||||
this.phaseManager.pushPhase(new NewBiomeEncounterPhase());
|
||||
this.phaseManager.createAndPush("NewBiomeEncounterPhase");
|
||||
|
||||
const newMaxExpLevel = this.getMaxExpLevel();
|
||||
if (newMaxExpLevel > maxExpLevel) {
|
||||
this.phaseManager.pushPhase(new LevelCapPhase());
|
||||
this.phaseManager.createAndPush("LevelCapPhase");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3199,9 +3185,9 @@ export default class BattleScene extends SceneBase {
|
||||
if (matchingFormChange) {
|
||||
let phase: Phase;
|
||||
if (pokemon.isPlayer() && !matchingFormChange.quiet) {
|
||||
phase = new FormChangePhase(pokemon, matchingFormChange, modal);
|
||||
phase = this.phaseManager.createPhase("FormChangePhase", pokemon, matchingFormChange, modal);
|
||||
} else {
|
||||
phase = new QuietFormChangePhase(pokemon, matchingFormChange);
|
||||
phase = this.phaseManager.createPhase("QuietFormChangePhase", pokemon, matchingFormChange);
|
||||
}
|
||||
if (pokemon.isPlayer() && !matchingFormChange.quiet && modal) {
|
||||
this.phaseManager.overridePhase(phase);
|
||||
@ -3223,11 +3209,12 @@ export default class BattleScene extends SceneBase {
|
||||
fieldAssets?: Phaser.GameObjects.Sprite[],
|
||||
delayed = false,
|
||||
): boolean {
|
||||
const phase: Phase = new PokemonAnimPhase(battleAnimType, pokemon, fieldAssets);
|
||||
const phaseManager = this.phaseManager;
|
||||
const phase: Phase = phaseManager.createPhase("PokemonAnimPhase", battleAnimType, pokemon, fieldAssets);
|
||||
if (delayed) {
|
||||
this.phaseManager.pushPhase(phase);
|
||||
phaseManager.pushPhase(phase);
|
||||
} else {
|
||||
this.phaseManager.unshiftPhase(phase);
|
||||
phaseManager.unshiftPhase(phase);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -3335,9 +3322,9 @@ export default class BattleScene extends SceneBase {
|
||||
this.currentBattle.double = true;
|
||||
const availablePartyMembers = this.getPlayerParty().filter(p => p.isAllowedInBattle());
|
||||
if (availablePartyMembers.length > 1) {
|
||||
this.phaseManager.pushPhase(new ToggleDoublePositionPhase(true));
|
||||
this.phaseManager.createAndPush("ToggleDoublePositionPhase", true);
|
||||
if (!availablePartyMembers[1].isOnField()) {
|
||||
this.phaseManager.pushPhase(new SummonPhase(1));
|
||||
this.phaseManager.createAndPush("SummonPhase", 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3461,8 +3448,8 @@ export default class BattleScene extends SceneBase {
|
||||
const partyMemberIndex = party.indexOf(expPartyMembers[pm]);
|
||||
this.phaseManager.unshiftPhase(
|
||||
expPartyMembers[pm].isOnField()
|
||||
? new ExpPhase(partyMemberIndex, exp)
|
||||
: new ShowPartyExpBarPhase(partyMemberIndex, exp),
|
||||
? this.phaseManager.createPhase("ExpPhase", partyMemberIndex, exp)
|
||||
: this.phaseManager.createPhase("ShowPartyExpBarPhase", partyMemberIndex, exp),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -5856,13 +5856,14 @@ export class PostDancingMoveAbAttr extends PostMoveUsedAbAttr {
|
||||
): void {
|
||||
if (!simulated) {
|
||||
dancer.turnData.extraTurns++;
|
||||
const phaseManager = globalScene.phaseManager;
|
||||
// If the move is an AttackMove or a StatusMove the Dancer must replicate the move on the source of the Dance
|
||||
if (move.getMove() instanceof AttackMove || move.getMove() instanceof StatusMove) {
|
||||
const target = this.getTarget(dancer, source, targets);
|
||||
globalScene.phaseManager.unshiftPhase(new MovePhase(dancer, target, move, true, true));
|
||||
phaseManager.createAndUnshift("MovePhase", dancer, target, move, true, true);
|
||||
} else if (move.getMove() instanceof SelfStatusMove) {
|
||||
// If the move is a SelfStatusMove (ie. Swords Dance) the Dancer should replicate it on itself
|
||||
globalScene.phaseManager.unshiftPhase(new MovePhase(dancer, [dancer.getBattlerIndex()], move, true, true));
|
||||
phaseManager.createAndUnshift("MovePhase", dancer, [dancer.getBattlerIndex()], move, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7293,13 +7294,13 @@ class ForceSwitchOutHelper {
|
||||
globalScene.clearEnemyHeldItemModifiers();
|
||||
|
||||
if (switchOutTarget.hp) {
|
||||
globalScene.phaseManager.pushPhase(new BattleEndPhase(false));
|
||||
globalScene.phaseManager.createAndPush("BattleEndPhase", false);
|
||||
|
||||
if (globalScene.gameMode.hasRandomBiomes || globalScene.isNewBiome()) {
|
||||
globalScene.phaseManager.pushPhase(new SelectBiomePhase());
|
||||
globalScene.phaseManager.createAndPush("SelectBiomePhase");
|
||||
}
|
||||
|
||||
globalScene.phaseManager.pushPhase(new NewBattlePhase());
|
||||
globalScene.phaseManager.createAndPush("NewBattlePhase");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1194,7 +1194,7 @@ export class EncoreTag extends MoveRestrictionBattlerTag {
|
||||
const lastMove = pokemon.getLastXMoves(1)[0];
|
||||
globalScene.phaseManager.tryReplacePhase(
|
||||
m => m.is("MovePhase") && m.pokemon === pokemon,
|
||||
globalScene.phaseManager.newPhase("MovePhase", pokemon, lastMove.targets ?? [], movesetMove),
|
||||
globalScene.phaseManager.createPhase("MovePhase", pokemon, lastMove.targets ?? [], movesetMove),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1890,8 +1890,8 @@ export class HealAttr extends MoveEffectAttr {
|
||||
* This heals the target and shows the appropriate message.
|
||||
*/
|
||||
addHealPhase(target: Pokemon, healRatio: number) {
|
||||
globalScene.phaseManager.unshiftPhase(new PokemonHealPhase(target.getBattlerIndex(),
|
||||
toDmgValue(target.getMaxHp() * healRatio), i18next.t("moveTriggers:healHp", { pokemonName: getPokemonNameWithAffix(target) }), true, !this.showAnim));
|
||||
globalScene.phaseManager.createAndUnshift("PokemonHealPhase", target.getBattlerIndex(),
|
||||
toDmgValue(target.getMaxHp() * healRatio), i18next.t("moveTriggers:healHp", { pokemonName: getPokemonNameWithAffix(target) }), true, !this.showAnim);
|
||||
}
|
||||
|
||||
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): number {
|
||||
@ -6351,13 +6351,13 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||
globalScene.clearEnemyHeldItemModifiers(switchOutTarget);
|
||||
|
||||
if (!allyPokemon?.isActive(true) && switchOutTarget.hp) {
|
||||
globalScene.phaseManager.pushPhase(new BattleEndPhase(false));
|
||||
globalScene.phaseManager.createAndPush("BattleEndPhase", false);
|
||||
|
||||
if (globalScene.gameMode.hasRandomBiomes || globalScene.isNewBiome()) {
|
||||
globalScene.phaseManager.pushPhase(new SelectBiomePhase());
|
||||
globalScene.phaseManager.createAndPush("SelectBiomePhase");
|
||||
}
|
||||
|
||||
globalScene.phaseManager.pushPhase(new NewBattlePhase());
|
||||
globalScene.phaseManager.createAndPush("NewBattlePhase");
|
||||
}
|
||||
}
|
||||
|
||||
@ -6733,8 +6733,8 @@ class CallMoveAttr extends OverrideMoveEffectAttr {
|
||||
? moveTargets.targets
|
||||
: [ this.hasTarget ? target.getBattlerIndex() : moveTargets.targets[user.randBattleSeedInt(moveTargets.targets.length)] ]; // account for Mirror Move having a target already
|
||||
user.getMoveQueue().push({ move: move.id, targets: targets, virtual: true, ignorePP: true });
|
||||
globalScene.phaseManager.unshiftPhase(new LoadMoveAnimPhase(move.id));
|
||||
globalScene.phaseManager.unshiftPhase(new MovePhase(user, targets, new PokemonMove(move.id, 0, 0, true), true, true));
|
||||
globalScene.phaseManager.createAndUnshift("LoadMoveAnimPhase", move.id);
|
||||
globalScene.phaseManager.createAndUnshift("MovePhase", user, targets, new PokemonMove(move.id, 0, 0, true), true, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -6962,8 +6962,8 @@ export class NaturePowerAttr extends OverrideMoveEffectAttr {
|
||||
}
|
||||
|
||||
user.getMoveQueue().push({ move: moveId, targets: [ target.getBattlerIndex() ], ignorePP: true });
|
||||
globalScene.phaseManager.unshiftPhase(new LoadMoveAnimPhase(moveId));
|
||||
globalScene.phaseManager.unshiftPhase(new MovePhase(user, [ target.getBattlerIndex() ], new PokemonMove(moveId, 0, 0, true), true));
|
||||
globalScene.phaseManager.createAndUnshift("LoadMoveAnimPhase", moveId);
|
||||
globalScene.phaseManager.createAndUnshift("MovePhase", user, [ target.getBattlerIndex() ], new PokemonMove(moveId, 0, 0, true), true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -7852,7 +7852,7 @@ export class AfterYouAttr extends MoveEffectAttr {
|
||||
//Will find next acting phase of the targeted pokémon, delete it and queue it next on successful delete.
|
||||
const nextAttackPhase = globalScene.phaseManager.findPhase<MovePhase>((phase) => phase.pokemon === target);
|
||||
if (nextAttackPhase && globalScene.phaseManager.tryRemovePhase((phase: MovePhase) => phase.pokemon === target)) {
|
||||
globalScene.phaseManager.prependToPhase(new MovePhase(target, [ ...nextAttackPhase.targets ], nextAttackPhase.move), "MovePhase");
|
||||
globalScene.phaseManager.createAndPrependToPhase("MovePhase", "MovePhase", target, [ ...nextAttackPhase.targets ], nextAttackPhase.move);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -7889,7 +7889,7 @@ export class ForceLastAttr extends MoveEffectAttr {
|
||||
globalScene.phaseManager.phaseQueue.splice(
|
||||
globalScene.phaseManager.phaseQueue.indexOf(prependPhase),
|
||||
0,
|
||||
new MovePhase(target, [ ...targetMovePhase.targets ], targetMovePhase.move, false, false, false, true)
|
||||
globalScene.phaseManager.createPhase("MovePhase", target, [ ...targetMovePhase.targets ], targetMovePhase.move, false, false, false, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -20,12 +20,7 @@ import {
|
||||
modifierTypes,
|
||||
regenerateModifierPoolThresholds,
|
||||
} from "#app/modifier/modifier-type";
|
||||
import {
|
||||
MysteryEncounterBattlePhase,
|
||||
MysteryEncounterBattleStartCleanupPhase,
|
||||
MysteryEncounterPhase,
|
||||
MysteryEncounterRewardsPhase,
|
||||
} from "#app/phases/mystery-encounter-phases";
|
||||
import { MysteryEncounterBattlePhase } from "#app/phases/mystery-encounter-phases";
|
||||
import type PokemonData from "#app/system/pokemon-data";
|
||||
import type { OptionSelectConfig, OptionSelectItem } from "#app/ui/abstact-option-select-ui-handler";
|
||||
import type { PartyOption, PokemonSelectFilter } from "#app/ui/party-ui-handler";
|
||||
@ -51,10 +46,6 @@ import type { IEggOptions } from "#app/data/egg";
|
||||
import { Egg } from "#app/data/egg";
|
||||
import type { CustomPokemonData } from "#app/data/custom-pokemon-data";
|
||||
import type HeldModifierConfig from "#app/@types/held-modifier-config";
|
||||
import { MovePhase } from "#app/phases/move-phase";
|
||||
import { EggLapsePhase } from "#app/phases/egg-lapse-phase";
|
||||
import { TrainerVictoryPhase } from "#app/phases/trainer-victory-phase";
|
||||
import { BattleEndPhase } from "#app/phases/battle-end-phase";
|
||||
import { GameOverPhase } from "#app/phases/game-over-phase";
|
||||
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
||||
import { PartyExpPhase } from "#app/phases/party-exp-phase";
|
||||
@ -829,7 +820,7 @@ export class OptionSelectSettings {
|
||||
* @param optionSelectSettings
|
||||
*/
|
||||
export function initSubsequentOptionSelect(optionSelectSettings: OptionSelectSettings) {
|
||||
globalScene.phaseManager.pushPhase(new MysteryEncounterPhase(optionSelectSettings));
|
||||
globalScene.phaseManager.createAndPush("MysteryEncounterPhase", optionSelectSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -869,8 +860,8 @@ export function handleMysteryEncounterVictory(addHealPhase = false, doNotContinu
|
||||
return;
|
||||
}
|
||||
if (encounter.encounterMode === MysteryEncounterMode.NO_BATTLE) {
|
||||
globalScene.phaseManager.pushPhase(new MysteryEncounterRewardsPhase(addHealPhase));
|
||||
globalScene.phaseManager.pushPhase(new EggLapsePhase());
|
||||
globalScene.phaseManager.createAndPush("MysteryEncounterRewardsPhase", addHealPhase);
|
||||
globalScene.phaseManager.createAndPush("EggLapsePhase");
|
||||
} else if (
|
||||
!globalScene
|
||||
.getEnemyParty()
|
||||
@ -878,15 +869,15 @@ export function handleMysteryEncounterVictory(addHealPhase = false, doNotContinu
|
||||
encounter.encounterMode !== MysteryEncounterMode.TRAINER_BATTLE ? p.isOnField() : !p?.isFainted(true),
|
||||
)
|
||||
) {
|
||||
globalScene.phaseManager.pushPhase(new BattleEndPhase(true));
|
||||
globalScene.phaseManager.createAndPush("BattleEndPhase", true);
|
||||
if (encounter.encounterMode === MysteryEncounterMode.TRAINER_BATTLE) {
|
||||
globalScene.phaseManager.pushPhase(new TrainerVictoryPhase());
|
||||
globalScene.phaseManager.createAndPush("TrainerVictoryPhase");
|
||||
}
|
||||
if (globalScene.gameMode.isEndless || !globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex)) {
|
||||
globalScene.phaseManager.pushPhase(new MysteryEncounterRewardsPhase(addHealPhase));
|
||||
globalScene.phaseManager.createAndPush("MysteryEncounterRewardsPhase", addHealPhase);
|
||||
if (!encounter.doContinueEncounter) {
|
||||
// Only lapse eggs once for multi-battle encounters
|
||||
globalScene.phaseManager.pushPhase(new EggLapsePhase());
|
||||
globalScene.phaseManager.createAndPush("EggLapsePhase");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -912,14 +903,14 @@ export function handleMysteryEncounterBattleFailed(addHealPhase = false, doNotCo
|
||||
return;
|
||||
}
|
||||
if (encounter.encounterMode !== MysteryEncounterMode.NO_BATTLE) {
|
||||
globalScene.phaseManager.pushPhase(new BattleEndPhase(false));
|
||||
globalScene.phaseManager.createAndPush("BattleEndPhase", false);
|
||||
}
|
||||
|
||||
globalScene.phaseManager.pushPhase(new MysteryEncounterRewardsPhase(addHealPhase));
|
||||
globalScene.phaseManager.createAndPush("MysteryEncounterRewardsPhase", addHealPhase);
|
||||
|
||||
if (!encounter.doContinueEncounter) {
|
||||
// Only lapse eggs once for multi-battle encounters
|
||||
globalScene.phaseManager.pushPhase(new EggLapsePhase());
|
||||
globalScene.phaseManager.createAndPush("EggLapsePhase");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1004,14 +995,19 @@ export function handleMysteryEncounterBattleStartEffects() {
|
||||
} else {
|
||||
source = globalScene.getEnemyField()[0];
|
||||
}
|
||||
globalScene.phaseManager.pushPhase(
|
||||
// @ts-ignore: source cannot be undefined
|
||||
new MovePhase(source, effect.targets, effect.move, effect.followUp, effect.ignorePp),
|
||||
globalScene.phaseManager.createAndPush(
|
||||
"MovePhase",
|
||||
// @ts-expect-error: source is guaranteed to be defined
|
||||
source,
|
||||
effect.targets,
|
||||
effect.move,
|
||||
effect.followUp,
|
||||
effect.ignorePp,
|
||||
);
|
||||
});
|
||||
|
||||
// Pseudo turn end phase to reset flinch states, Endure, etc.
|
||||
globalScene.phaseManager.pushPhase(new MysteryEncounterBattleStartCleanupPhase());
|
||||
globalScene.phaseManager.createAndPush("MysteryEncounterBattleStartCleanupPhase");
|
||||
|
||||
encounter.startOfBattleEffectsComplete = true;
|
||||
}
|
||||
|
@ -518,7 +518,7 @@ export class PhaseManager {
|
||||
* @param args - The arguments to pass to the phase constructor.
|
||||
* @returns The requested phase instance
|
||||
*/
|
||||
public newPhase<T extends PhaseString>(
|
||||
public createPhase<T extends PhaseString>(
|
||||
phase: T,
|
||||
...args: ConstructorParameters<PhaseConstructorMap[T]>
|
||||
): PhaseMap[T] {
|
||||
@ -531,4 +531,55 @@ export class PhaseManager {
|
||||
// @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new phase and immediately push it to the phase queue. Equivalent to calling {@linkcode createPhase} followed by {@linkcode pushPhase}.
|
||||
* @param phase - The name of the phase to create
|
||||
* @param args - The arguments to pass to the phase constructor
|
||||
*/
|
||||
public createAndPush<T extends PhaseString>(phase: T, ...args: ConstructorParameters<PhaseConstructorMap[T]>): void {
|
||||
this.pushPhase(this.createPhase(phase, ...args));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new phase and immediately unshift it to the phase queue. Equivalent to calling {@linkcode createPhase} followed by {@linkcode unshiftPhase}.
|
||||
* @param phase - The name of the phase to create
|
||||
* @param args - The arguments to pass to the phase constructor
|
||||
*/
|
||||
public createAndUnshift<T extends PhaseString>(
|
||||
phase: T,
|
||||
...args: ConstructorParameters<PhaseConstructorMap[T]>
|
||||
): void {
|
||||
this.unshiftPhase(this.createPhase(phase, ...args));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new phase and immediately prepend it to the phase queue. Equivalent to calling {@linkcode createPhase} followed by {@linkcode prependToPhase}.
|
||||
* @param targetPhase - The phase to search for in phaseQueue
|
||||
* @param phase - The name of the phase to create
|
||||
* @param args - The arguments to pass to the phase constructor
|
||||
* @returns `true` if a `targetPhase` was found to prepend to
|
||||
*/
|
||||
public createAndPrependToPhase<T extends PhaseString>(
|
||||
targetPhase: PhaseString,
|
||||
phase: T,
|
||||
...args: ConstructorParameters<PhaseConstructorMap[T]>
|
||||
): boolean {
|
||||
return this.prependToPhase(this.createPhase(phase, ...args), targetPhase);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new phase and immediately append it to the phase queue. Equivalent to calling {@linkcode createPhase} followed by {@linkcode appendToPhase}.
|
||||
* @param targetPhase - The phase to search for in phaseQueue
|
||||
* @param phase - The name of the phase to create
|
||||
* @param args - The arguments to pass to the phase constructor
|
||||
* @returns `true` if a `targetPhase` was found to append to
|
||||
*/
|
||||
public createAndAppendToPhase<T extends PhaseString>(
|
||||
targetPhase: PhaseString,
|
||||
phase: T,
|
||||
...args: ConstructorParameters<PhaseConstructorMap[T]>
|
||||
): boolean {
|
||||
return this.appendToPhase(this.createPhase(phase, ...args), targetPhase);
|
||||
}
|
||||
}
|
||||
|
@ -10,11 +10,8 @@ import type { PlayerPokemon, EnemyPokemon } from "#app/field/pokemon";
|
||||
import type Pokemon from "#app/field/pokemon";
|
||||
import i18next from "i18next";
|
||||
import { NumberHolder } from "#app/utils/common";
|
||||
import { BattleEndPhase } from "./battle-end-phase";
|
||||
import { NewBattlePhase } from "./new-battle-phase";
|
||||
import { PokemonPhase } from "./pokemon-phase";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
import { SelectBiomePhase } from "./select-biome-phase";
|
||||
|
||||
export class AttemptRunPhase extends PokemonPhase {
|
||||
public readonly phaseName = "AttemptRunPhase";
|
||||
@ -60,13 +57,13 @@ export class AttemptRunPhase extends PokemonPhase {
|
||||
enemyPokemon.trySetStatus(StatusEffect.FAINT);
|
||||
});
|
||||
|
||||
globalScene.phaseManager.pushPhase(new BattleEndPhase(false));
|
||||
globalScene.phaseManager.createAndPush("BattleEndPhase", false);
|
||||
|
||||
if (globalScene.gameMode.hasRandomBiomes || globalScene.isNewBiome()) {
|
||||
globalScene.phaseManager.pushPhase(new SelectBiomePhase());
|
||||
globalScene.phaseManager.createAndPush("SelectBiomePhase");
|
||||
}
|
||||
|
||||
globalScene.phaseManager.pushPhase(new NewBattlePhase());
|
||||
globalScene.phaseManager.createAndPush("NewBattlePhase");
|
||||
} else {
|
||||
playerPokemon.turnData.failedRunAway = true;
|
||||
globalScene.phaseManager.queueMessage(i18next.t("battle:runAwayCannotEscape"), null, true, 500);
|
||||
|
@ -27,11 +27,9 @@ import { CheckSwitchPhase } from "#app/phases/check-switch-phase";
|
||||
import { GameOverPhase } from "#app/phases/game-over-phase";
|
||||
import { MysteryEncounterPhase } from "#app/phases/mystery-encounter-phases";
|
||||
import { PostSummonPhase } from "#app/phases/post-summon-phase";
|
||||
import { ReturnPhase } from "#app/phases/return-phase";
|
||||
import { ScanIvsPhase } from "#app/phases/scan-ivs-phase";
|
||||
import { ShinySparklePhase } from "#app/phases/shiny-sparkle-phase";
|
||||
import { SummonPhase } from "#app/phases/summon-phase";
|
||||
import { ToggleDoublePositionPhase } from "#app/phases/toggle-double-position-phase";
|
||||
import { achvs } from "#app/system/achv";
|
||||
import { handleTutorial, Tutorial } from "#app/tutorial";
|
||||
import { UiMode } from "#enums/ui-mode";
|
||||
@ -602,21 +600,21 @@ export class EncounterPhase extends BattlePhase {
|
||||
const availablePartyMembers = globalScene.getPokemonAllowedInBattle();
|
||||
|
||||
if (!availablePartyMembers[0].isOnField()) {
|
||||
globalScene.phaseManager.pushPhase(new SummonPhase(0));
|
||||
globalScene.phaseManager.createAndPush("SummonPhase", 0);
|
||||
}
|
||||
|
||||
if (globalScene.currentBattle.double) {
|
||||
if (availablePartyMembers.length > 1) {
|
||||
globalScene.phaseManager.pushPhase(new ToggleDoublePositionPhase(true));
|
||||
globalScene.phaseManager.createAndPush("ToggleDoublePositionPhase", true);
|
||||
if (!availablePartyMembers[1].isOnField()) {
|
||||
globalScene.phaseManager.pushPhase(new SummonPhase(1));
|
||||
globalScene.phaseManager.createAndPush("SummonPhase", 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (availablePartyMembers.length > 1 && availablePartyMembers[1].isOnField()) {
|
||||
globalScene.phaseManager.pushPhase(new ReturnPhase(1));
|
||||
globalScene.phaseManager.createAndPush("ReturnPhase", 1);
|
||||
}
|
||||
globalScene.phaseManager.pushPhase(new ToggleDoublePositionPhase(false));
|
||||
globalScene.phaseManager.createAndPush("ToggleDoublePositionPhase", false);
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -10,12 +10,9 @@ import type Pokemon from "#app/field/pokemon";
|
||||
import { modifierTypes } from "#app/modifier/modifier-type";
|
||||
import { BattlePhase } from "#app/phases/battle-phase";
|
||||
import { CheckSwitchPhase } from "#app/phases/check-switch-phase";
|
||||
import { EncounterPhase } from "#app/phases/encounter-phase";
|
||||
import { EndCardPhase } from "#app/phases/end-card-phase";
|
||||
import { GameOverModifierRewardPhase } from "#app/phases/game-over-modifier-reward-phase";
|
||||
import { PostGameOverPhase } from "#app/phases/post-game-over-phase";
|
||||
import { RibbonModifierRewardPhase } from "#app/phases/ribbon-modifier-reward-phase";
|
||||
import { SummonPhase } from "#app/phases/summon-phase";
|
||||
import { UnlockPhase } from "#app/phases/unlock-phase";
|
||||
import { achvs, ChallengeAchv } from "#app/system/achv";
|
||||
import { Unlockables } from "#app/system/unlockables";
|
||||
@ -86,13 +83,13 @@ export class GameOverPhase extends BattlePhase {
|
||||
globalScene.reset();
|
||||
globalScene.phaseManager.clearPhaseQueue();
|
||||
globalScene.gameData.loadSession(globalScene.sessionSlotId).then(() => {
|
||||
globalScene.phaseManager.pushPhase(new EncounterPhase(true));
|
||||
globalScene.phaseManager.createAndPush("EncounterPhase", true);
|
||||
|
||||
const availablePartyMembers = globalScene.getPokemonAllowedInBattle().length;
|
||||
|
||||
globalScene.phaseManager.pushPhase(new SummonPhase(0));
|
||||
globalScene.phaseManager.createAndPush("SummonPhase", 0);
|
||||
if (globalScene.currentBattle.double && availablePartyMembers > 1) {
|
||||
globalScene.phaseManager.pushPhase(new SummonPhase(1));
|
||||
globalScene.phaseManager.createAndPush("SummonPhase", 1);
|
||||
}
|
||||
if (
|
||||
globalScene.currentBattle.waveIndex > 1 &&
|
||||
@ -170,7 +167,7 @@ export class GameOverPhase extends BattlePhase {
|
||||
}
|
||||
this.getRunHistoryEntry().then(runHistoryEntry => {
|
||||
globalScene.gameData.saveRunHistory(runHistoryEntry, this.isVictory);
|
||||
globalScene.phaseManager.pushPhase(new PostGameOverPhase(endCardPhase));
|
||||
globalScene.phaseManager.createAndPush("PostGameOverPhase", endCardPhase);
|
||||
this.end();
|
||||
});
|
||||
};
|
||||
|
@ -6,7 +6,6 @@ import type { PokemonMove } from "#app/field/pokemon";
|
||||
import type Pokemon from "#app/field/pokemon";
|
||||
import { MoveResult } from "#app/field/pokemon";
|
||||
import { BooleanHolder } from "#app/utils/common";
|
||||
import { MovePhase } from "#app/phases/move-phase";
|
||||
import { PokemonPhase } from "#app/phases/pokemon-phase";
|
||||
import { BattlerTagType } from "#enums/battler-tag-type";
|
||||
|
||||
@ -64,7 +63,7 @@ export class MoveChargePhase extends PokemonPhase {
|
||||
// this MoveEndPhase will be duplicated by the queued MovePhase if not removed
|
||||
globalScene.phaseManager.tryRemovePhase(phase => phase.is("MoveEndPhase") && phase.getPokemon() === user);
|
||||
// queue a new MovePhase for this move's attack phase
|
||||
globalScene.phaseManager.unshiftPhase(new MovePhase(user, [this.targetIndex], this.move, false));
|
||||
globalScene.phaseManager.createAndUnshift("MovePhase", user, [this.targetIndex], this.move, false);
|
||||
} else {
|
||||
user.getMoveQueue().push({ move: move.id, targets: [this.targetIndex] });
|
||||
}
|
||||
|
@ -69,7 +69,6 @@ import { MoveId } from "#enums/move-id";
|
||||
import i18next from "i18next";
|
||||
import type { Phase } from "#app/phase";
|
||||
import { ShowAbilityPhase } from "./show-ability-phase";
|
||||
import { MovePhase } from "./move-phase";
|
||||
import { HideAbilityPhase } from "#app/phases/hide-ability-phase";
|
||||
import type { TypeDamageMultiplier } from "#app/data/type";
|
||||
import { HitCheckResult } from "#enums/hit-check-result";
|
||||
@ -196,7 +195,15 @@ export class MoveEffectPhase extends PokemonPhase {
|
||||
}
|
||||
|
||||
this.queuedPhases.push(
|
||||
new MovePhase(target, newTargets, new PokemonMove(this.move.id, 0, 0, true), true, true, true),
|
||||
globalScene.phaseManager.createPhase(
|
||||
"MovePhase",
|
||||
target,
|
||||
newTargets,
|
||||
new PokemonMove(this.move.id, 0, 0, true),
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,6 @@ import { SeenEncounterData } from "#app/data/mystery-encounters/mystery-encounte
|
||||
import { getEncounterText } from "#app/data/mystery-encounters/utils/encounter-dialogue-utils";
|
||||
import { CheckSwitchPhase } from "#app/phases/check-switch-phase";
|
||||
import { GameOverPhase } from "#app/phases/game-over-phase";
|
||||
import { NewBattlePhase } from "#app/phases/new-battle-phase";
|
||||
import { ReturnPhase } from "#app/phases/return-phase";
|
||||
import { ScanIvsPhase } from "#app/phases/scan-ivs-phase";
|
||||
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
|
||||
import { SummonPhase } from "#app/phases/summon-phase";
|
||||
@ -26,7 +24,6 @@ import { IvScannerModifier } from "../modifier/modifier";
|
||||
import { Phase } from "../phase";
|
||||
import { UiMode } from "#enums/ui-mode";
|
||||
import { isNullOrUndefined, randSeedItem } from "#app/utils/common";
|
||||
import { SelectBiomePhase } from "./select-biome-phase";
|
||||
|
||||
/**
|
||||
* Will handle (in order):
|
||||
@ -124,7 +121,7 @@ export class MysteryEncounterPhase extends Phase {
|
||||
*/
|
||||
continueEncounter() {
|
||||
const endDialogueAndContinueEncounter = () => {
|
||||
globalScene.phaseManager.pushPhase(new MysteryEncounterOptionSelectedPhase());
|
||||
globalScene.phaseManager.createAndPush("MysteryEncounterOptionSelectedPhase");
|
||||
this.end();
|
||||
};
|
||||
|
||||
@ -433,22 +430,22 @@ export class MysteryEncounterBattlePhase extends Phase {
|
||||
const availablePartyMembers = globalScene.getPlayerParty().filter(p => p.isAllowedInBattle());
|
||||
|
||||
if (!availablePartyMembers[0].isOnField()) {
|
||||
globalScene.phaseManager.pushPhase(new SummonPhase(0));
|
||||
globalScene.phaseManager.createAndPush("SummonPhase", 0);
|
||||
}
|
||||
|
||||
if (globalScene.currentBattle.double) {
|
||||
if (availablePartyMembers.length > 1) {
|
||||
globalScene.phaseManager.pushPhase(new ToggleDoublePositionPhase(true));
|
||||
globalScene.phaseManager.createAndPush("ToggleDoublePositionPhase", true);
|
||||
if (!availablePartyMembers[1].isOnField()) {
|
||||
globalScene.phaseManager.pushPhase(new SummonPhase(1));
|
||||
globalScene.phaseManager.createAndPush("SummonPhase", 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (availablePartyMembers.length > 1 && availablePartyMembers[1].isOnField()) {
|
||||
globalScene.getPlayerField().forEach(pokemon => pokemon.lapseTag(BattlerTagType.COMMANDED));
|
||||
globalScene.phaseManager.pushPhase(new ReturnPhase(1));
|
||||
globalScene.phaseManager.createAndPush("ReturnPhase", 1);
|
||||
}
|
||||
globalScene.phaseManager.pushPhase(new ToggleDoublePositionPhase(false));
|
||||
globalScene.phaseManager.createAndPush("ToggleDoublePositionPhase", false);
|
||||
}
|
||||
|
||||
if (encounterMode !== MysteryEncounterMode.TRAINER_BATTLE && !this.disableSwitch) {
|
||||
@ -571,7 +568,7 @@ export class MysteryEncounterRewardsPhase extends Phase {
|
||||
);
|
||||
}
|
||||
|
||||
globalScene.phaseManager.pushPhase(new PostMysteryEncounterPhase());
|
||||
globalScene.phaseManager.createAndPush("PostMysteryEncounterPhase");
|
||||
this.end();
|
||||
}
|
||||
}
|
||||
@ -618,10 +615,10 @@ export class PostMysteryEncounterPhase extends Phase {
|
||||
continueEncounter() {
|
||||
const endPhase = () => {
|
||||
if (globalScene.gameMode.hasRandomBiomes || globalScene.isNewBiome()) {
|
||||
globalScene.phaseManager.pushPhase(new SelectBiomePhase());
|
||||
globalScene.phaseManager.createAndPush("SelectBiomePhase");
|
||||
}
|
||||
|
||||
globalScene.phaseManager.pushPhase(new NewBattlePhase());
|
||||
globalScene.phaseManager.createAndPush("NewBattlePhase");
|
||||
this.end();
|
||||
};
|
||||
|
||||
|
@ -6,7 +6,6 @@ import { getPokemonSpecies } from "#app/data/pokemon-species";
|
||||
import { overrideHeldItems, overrideModifiers } from "#app/modifier/modifier";
|
||||
import Overrides from "#app/overrides";
|
||||
import { Phase } from "#app/phase";
|
||||
import { TitlePhase } from "#app/phases/title-phase";
|
||||
import { SaveSlotUiMode } from "#app/ui/save-slot-select-ui-handler";
|
||||
import type { Starter } from "#app/ui/starter-select-ui-handler";
|
||||
import { UiMode } from "#enums/ui-mode";
|
||||
@ -26,7 +25,7 @@ export class SelectStarterPhase extends Phase {
|
||||
globalScene.ui.setMode(UiMode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => {
|
||||
if (slotId === -1) {
|
||||
globalScene.phaseManager.clearPhaseQueue();
|
||||
globalScene.phaseManager.pushPhase(new TitlePhase());
|
||||
globalScene.phaseManager.createAndPush("TitlePhase");
|
||||
return this.end();
|
||||
}
|
||||
globalScene.sessionSlotId = slotId;
|
||||
|
@ -22,8 +22,6 @@ import { isLocal, isLocalServerConnected, isNullOrUndefined } from "#app/utils/c
|
||||
import i18next from "i18next";
|
||||
import { CheckSwitchPhase } from "./check-switch-phase";
|
||||
import { EncounterPhase } from "./encounter-phase";
|
||||
import { SelectChallengePhase } from "./select-challenge-phase";
|
||||
import { SelectStarterPhase } from "./select-starter-phase";
|
||||
import { SummonPhase } from "./summon-phase";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
import Overrides from "#app/overrides";
|
||||
@ -125,7 +123,7 @@ export class TitlePhase extends Phase {
|
||||
label: i18next.t("menu:cancel"),
|
||||
handler: () => {
|
||||
globalScene.phaseManager.clearPhaseQueue();
|
||||
globalScene.phaseManager.pushPhase(new TitlePhase());
|
||||
globalScene.phaseManager.createAndPush("TitlePhase");
|
||||
super.end();
|
||||
return true;
|
||||
},
|
||||
@ -200,7 +198,7 @@ export class TitlePhase extends Phase {
|
||||
globalScene.ui.setMode(UiMode.SAVE_SLOT, SaveSlotUiMode.SAVE, (slotId: number) => {
|
||||
globalScene.phaseManager.clearPhaseQueue();
|
||||
if (slotId === -1) {
|
||||
globalScene.phaseManager.pushPhase(new TitlePhase());
|
||||
globalScene.phaseManager.createAndPush("TitlePhase");
|
||||
return super.end();
|
||||
}
|
||||
globalScene.sessionSlotId = slotId;
|
||||
@ -304,9 +302,9 @@ export class TitlePhase extends Phase {
|
||||
globalScene.arena.preloadBgm();
|
||||
globalScene.gameMode = getGameMode(this.gameMode);
|
||||
if (this.gameMode === GameModes.CHALLENGE) {
|
||||
globalScene.phaseManager.pushPhase(new SelectChallengePhase());
|
||||
globalScene.phaseManager.createAndPush("SelectChallengePhase");
|
||||
} else {
|
||||
globalScene.phaseManager.pushPhase(new SelectStarterPhase());
|
||||
globalScene.phaseManager.createAndPush("SelectStarterPhase");
|
||||
}
|
||||
globalScene.newArena(globalScene.gameMode.getStartingBiome());
|
||||
} else {
|
||||
|
@ -11,7 +11,6 @@ import { EnemyCommandPhase } from "./enemy-command-phase";
|
||||
import { FieldPhase } from "./field-phase";
|
||||
import { GameOverPhase } from "./game-over-phase";
|
||||
import { ToggleDoublePositionPhase } from "./toggle-double-position-phase";
|
||||
import { TurnStartPhase } from "./turn-start-phase";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
|
||||
export class TurnInitPhase extends FieldPhase {
|
||||
@ -75,7 +74,7 @@ export class TurnInitPhase extends FieldPhase {
|
||||
}
|
||||
});
|
||||
|
||||
globalScene.phaseManager.pushPhase(new TurnStartPhase());
|
||||
globalScene.phaseManager.createAndPush("TurnStartPhase");
|
||||
|
||||
this.end();
|
||||
}
|
||||
|
@ -8,21 +8,14 @@ import { PokemonMove } from "#app/field/pokemon";
|
||||
import { BypassSpeedChanceModifier } from "#app/modifier/modifier";
|
||||
import { Command } from "#app/ui/command-ui-handler";
|
||||
import { randSeedShuffle, BooleanHolder } from "#app/utils/common";
|
||||
import { AttemptCapturePhase } from "./attempt-capture-phase";
|
||||
import { AttemptRunPhase } from "./attempt-run-phase";
|
||||
import { BerryPhase } from "./berry-phase";
|
||||
import { FieldPhase } from "./field-phase";
|
||||
import { MoveHeaderPhase } from "./move-header-phase";
|
||||
import { MovePhase } from "./move-phase";
|
||||
import { SwitchSummonPhase } from "./switch-summon-phase";
|
||||
import { TurnEndPhase } from "./turn-end-phase";
|
||||
import { WeatherEffectPhase } from "./weather-effect-phase";
|
||||
import { CheckStatusEffectPhase } from "#app/phases/check-status-effect-phase";
|
||||
import { BattlerIndex } from "#app/battle";
|
||||
import { TrickRoomTag } from "#app/data/arena-tag";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
import { TeraPhase } from "./tera-phase";
|
||||
|
||||
export class TurnStartPhase extends FieldPhase {
|
||||
public readonly phaseName = "TurnStartPhase";
|
||||
@ -153,10 +146,12 @@ export class TurnStartPhase extends FieldPhase {
|
||||
|
||||
switch (preTurnCommand?.command) {
|
||||
case Command.TERA:
|
||||
globalScene.phaseManager.pushPhase(new TeraPhase(pokemon));
|
||||
globalScene.phaseManager.createAndPush("TeraPhase", pokemon);
|
||||
}
|
||||
}
|
||||
|
||||
const phaseManager = globalScene.phaseManager;
|
||||
|
||||
for (const o of moveOrder) {
|
||||
const pokemon = field[o];
|
||||
const turnCommand = globalScene.currentBattle.turnCommands[o];
|
||||
@ -167,88 +162,94 @@ export class TurnStartPhase extends FieldPhase {
|
||||
|
||||
switch (turnCommand?.command) {
|
||||
case Command.FIGHT:
|
||||
const queuedMove = turnCommand.move;
|
||||
pokemon.turnData.order = orderIndex++;
|
||||
if (!queuedMove) {
|
||||
continue;
|
||||
}
|
||||
const move =
|
||||
pokemon.getMoveset().find(m => m.moveId === queuedMove.move && m.ppUsed < m.getMovePp()) ||
|
||||
new PokemonMove(queuedMove.move);
|
||||
if (move.getMove().hasAttr(MoveHeaderAttr)) {
|
||||
globalScene.phaseManager.unshiftPhase(new MoveHeaderPhase(pokemon, move));
|
||||
}
|
||||
if (pokemon.isPlayer()) {
|
||||
if (turnCommand.cursor === -1) {
|
||||
globalScene.phaseManager.pushPhase(
|
||||
new MovePhase(pokemon, turnCommand.targets || turnCommand.move!.targets, move),
|
||||
); //TODO: is the bang correct here?
|
||||
} else {
|
||||
const playerPhase = new MovePhase(
|
||||
pokemon,
|
||||
turnCommand.targets || turnCommand.move!.targets,
|
||||
move,
|
||||
false,
|
||||
queuedMove.ignorePP,
|
||||
); //TODO: is the bang correct here?
|
||||
globalScene.phaseManager.pushPhase(playerPhase);
|
||||
{
|
||||
const queuedMove = turnCommand.move;
|
||||
pokemon.turnData.order = orderIndex++;
|
||||
if (!queuedMove) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
globalScene.phaseManager.pushPhase(
|
||||
new MovePhase(
|
||||
const move =
|
||||
pokemon.getMoveset().find(m => m.moveId === queuedMove.move && m.ppUsed < m.getMovePp()) ||
|
||||
new PokemonMove(queuedMove.move);
|
||||
if (move.getMove().hasAttr(MoveHeaderAttr)) {
|
||||
phaseManager.unshiftPhase(new MoveHeaderPhase(pokemon, move));
|
||||
}
|
||||
if (pokemon.isPlayer()) {
|
||||
if (turnCommand.cursor === -1) {
|
||||
phaseManager.createAndPush(
|
||||
"MovePhase",
|
||||
pokemon,
|
||||
turnCommand.targets || turnCommand.move!.targets,
|
||||
move,
|
||||
);
|
||||
} else {
|
||||
phaseManager.createAndPush(
|
||||
"MovePhase",
|
||||
pokemon,
|
||||
turnCommand.targets || turnCommand.move!.targets, // TODO: is the bang correct here?
|
||||
move,
|
||||
false,
|
||||
queuedMove.ignorePP,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
phaseManager.createAndPush(
|
||||
"MovePhase",
|
||||
pokemon,
|
||||
turnCommand.targets || turnCommand.move!.targets,
|
||||
move,
|
||||
false,
|
||||
queuedMove.ignorePP,
|
||||
),
|
||||
); //TODO: is the bang correct here?
|
||||
);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Command.BALL:
|
||||
globalScene.phaseManager.unshiftPhase(
|
||||
new AttemptCapturePhase(turnCommand.targets![0] % 2, turnCommand.cursor!),
|
||||
); //TODO: is the bang correct here?
|
||||
phaseManager.createAndUnshift("AttemptCapturePhase", turnCommand.targets![0] % 2, turnCommand.cursor!); //TODO: is the bang correct here?
|
||||
break;
|
||||
case Command.POKEMON:
|
||||
const switchType = turnCommand.args?.[0] ? SwitchType.BATON_PASS : SwitchType.SWITCH;
|
||||
globalScene.phaseManager.unshiftPhase(
|
||||
new SwitchSummonPhase(switchType, pokemon.getFieldIndex(), turnCommand.cursor!, true, pokemon.isPlayer()),
|
||||
);
|
||||
{
|
||||
const switchType = turnCommand.args?.[0] ? SwitchType.BATON_PASS : SwitchType.SWITCH;
|
||||
phaseManager.unshiftPhase(
|
||||
new SwitchSummonPhase(switchType, pokemon.getFieldIndex(), turnCommand.cursor!, true, pokemon.isPlayer()),
|
||||
);
|
||||
}
|
||||
break;
|
||||
case Command.RUN:
|
||||
let runningPokemon = pokemon;
|
||||
if (globalScene.currentBattle.double) {
|
||||
const playerActivePokemon = field.filter(pokemon => {
|
||||
if (pokemon) {
|
||||
return pokemon.isPlayer() && pokemon.isActive();
|
||||
{
|
||||
let runningPokemon = pokemon;
|
||||
if (globalScene.currentBattle.double) {
|
||||
const playerActivePokemon = field.filter(pokemon => {
|
||||
if (pokemon) {
|
||||
return pokemon.isPlayer() && pokemon.isActive();
|
||||
}
|
||||
return;
|
||||
});
|
||||
// if only one pokemon is alive, use that one
|
||||
if (playerActivePokemon.length > 1) {
|
||||
// find which active pokemon has faster speed
|
||||
const fasterPokemon =
|
||||
playerActivePokemon[0].getStat(Stat.SPD) > playerActivePokemon[1].getStat(Stat.SPD)
|
||||
? playerActivePokemon[0]
|
||||
: playerActivePokemon[1];
|
||||
// check if either active pokemon has the ability "Run Away"
|
||||
const hasRunAway = playerActivePokemon.find(p => p.hasAbility(AbilityId.RUN_AWAY));
|
||||
runningPokemon = hasRunAway !== undefined ? hasRunAway : fasterPokemon;
|
||||
}
|
||||
return;
|
||||
});
|
||||
// if only one pokemon is alive, use that one
|
||||
if (playerActivePokemon.length > 1) {
|
||||
// find which active pokemon has faster speed
|
||||
const fasterPokemon =
|
||||
playerActivePokemon[0].getStat(Stat.SPD) > playerActivePokemon[1].getStat(Stat.SPD)
|
||||
? playerActivePokemon[0]
|
||||
: playerActivePokemon[1];
|
||||
// check if either active pokemon has the ability "Run Away"
|
||||
const hasRunAway = playerActivePokemon.find(p => p.hasAbility(AbilityId.RUN_AWAY));
|
||||
runningPokemon = hasRunAway !== undefined ? hasRunAway : fasterPokemon;
|
||||
}
|
||||
phaseManager.createAndUnshift("AttemptRunPhase", runningPokemon.getFieldIndex());
|
||||
}
|
||||
globalScene.phaseManager.unshiftPhase(new AttemptRunPhase(runningPokemon.getFieldIndex()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
globalScene.phaseManager.pushPhase(new WeatherEffectPhase());
|
||||
globalScene.phaseManager.pushPhase(new BerryPhase());
|
||||
phaseManager.createAndPush("WeatherEffectPhase");
|
||||
phaseManager.createAndPush("BerryPhase");
|
||||
|
||||
/** Add a new phase to check who should be taking status damage */
|
||||
globalScene.phaseManager.pushPhase(new CheckStatusEffectPhase(moveOrder));
|
||||
phaseManager.pushPhase(new CheckStatusEffectPhase(moveOrder));
|
||||
|
||||
globalScene.phaseManager.pushPhase(new TurnEndPhase());
|
||||
phaseManager.createAndPush("TurnEndPhase");
|
||||
|
||||
/**
|
||||
* this.end() will call shiftPhase(), which dumps everything from PrependQueue (aka everything that is unshifted()) to the front
|
||||
|
@ -3,19 +3,12 @@ import { ClassicFixedBossWaves } from "#enums/fixed-boss-waves";
|
||||
import { BattleType } from "#enums/battle-type";
|
||||
import type { CustomModifierSettings } from "#app/modifier/modifier-type";
|
||||
import { modifierTypes } from "#app/modifier/modifier-type";
|
||||
import { BattleEndPhase } from "./battle-end-phase";
|
||||
import { NewBattlePhase } from "./new-battle-phase";
|
||||
import { PokemonPhase } from "./pokemon-phase";
|
||||
import { AddEnemyBuffModifierPhase } from "./add-enemy-buff-modifier-phase";
|
||||
import { EggLapsePhase } from "./egg-lapse-phase";
|
||||
import { GameOverPhase } from "./game-over-phase";
|
||||
import { ModifierRewardPhase } from "./modifier-reward-phase";
|
||||
import { SelectModifierPhase } from "./select-modifier-phase";
|
||||
import { TrainerVictoryPhase } from "./trainer-victory-phase";
|
||||
import { handleMysteryEncounterVictory } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
import { timedEventManager } from "#app/global-event-manager";
|
||||
import { SelectBiomePhase } from "./select-biome-phase";
|
||||
|
||||
export class VictoryPhase extends PokemonPhase {
|
||||
public readonly phaseName = "VictoryPhase";
|
||||
@ -51,12 +44,12 @@ export class VictoryPhase extends PokemonPhase {
|
||||
.getEnemyParty()
|
||||
.find(p => (globalScene.currentBattle.battleType === BattleType.WILD ? p.isOnField() : !p?.isFainted(true)))
|
||||
) {
|
||||
globalScene.phaseManager.pushPhase(new BattleEndPhase(true));
|
||||
globalScene.phaseManager.createAndPush("BattleEndPhase", true);
|
||||
if (globalScene.currentBattle.battleType === BattleType.TRAINER) {
|
||||
globalScene.phaseManager.pushPhase(new TrainerVictoryPhase());
|
||||
globalScene.phaseManager.createAndPush("TrainerVictoryPhase");
|
||||
}
|
||||
if (globalScene.gameMode.isEndless || !globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex)) {
|
||||
globalScene.phaseManager.pushPhase(new EggLapsePhase());
|
||||
globalScene.phaseManager.createAndPush("EggLapsePhase");
|
||||
if (globalScene.gameMode.isClassic) {
|
||||
switch (globalScene.currentBattle.waveIndex) {
|
||||
case ClassicFixedBossWaves.RIVAL_1:
|
||||
@ -112,20 +105,20 @@ export class VictoryPhase extends PokemonPhase {
|
||||
: modifierTypes.VOUCHER_PLUS,
|
||||
),
|
||||
);
|
||||
globalScene.phaseManager.pushPhase(new AddEnemyBuffModifierPhase());
|
||||
globalScene.phaseManager.createAndPush("AddEnemyBuffModifierPhase");
|
||||
}
|
||||
}
|
||||
|
||||
if (globalScene.gameMode.hasRandomBiomes || globalScene.isNewBiome()) {
|
||||
globalScene.phaseManager.pushPhase(new SelectBiomePhase());
|
||||
globalScene.phaseManager.createAndPush("SelectBiomePhase");
|
||||
}
|
||||
|
||||
globalScene.phaseManager.pushPhase(new NewBattlePhase());
|
||||
globalScene.phaseManager.createAndPush("NewBattlePhase");
|
||||
} else {
|
||||
globalScene.currentBattle.battleType = BattleType.CLEAR;
|
||||
globalScene.score += globalScene.gameMode.getClearScoreBonus();
|
||||
globalScene.updateScoreText();
|
||||
globalScene.phaseManager.pushPhase(new GameOverPhase(true));
|
||||
globalScene.phaseManager.createAndPush("GameOverPhase", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import { Challenges } from "#app/enums/challenges";
|
||||
import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
|
||||
import { Color, ShadowColor } from "#app/enums/color";
|
||||
import { SelectStarterPhase } from "#app/phases/select-starter-phase";
|
||||
import { TitlePhase } from "#app/phases/title-phase";
|
||||
import { globalScene } from "#app/global-scene";
|
||||
|
||||
/**
|
||||
@ -384,7 +383,7 @@ export default class GameChallengesUiHandler extends UiHandler {
|
||||
this.updateChallengeArrows(this.startCursor.visible);
|
||||
} else {
|
||||
globalScene.phaseManager.clearPhaseQueue();
|
||||
globalScene.phaseManager.pushPhase(new TitlePhase());
|
||||
globalScene.phaseManager.createAndPush("TitlePhase");
|
||||
globalScene.phaseManager.getCurrentPhase()?.end();
|
||||
}
|
||||
success = true;
|
||||
|
@ -51,9 +51,6 @@ import { StarterContainer } from "#app/ui/starter-container";
|
||||
import { FilterBar } from "#app/ui/filter-bar";
|
||||
import { DropDownColumn } from "#enums/drop-down-column";
|
||||
import { ScrollBar } from "#app/ui/scroll-bar";
|
||||
import { SelectChallengePhase } from "#app/phases/select-challenge-phase";
|
||||
import { EncounterPhase } from "#app/phases/encounter-phase";
|
||||
import { TitlePhase } from "#app/phases/title-phase";
|
||||
import { AbilityId } from "#enums/ability-id";
|
||||
import {
|
||||
getPassiveCandyCount,
|
||||
@ -4307,10 +4304,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
||||
ui.setMode(UiMode.STARTER_SELECT);
|
||||
globalScene.phaseManager.clearPhaseQueue();
|
||||
if (globalScene.gameMode.isChallenge) {
|
||||
globalScene.phaseManager.pushPhase(new SelectChallengePhase());
|
||||
globalScene.phaseManager.pushPhase(new EncounterPhase());
|
||||
globalScene.phaseManager.createAndPush("SelectChallengePhase");
|
||||
globalScene.phaseManager.createAndPush("EncounterPhase");
|
||||
} else {
|
||||
globalScene.phaseManager.pushPhase(new TitlePhase());
|
||||
globalScene.phaseManager.createAndPush("TitlePhase");
|
||||
}
|
||||
this.clearText();
|
||||
globalScene.phaseManager.getCurrentPhase()?.end();
|
||||
|
@ -105,8 +105,8 @@ export default class GameManager {
|
||||
|
||||
// Must be run after phase interceptor has been initialized.
|
||||
|
||||
this.scene.phaseManager.pushPhase(new LoginPhase());
|
||||
this.scene.phaseManager.pushPhase(new TitlePhase());
|
||||
this.scene.phaseManager.createAndPush("LoginPhase");
|
||||
this.scene.phaseManager.createAndPush("TitlePhase");
|
||||
this.scene.phaseManager.shiftPhase();
|
||||
|
||||
this.gameWrapper.scene = this.scene;
|
||||
|
Loading…
Reference in New Issue
Block a user