mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-03 23:12:20 +02:00
Add StaticSwitchSummonPhase
This commit is contained in:
parent
88e447fe7e
commit
87ed788e8f
@ -7451,7 +7451,7 @@ class ForceSwitchOutHelper {
|
||||
: 0;
|
||||
globalScene.phaseManager.prependNewToPhase(
|
||||
"MoveEndPhase",
|
||||
"SwitchSummonPhase",
|
||||
"StaticSwitchSummonPhase",
|
||||
this.switchType,
|
||||
switchOutTarget.getFieldIndex(),
|
||||
summonIndex,
|
||||
|
@ -6192,13 +6192,15 @@ export class RevivalBlessingAttr extends MoveEffectAttr {
|
||||
if (globalScene.currentBattle.double && globalScene.getEnemyParty().length > 1 && !isNullOrUndefined(allyPokemon)) {
|
||||
// Handle cases where revived pokemon needs to get switched in on same turn
|
||||
if (allyPokemon.isFainted() || allyPokemon === pokemon) {
|
||||
// Enemy switch phase should be removed and replaced with the revived pkmn switching in
|
||||
globalScene.phaseManager.tryRemovePhase((phase: SwitchSummonPhase) => phase.is("StaticSwitchSummonPhase") && phase.getPokemon() === pokemon);
|
||||
// If the pokemon being revived was alive earlier in the turn, cancel its move
|
||||
// (revived pokemon can't move in the turn they're brought back)
|
||||
globalScene.phaseManager.findPhase("MovePhase", (phase: MovePhase) => phase.pokemon === pokemon)?.cancel();
|
||||
if (user.fieldPosition === FieldPosition.CENTER) {
|
||||
user.setFieldPosition(FieldPosition.LEFT);
|
||||
}
|
||||
globalScene.phaseManager.pushNew("SwitchSummonPhase", SwitchType.SWITCH, allyPokemon.getFieldIndex(), slotIndex, false, false);
|
||||
globalScene.phaseManager.unshiftNew("StaticSwitchSummonPhase", SwitchType.SWITCH, allyPokemon.getFieldIndex(), slotIndex, false, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -6278,7 +6280,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||
const slotIndex = eligibleNewIndices[user.randBattleSeedInt(eligibleNewIndices.length)];
|
||||
globalScene.phaseManager.prependNewToPhase(
|
||||
"MoveEndPhase",
|
||||
"SwitchSummonPhase",
|
||||
"StaticSwitchSummonPhase",
|
||||
this.switchType,
|
||||
switchOutTarget.getFieldIndex(),
|
||||
slotIndex,
|
||||
@ -6317,7 +6319,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||
switchOutTarget.leaveField(true);
|
||||
const slotIndex = eligibleNewIndices[user.randBattleSeedInt(eligibleNewIndices.length)];
|
||||
globalScene.phaseManager.prependNewToPhase("MoveEndPhase",
|
||||
"SwitchSummonPhase",
|
||||
"StaticSwitchSummonPhase",
|
||||
this.switchType,
|
||||
switchOutTarget.getFieldIndex(),
|
||||
slotIndex,
|
||||
@ -6327,7 +6329,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
||||
} else {
|
||||
switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH);
|
||||
globalScene.phaseManager.prependNewToPhase("MoveEndPhase",
|
||||
"SwitchSummonPhase",
|
||||
"StaticSwitchSummonPhase",
|
||||
this.switchType,
|
||||
switchOutTarget.getFieldIndex(),
|
||||
(globalScene.currentBattle.trainer ? globalScene.currentBattle.trainer.getNextSummonIndex((switchOutTarget as EnemyPokemon).trainerSlot) : 0),
|
||||
|
@ -5598,7 +5598,7 @@ export class PlayerPokemon extends Pokemon {
|
||||
if (slotIndex >= globalScene.currentBattle.getBattlerCount() && slotIndex < 6) {
|
||||
globalScene.phaseManager.prependNewToPhase(
|
||||
"MoveEndPhase",
|
||||
"SwitchSummonPhase",
|
||||
"StaticSwitchSummonPhase",
|
||||
switchType,
|
||||
this.getFieldIndex(),
|
||||
slotIndex,
|
||||
|
@ -99,6 +99,7 @@ import { DynamicQueueManager } from "#app/queues/dynamic-queue-manager";
|
||||
import type { PhaseConditionFunc } from "#app/@types/phase-condition";
|
||||
import { MovePhaseTimingModifier } from "#enums/move-phase-timing-modifier";
|
||||
import type { PokemonMove } from "#app/data/moves/pokemon-move";
|
||||
import { StaticSwitchSummonPhase } from "#app/phases/static-switch-summon-phase";
|
||||
|
||||
/**
|
||||
* Manager for phases used by battle scene.
|
||||
@ -189,6 +190,7 @@ const PHASES = Object.freeze({
|
||||
ShowAbilityPhase,
|
||||
ShowPartyExpBarPhase,
|
||||
ShowTrainerPhase,
|
||||
StaticSwitchSummonPhase,
|
||||
StatStageChangePhase,
|
||||
SummonMissingPhase,
|
||||
SummonPhase,
|
||||
|
@ -183,7 +183,14 @@ export class FaintPhase extends PokemonPhase {
|
||||
.filter(p => p.isActive() && !p.isOnField() && p.trainerSlot === (pokemon as EnemyPokemon).trainerSlot)
|
||||
.length;
|
||||
if (hasReservePartyMember) {
|
||||
globalScene.phaseManager.pushNew("SwitchSummonPhase", SwitchType.SWITCH, this.fieldIndex, -1, false, false);
|
||||
globalScene.phaseManager.pushNew(
|
||||
"StaticSwitchSummonPhase",
|
||||
SwitchType.SWITCH,
|
||||
this.fieldIndex,
|
||||
-1,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ export class RevivalBlessingPhase extends BattlePhase {
|
||||
if (slotIndex <= 1) {
|
||||
// Revived ally pokemon
|
||||
globalScene.phaseManager.unshiftNew(
|
||||
"SwitchSummonPhase",
|
||||
"StaticSwitchSummonPhase",
|
||||
SwitchType.SWITCH,
|
||||
pokemon.getFieldIndex(),
|
||||
slotIndex,
|
||||
@ -61,7 +61,7 @@ export class RevivalBlessingPhase extends BattlePhase {
|
||||
} else if (allyPokemon.isFainted()) {
|
||||
// Revived party pokemon, and ally pokemon is fainted
|
||||
globalScene.phaseManager.unshiftNew(
|
||||
"SwitchSummonPhase",
|
||||
"StaticSwitchSummonPhase",
|
||||
SwitchType.SWITCH,
|
||||
allyPokemon.getFieldIndex(),
|
||||
slotIndex,
|
||||
|
5
src/phases/static-switch-summon-phase.ts
Normal file
5
src/phases/static-switch-summon-phase.ts
Normal file
@ -0,0 +1,5 @@
|
||||
import { SwitchSummonPhase } from "#app/phases/switch-summon-phase";
|
||||
|
||||
export class StaticSwitchSummonPhase extends SwitchSummonPhase {
|
||||
public readonly phaseName = "StaticSwitchSummonPhase";
|
||||
}
|
@ -15,7 +15,12 @@ import { globalScene } from "#app/global-scene";
|
||||
|
||||
export class SummonPhase extends PartyMemberPokemonPhase {
|
||||
// The union type is needed to keep typescript happy as these phases extend from SummonPhase
|
||||
public readonly phaseName: "SummonPhase" | "SummonMissingPhase" | "SwitchSummonPhase" | "ReturnPhase" = "SummonPhase";
|
||||
public readonly phaseName:
|
||||
| "SummonPhase"
|
||||
| "SummonMissingPhase"
|
||||
| "SwitchSummonPhase"
|
||||
| "ReturnPhase"
|
||||
| "StaticSwitchSummonPhase" = "SummonPhase";
|
||||
private loaded: boolean;
|
||||
|
||||
constructor(fieldIndex: number, player = true, loaded = false) {
|
||||
|
@ -79,7 +79,13 @@ export class SwitchPhase extends BattlePhase {
|
||||
p => p.is("PostSummonPhase") && p.player && p.fieldIndex === this.fieldIndex,
|
||||
);
|
||||
const switchType = option === PartyOption.PASS_BATON ? SwitchType.BATON_PASS : this.switchType;
|
||||
globalScene.phaseManager.pushNew("SwitchSummonPhase", switchType, fieldIndex, slotIndex, this.doReturn);
|
||||
globalScene.phaseManager.unshiftNew(
|
||||
"StaticSwitchSummonPhase",
|
||||
switchType,
|
||||
fieldIndex,
|
||||
slotIndex,
|
||||
this.doReturn,
|
||||
);
|
||||
}
|
||||
globalScene.ui.setMode(UiMode.MESSAGE).then(() => super.end());
|
||||
},
|
||||
|
@ -14,7 +14,7 @@ import { SubstituteTag } from "#app/data/battler-tags";
|
||||
import { SwitchType } from "#enums/switch-type";
|
||||
|
||||
export class SwitchSummonPhase extends SummonPhase {
|
||||
public readonly phaseName: "SwitchSummonPhase" | "ReturnPhase" = "SwitchSummonPhase";
|
||||
public readonly phaseName: "SwitchSummonPhase" | "ReturnPhase" | "StaticSwitchSummonPhase" = "SwitchSummonPhase";
|
||||
private readonly switchType: SwitchType;
|
||||
private readonly slotIndex: number;
|
||||
private readonly doReturn: boolean;
|
||||
|
@ -4,7 +4,7 @@ import { PokemonPhasePriorityQueue } from "#app/queues/pokemon-phase-priority-qu
|
||||
export class SwitchSummonPhasePriorityQueue extends PokemonPhasePriorityQueue<SwitchSummonPhase> {
|
||||
public override push(phase: SwitchSummonPhase): void {
|
||||
// The same pokemon or slot cannot be switched into at the same time
|
||||
this.queue.filter(
|
||||
this.queue = this.queue.filter(
|
||||
old =>
|
||||
old.getPokemon() !== phase.getPokemon() &&
|
||||
!(old.isPlayer() === phase.isPlayer() && old.getFieldIndex() === phase.getFieldIndex()),
|
||||
|
Loading…
Reference in New Issue
Block a user