mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-04 15:32:18 +02:00
Update calls to append/prepend phase to use string phase
This commit is contained in:
parent
5cd3da3f78
commit
df6b754b2a
@ -55,7 +55,6 @@ import { SwitchPhase } from "#app/phases/switch-phase";
|
|||||||
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
|
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
|
||||||
import { BattleEndPhase } from "#app/phases/battle-end-phase";
|
import { BattleEndPhase } from "#app/phases/battle-end-phase";
|
||||||
import { NewBattlePhase } from "#app/phases/new-battle-phase";
|
import { NewBattlePhase } from "#app/phases/new-battle-phase";
|
||||||
import { MoveEndPhase } from "#app/phases/move-end-phase";
|
|
||||||
import { PokemonTransformPhase } from "#app/phases/pokemon-transform-phase";
|
import { PokemonTransformPhase } from "#app/phases/pokemon-transform-phase";
|
||||||
import { allAbilities } from "#app/data/data-lists";
|
import { allAbilities } from "#app/data/data-lists";
|
||||||
import { AbAttr } from "#app/data/abilities/ab-attrs/ab-attr";
|
import { AbAttr } from "#app/data/abilities/ab-attrs/ab-attr";
|
||||||
@ -7243,7 +7242,7 @@ class ForceSwitchOutHelper {
|
|||||||
switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH);
|
switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH);
|
||||||
globalScene.phaseManager.prependToPhase(
|
globalScene.phaseManager.prependToPhase(
|
||||||
new SwitchPhase(this.switchType, switchOutTarget.getFieldIndex(), true, true),
|
new SwitchPhase(this.switchType, switchOutTarget.getFieldIndex(), true, true),
|
||||||
MoveEndPhase,
|
"MoveEndPhase",
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -7262,7 +7261,7 @@ class ForceSwitchOutHelper {
|
|||||||
: 0;
|
: 0;
|
||||||
globalScene.phaseManager.prependToPhase(
|
globalScene.phaseManager.prependToPhase(
|
||||||
new SwitchSummonPhase(this.switchType, switchOutTarget.getFieldIndex(), summonIndex, false, false),
|
new SwitchSummonPhase(this.switchType, switchOutTarget.getFieldIndex(), summonIndex, false, false),
|
||||||
MoveEndPhase,
|
"MoveEndPhase",
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import { HitResult, MoveResult } from "#app/field/pokemon";
|
|||||||
import { getPokemonNameWithAffix } from "#app/messages";
|
import { getPokemonNameWithAffix } from "#app/messages";
|
||||||
import { CommonAnimPhase } from "#app/phases/common-anim-phase";
|
import { CommonAnimPhase } from "#app/phases/common-anim-phase";
|
||||||
import type { MoveEffectPhase } from "#app/phases/move-effect-phase";
|
import type { MoveEffectPhase } from "#app/phases/move-effect-phase";
|
||||||
import { MovePhase } from "#app/phases/move-phase";
|
import type { MovePhase } from "#app/phases/move-phase";
|
||||||
import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase";
|
import { PokemonHealPhase } from "#app/phases/pokemon-heal-phase";
|
||||||
import type { StatStageChangeCallback } from "#app/phases/stat-stage-change-phase";
|
import type { StatStageChangeCallback } from "#app/phases/stat-stage-change-phase";
|
||||||
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
||||||
@ -560,7 +560,7 @@ export class ShellTrapTag extends BattlerTag {
|
|||||||
// Only shift MovePhase timing if it's not already next up
|
// Only shift MovePhase timing if it's not already next up
|
||||||
if (shellTrapPhaseIndex !== -1 && shellTrapPhaseIndex !== firstMovePhaseIndex) {
|
if (shellTrapPhaseIndex !== -1 && shellTrapPhaseIndex !== firstMovePhaseIndex) {
|
||||||
const shellTrapMovePhase = globalScene.phaseManager.phaseQueue.splice(shellTrapPhaseIndex, 1)[0];
|
const shellTrapMovePhase = globalScene.phaseManager.phaseQueue.splice(shellTrapPhaseIndex, 1)[0];
|
||||||
globalScene.phaseManager.prependToPhase(shellTrapMovePhase, MovePhase);
|
globalScene.phaseManager.prependToPhase(shellTrapMovePhase, "MovePhase");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.activated = true;
|
this.activated = true;
|
||||||
@ -1194,7 +1194,7 @@ export class EncoreTag extends MoveRestrictionBattlerTag {
|
|||||||
const lastMove = pokemon.getLastXMoves(1)[0];
|
const lastMove = pokemon.getLastXMoves(1)[0];
|
||||||
globalScene.phaseManager.tryReplacePhase(
|
globalScene.phaseManager.tryReplacePhase(
|
||||||
m => m.is("MovePhase") && m.pokemon === pokemon,
|
m => m.is("MovePhase") && m.pokemon === pokemon,
|
||||||
new MovePhase(pokemon, lastMove.targets ?? [], movesetMove),
|
globalScene.phaseManager.newPhase("MovePhase", pokemon, lastMove.targets ?? [], movesetMove),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3125,7 +3125,7 @@ export class AwaitCombinedPledgeAttr extends OverrideMoveEffectAttr {
|
|||||||
const allyMovePhaseIndex = globalScene.phaseManager.phaseQueue.indexOf(allyMovePhase);
|
const allyMovePhaseIndex = globalScene.phaseManager.phaseQueue.indexOf(allyMovePhase);
|
||||||
const firstMovePhaseIndex = globalScene.phaseManager.phaseQueue.findIndex((phase) => phase.is("MovePhase"));
|
const firstMovePhaseIndex = globalScene.phaseManager.phaseQueue.findIndex((phase) => phase.is("MovePhase"));
|
||||||
if (allyMovePhaseIndex !== firstMovePhaseIndex) {
|
if (allyMovePhaseIndex !== firstMovePhaseIndex) {
|
||||||
globalScene.phaseManager.prependToPhase(globalScene.phaseManager.phaseQueue.splice(allyMovePhaseIndex, 1)[0], MovePhase);
|
globalScene.phaseManager.prependToPhase(globalScene.phaseManager.phaseQueue.splice(allyMovePhaseIndex, 1)[0], "MovePhase");
|
||||||
}
|
}
|
||||||
|
|
||||||
overridden.value = true;
|
overridden.value = true;
|
||||||
@ -4488,7 +4488,7 @@ export class CueNextRoundAttr extends MoveEffectAttr {
|
|||||||
const nextRoundIndex = globalScene.phaseManager.phaseQueue.indexOf(nextRoundPhase);
|
const nextRoundIndex = globalScene.phaseManager.phaseQueue.indexOf(nextRoundPhase);
|
||||||
const nextMoveIndex = globalScene.phaseManager.phaseQueue.findIndex(phase => phase.is("MovePhase"));
|
const nextMoveIndex = globalScene.phaseManager.phaseQueue.findIndex(phase => phase.is("MovePhase"));
|
||||||
if (nextRoundIndex !== nextMoveIndex) {
|
if (nextRoundIndex !== nextMoveIndex) {
|
||||||
globalScene.phaseManager.prependToPhase(globalScene.phaseManager.phaseQueue.splice(nextRoundIndex, 1)[0], MovePhase);
|
globalScene.phaseManager.prependToPhase(globalScene.phaseManager.phaseQueue.splice(nextRoundIndex, 1)[0], "MovePhase");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark the corresponding Pokemon as having "joined the Round" (for doubling power later)
|
// Mark the corresponding Pokemon as having "joined the Round" (for doubling power later)
|
||||||
@ -6263,7 +6263,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
false,
|
false,
|
||||||
true
|
true
|
||||||
),
|
),
|
||||||
MoveEndPhase
|
"MoveEndPhase"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH);
|
switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH);
|
||||||
@ -6274,7 +6274,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
true,
|
true,
|
||||||
true
|
true
|
||||||
),
|
),
|
||||||
MoveEndPhase
|
"MoveEndPhase"
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -6306,7 +6306,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
MoveEndPhase
|
"MoveEndPhase"
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH);
|
switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH);
|
||||||
@ -6318,7 +6318,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
),
|
),
|
||||||
MoveEndPhase
|
"MoveEndPhase"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7050,7 +7050,7 @@ export class RepeatMoveAttr extends MoveEffectAttr {
|
|||||||
}));
|
}));
|
||||||
target.getMoveQueue().unshift({ move: lastMove.move, targets: moveTargets, ignorePP: false });
|
target.getMoveQueue().unshift({ move: lastMove.move, targets: moveTargets, ignorePP: false });
|
||||||
target.turnData.extraTurns++;
|
target.turnData.extraTurns++;
|
||||||
globalScene.phaseManager.appendToPhase(new MovePhase(target, moveTargets, movesetMove), MoveEndPhase);
|
globalScene.phaseManager.appendToPhase(new MovePhase(target, moveTargets, movesetMove), "MoveEndPhase");
|
||||||
return 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.
|
//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);
|
const nextAttackPhase = globalScene.phaseManager.findPhase<MovePhase>((phase) => phase.pokemon === target);
|
||||||
if (nextAttackPhase && globalScene.phaseManager.tryRemovePhase((phase: MovePhase) => 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.prependToPhase(new MovePhase(target, [ ...nextAttackPhase.targets ], nextAttackPhase.move), "MovePhase");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -233,7 +233,6 @@ import { getPokemonNameWithAffix } from "#app/messages";
|
|||||||
import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
|
import { DamageAnimPhase } from "#app/phases/damage-anim-phase";
|
||||||
import { FaintPhase } from "#app/phases/faint-phase";
|
import { FaintPhase } from "#app/phases/faint-phase";
|
||||||
import { LearnMovePhase } from "#app/phases/learn-move-phase";
|
import { LearnMovePhase } from "#app/phases/learn-move-phase";
|
||||||
import { MoveEndPhase } from "#app/phases/move-end-phase";
|
|
||||||
import { ObtainStatusEffectPhase } from "#app/phases/obtain-status-effect-phase";
|
import { ObtainStatusEffectPhase } from "#app/phases/obtain-status-effect-phase";
|
||||||
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
||||||
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
|
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
|
||||||
@ -5637,7 +5636,7 @@ export class PlayerPokemon extends Pokemon {
|
|||||||
if (slotIndex >= globalScene.currentBattle.getBattlerCount() && slotIndex < 6) {
|
if (slotIndex >= globalScene.currentBattle.getBattlerCount() && slotIndex < 6) {
|
||||||
globalScene.phaseManager.prependToPhase(
|
globalScene.phaseManager.prependToPhase(
|
||||||
new SwitchSummonPhase(switchType, this.getFieldIndex(), slotIndex, false),
|
new SwitchSummonPhase(switchType, this.getFieldIndex(), slotIndex, false),
|
||||||
MoveEndPhase,
|
"MoveEndPhase",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
globalScene.ui.setMode(UiMode.MESSAGE).then(resolve);
|
globalScene.ui.setMode(UiMode.MESSAGE).then(resolve);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
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 "./utils/common";
|
import type { PhaseMap, PhaseString } from "./@types/phase-types";
|
||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import { AddEnemyBuffModifierPhase } from "#app/phases/add-enemy-buff-modifier-phase";
|
import { AddEnemyBuffModifierPhase } from "#app/phases/add-enemy-buff-modifier-phase";
|
||||||
import { AttemptCapturePhase } from "#app/phases/attempt-capture-phase";
|
import { AttemptCapturePhase } from "#app/phases/attempt-capture-phase";
|
||||||
@ -95,7 +95,6 @@ import { UnavailablePhase } from "#app/phases/unavailable-phase";
|
|||||||
import { UnlockPhase } from "#app/phases/unlock-phase";
|
import { UnlockPhase } from "#app/phases/unlock-phase";
|
||||||
import { VictoryPhase } from "#app/phases/victory-phase";
|
import { VictoryPhase } from "#app/phases/victory-phase";
|
||||||
import { WeatherEffectPhase } from "#app/phases/weather-effect-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.
|
||||||
@ -111,7 +110,7 @@ import type { PhaseString } from "./@types/phase-types";
|
|||||||
* The keys of this object are the names of the phases, and the values are the constructors of the phases.
|
* 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.
|
* This allows for easy creation of new phases without needing to import each phase individually.
|
||||||
*/
|
*/
|
||||||
const Phases = Object.freeze({
|
const PHASES = Object.freeze({
|
||||||
AddEnemyBuffModifierPhase,
|
AddEnemyBuffModifierPhase,
|
||||||
AttemptCapturePhase,
|
AttemptCapturePhase,
|
||||||
AttemptRunPhase,
|
AttemptRunPhase,
|
||||||
@ -207,7 +206,7 @@ const Phases = Object.freeze({
|
|||||||
|
|
||||||
// This type export cannot be moved to `@types`, as `Phases` is intentionally private to this file
|
// This type export cannot be moved to `@types`, as `Phases` is intentionally private to this file
|
||||||
/** Maps Phase strings to their constructors */
|
/** Maps Phase strings to their constructors */
|
||||||
export type PhaseConstructorMap = typeof Phases;
|
export type PhaseConstructorMap = typeof PHASES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PhaseManager is responsible for managing the phases in the battle scene
|
* PhaseManager is responsible for managing the phases in the battle scene
|
||||||
@ -412,15 +411,16 @@ export class PhaseManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to add the input phase to index before target phase in the phaseQueue, else simply calls unshiftPhase()
|
* Tries to add the input phase to index before target phase in the phaseQueue, else simply calls unshiftPhase()
|
||||||
* @param phase {@linkcode Phase} the phase to be added
|
* @param phase - The phase to be added
|
||||||
* @param targetPhase {@linkcode Phase} the type of phase to search for in phaseQueue
|
* @param targetPhase - The phase to search for in phaseQueue
|
||||||
* @returns boolean if a targetPhase was found and added
|
* @returns boolean if a targetPhase was found and added
|
||||||
*/
|
*/
|
||||||
prependToPhase(phase: Phase | Phase[], targetPhase: Constructor<Phase>): boolean {
|
prependToPhase(phase: Phase | Phase[], targetPhase: PhaseString): boolean {
|
||||||
if (!Array.isArray(phase)) {
|
if (!Array.isArray(phase)) {
|
||||||
phase = [phase];
|
phase = [phase];
|
||||||
}
|
}
|
||||||
const targetIndex = this.phaseQueue.findIndex(ph => ph instanceof targetPhase);
|
const target = PHASES[targetPhase];
|
||||||
|
const targetIndex = this.phaseQueue.findIndex(ph => ph instanceof target);
|
||||||
|
|
||||||
if (targetIndex !== -1) {
|
if (targetIndex !== -1) {
|
||||||
this.phaseQueue.splice(targetIndex, 0, ...phase);
|
this.phaseQueue.splice(targetIndex, 0, ...phase);
|
||||||
@ -433,14 +433,15 @@ export class PhaseManager {
|
|||||||
/**
|
/**
|
||||||
* Attempt to add the input phase(s) to index after target phase in the {@linkcode phaseQueue}, else simply calls {@linkcode unshiftPhase()}
|
* Attempt to add the input phase(s) to index after target phase in the {@linkcode phaseQueue}, else simply calls {@linkcode unshiftPhase()}
|
||||||
* @param phase - The phase(s) to be added
|
* @param phase - The phase(s) to be added
|
||||||
* @param targetPhase - The type of phase to search for in {@linkcode phaseQueue}
|
* @param targetPhase - The phase to search for in phaseQueue
|
||||||
* @returns `true` if a `targetPhase` was found to append to
|
* @returns `true` if a `targetPhase` was found to append to
|
||||||
*/
|
*/
|
||||||
appendToPhase(phase: Phase | Phase[], targetPhase: Constructor<Phase>): boolean {
|
appendToPhase(phase: Phase | Phase[], targetPhase: PhaseString): boolean {
|
||||||
if (!Array.isArray(phase)) {
|
if (!Array.isArray(phase)) {
|
||||||
phase = [phase];
|
phase = [phase];
|
||||||
}
|
}
|
||||||
const targetIndex = this.phaseQueue.findIndex(ph => ph instanceof targetPhase);
|
const target = PHASES[targetPhase];
|
||||||
|
const targetIndex = this.phaseQueue.findIndex(ph => ph instanceof target);
|
||||||
|
|
||||||
if (targetIndex !== -1 && this.phaseQueue.length > targetIndex) {
|
if (targetIndex !== -1 && this.phaseQueue.length > targetIndex) {
|
||||||
this.phaseQueue.splice(targetIndex + 1, 0, ...phase);
|
this.phaseQueue.splice(targetIndex + 1, 0, ...phase);
|
||||||
@ -520,8 +521,8 @@ export class PhaseManager {
|
|||||||
public newPhase<T extends PhaseString>(
|
public newPhase<T extends PhaseString>(
|
||||||
phase: T,
|
phase: T,
|
||||||
...args: ConstructorParameters<PhaseConstructorMap[T]>
|
...args: ConstructorParameters<PhaseConstructorMap[T]>
|
||||||
): InstanceType<(typeof Phases)[T]> {
|
): PhaseMap[T] {
|
||||||
const PhaseClass = Phases[phase];
|
const PhaseClass = PHASES[phase];
|
||||||
|
|
||||||
if (!PhaseClass) {
|
if (!PhaseClass) {
|
||||||
throw new Error(`Phase ${phase} does not exist in PhaseMap.`);
|
throw new Error(`Phase ${phase} does not exist in PhaseMap.`);
|
||||||
|
@ -70,7 +70,6 @@ import i18next from "i18next";
|
|||||||
import type { Phase } from "#app/phase";
|
import type { Phase } from "#app/phase";
|
||||||
import { ShowAbilityPhase } from "./show-ability-phase";
|
import { ShowAbilityPhase } from "./show-ability-phase";
|
||||||
import { MovePhase } from "./move-phase";
|
import { MovePhase } from "./move-phase";
|
||||||
import { MoveEndPhase } from "./move-end-phase";
|
|
||||||
import { HideAbilityPhase } from "#app/phases/hide-ability-phase";
|
import { HideAbilityPhase } from "#app/phases/hide-ability-phase";
|
||||||
import type { TypeDamageMultiplier } from "#app/data/type";
|
import type { TypeDamageMultiplier } from "#app/data/type";
|
||||||
import { HitCheckResult } from "#enums/hit-check-result";
|
import { HitCheckResult } from "#enums/hit-check-result";
|
||||||
@ -384,7 +383,7 @@ export class MoveEffectPhase extends PokemonPhase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.queuedPhases.length) {
|
if (this.queuedPhases.length) {
|
||||||
globalScene.phaseManager.appendToPhase(this.queuedPhases, MoveEndPhase);
|
globalScene.phaseManager.appendToPhase(this.queuedPhases, "MoveEndPhase");
|
||||||
}
|
}
|
||||||
const moveType = user.getMoveType(this.move, true);
|
const moveType = user.getMoveType(this.move, true);
|
||||||
if (this.move.category !== MoveCategory.STATUS && !user.stellarTypesBoosted.includes(moveType)) {
|
if (this.move.category !== MoveCategory.STATUS && !user.stellarTypesBoosted.includes(moveType)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user