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;
|
: 0;
|
||||||
globalScene.phaseManager.prependNewToPhase(
|
globalScene.phaseManager.prependNewToPhase(
|
||||||
"MoveEndPhase",
|
"MoveEndPhase",
|
||||||
"SwitchSummonPhase",
|
"StaticSwitchSummonPhase",
|
||||||
this.switchType,
|
this.switchType,
|
||||||
switchOutTarget.getFieldIndex(),
|
switchOutTarget.getFieldIndex(),
|
||||||
summonIndex,
|
summonIndex,
|
||||||
|
@ -6192,13 +6192,15 @@ export class RevivalBlessingAttr extends MoveEffectAttr {
|
|||||||
if (globalScene.currentBattle.double && globalScene.getEnemyParty().length > 1 && !isNullOrUndefined(allyPokemon)) {
|
if (globalScene.currentBattle.double && globalScene.getEnemyParty().length > 1 && !isNullOrUndefined(allyPokemon)) {
|
||||||
// Handle cases where revived pokemon needs to get switched in on same turn
|
// Handle cases where revived pokemon needs to get switched in on same turn
|
||||||
if (allyPokemon.isFainted() || allyPokemon === pokemon) {
|
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
|
// 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)
|
// (revived pokemon can't move in the turn they're brought back)
|
||||||
globalScene.phaseManager.findPhase("MovePhase", (phase: MovePhase) => phase.pokemon === pokemon)?.cancel();
|
globalScene.phaseManager.findPhase("MovePhase", (phase: MovePhase) => phase.pokemon === pokemon)?.cancel();
|
||||||
if (user.fieldPosition === FieldPosition.CENTER) {
|
if (user.fieldPosition === FieldPosition.CENTER) {
|
||||||
user.setFieldPosition(FieldPosition.LEFT);
|
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;
|
return true;
|
||||||
@ -6278,7 +6280,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
const slotIndex = eligibleNewIndices[user.randBattleSeedInt(eligibleNewIndices.length)];
|
const slotIndex = eligibleNewIndices[user.randBattleSeedInt(eligibleNewIndices.length)];
|
||||||
globalScene.phaseManager.prependNewToPhase(
|
globalScene.phaseManager.prependNewToPhase(
|
||||||
"MoveEndPhase",
|
"MoveEndPhase",
|
||||||
"SwitchSummonPhase",
|
"StaticSwitchSummonPhase",
|
||||||
this.switchType,
|
this.switchType,
|
||||||
switchOutTarget.getFieldIndex(),
|
switchOutTarget.getFieldIndex(),
|
||||||
slotIndex,
|
slotIndex,
|
||||||
@ -6317,7 +6319,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
switchOutTarget.leaveField(true);
|
switchOutTarget.leaveField(true);
|
||||||
const slotIndex = eligibleNewIndices[user.randBattleSeedInt(eligibleNewIndices.length)];
|
const slotIndex = eligibleNewIndices[user.randBattleSeedInt(eligibleNewIndices.length)];
|
||||||
globalScene.phaseManager.prependNewToPhase("MoveEndPhase",
|
globalScene.phaseManager.prependNewToPhase("MoveEndPhase",
|
||||||
"SwitchSummonPhase",
|
"StaticSwitchSummonPhase",
|
||||||
this.switchType,
|
this.switchType,
|
||||||
switchOutTarget.getFieldIndex(),
|
switchOutTarget.getFieldIndex(),
|
||||||
slotIndex,
|
slotIndex,
|
||||||
@ -6327,7 +6329,7 @@ export class ForceSwitchOutAttr extends MoveEffectAttr {
|
|||||||
} else {
|
} else {
|
||||||
switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH);
|
switchOutTarget.leaveField(this.switchType === SwitchType.SWITCH);
|
||||||
globalScene.phaseManager.prependNewToPhase("MoveEndPhase",
|
globalScene.phaseManager.prependNewToPhase("MoveEndPhase",
|
||||||
"SwitchSummonPhase",
|
"StaticSwitchSummonPhase",
|
||||||
this.switchType,
|
this.switchType,
|
||||||
switchOutTarget.getFieldIndex(),
|
switchOutTarget.getFieldIndex(),
|
||||||
(globalScene.currentBattle.trainer ? globalScene.currentBattle.trainer.getNextSummonIndex((switchOutTarget as EnemyPokemon).trainerSlot) : 0),
|
(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) {
|
if (slotIndex >= globalScene.currentBattle.getBattlerCount() && slotIndex < 6) {
|
||||||
globalScene.phaseManager.prependNewToPhase(
|
globalScene.phaseManager.prependNewToPhase(
|
||||||
"MoveEndPhase",
|
"MoveEndPhase",
|
||||||
"SwitchSummonPhase",
|
"StaticSwitchSummonPhase",
|
||||||
switchType,
|
switchType,
|
||||||
this.getFieldIndex(),
|
this.getFieldIndex(),
|
||||||
slotIndex,
|
slotIndex,
|
||||||
|
@ -99,6 +99,7 @@ import { DynamicQueueManager } from "#app/queues/dynamic-queue-manager";
|
|||||||
import type { PhaseConditionFunc } from "#app/@types/phase-condition";
|
import type { PhaseConditionFunc } from "#app/@types/phase-condition";
|
||||||
import { MovePhaseTimingModifier } from "#enums/move-phase-timing-modifier";
|
import { MovePhaseTimingModifier } from "#enums/move-phase-timing-modifier";
|
||||||
import type { PokemonMove } from "#app/data/moves/pokemon-move";
|
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.
|
* Manager for phases used by battle scene.
|
||||||
@ -189,6 +190,7 @@ const PHASES = Object.freeze({
|
|||||||
ShowAbilityPhase,
|
ShowAbilityPhase,
|
||||||
ShowPartyExpBarPhase,
|
ShowPartyExpBarPhase,
|
||||||
ShowTrainerPhase,
|
ShowTrainerPhase,
|
||||||
|
StaticSwitchSummonPhase,
|
||||||
StatStageChangePhase,
|
StatStageChangePhase,
|
||||||
SummonMissingPhase,
|
SummonMissingPhase,
|
||||||
SummonPhase,
|
SummonPhase,
|
||||||
|
@ -183,7 +183,14 @@ export class FaintPhase extends PokemonPhase {
|
|||||||
.filter(p => p.isActive() && !p.isOnField() && p.trainerSlot === (pokemon as EnemyPokemon).trainerSlot)
|
.filter(p => p.isActive() && !p.isOnField() && p.trainerSlot === (pokemon as EnemyPokemon).trainerSlot)
|
||||||
.length;
|
.length;
|
||||||
if (hasReservePartyMember) {
|
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) {
|
if (slotIndex <= 1) {
|
||||||
// Revived ally pokemon
|
// Revived ally pokemon
|
||||||
globalScene.phaseManager.unshiftNew(
|
globalScene.phaseManager.unshiftNew(
|
||||||
"SwitchSummonPhase",
|
"StaticSwitchSummonPhase",
|
||||||
SwitchType.SWITCH,
|
SwitchType.SWITCH,
|
||||||
pokemon.getFieldIndex(),
|
pokemon.getFieldIndex(),
|
||||||
slotIndex,
|
slotIndex,
|
||||||
@ -61,7 +61,7 @@ export class RevivalBlessingPhase extends BattlePhase {
|
|||||||
} else if (allyPokemon.isFainted()) {
|
} else if (allyPokemon.isFainted()) {
|
||||||
// Revived party pokemon, and ally pokemon is fainted
|
// Revived party pokemon, and ally pokemon is fainted
|
||||||
globalScene.phaseManager.unshiftNew(
|
globalScene.phaseManager.unshiftNew(
|
||||||
"SwitchSummonPhase",
|
"StaticSwitchSummonPhase",
|
||||||
SwitchType.SWITCH,
|
SwitchType.SWITCH,
|
||||||
allyPokemon.getFieldIndex(),
|
allyPokemon.getFieldIndex(),
|
||||||
slotIndex,
|
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 {
|
export class SummonPhase extends PartyMemberPokemonPhase {
|
||||||
// The union type is needed to keep typescript happy as these phases extend from SummonPhase
|
// 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;
|
private loaded: boolean;
|
||||||
|
|
||||||
constructor(fieldIndex: number, player = true, loaded = false) {
|
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,
|
p => p.is("PostSummonPhase") && p.player && p.fieldIndex === this.fieldIndex,
|
||||||
);
|
);
|
||||||
const switchType = option === PartyOption.PASS_BATON ? SwitchType.BATON_PASS : this.switchType;
|
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());
|
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";
|
import { SwitchType } from "#enums/switch-type";
|
||||||
|
|
||||||
export class SwitchSummonPhase extends SummonPhase {
|
export class SwitchSummonPhase extends SummonPhase {
|
||||||
public readonly phaseName: "SwitchSummonPhase" | "ReturnPhase" = "SwitchSummonPhase";
|
public readonly phaseName: "SwitchSummonPhase" | "ReturnPhase" | "StaticSwitchSummonPhase" = "SwitchSummonPhase";
|
||||||
private readonly switchType: SwitchType;
|
private readonly switchType: SwitchType;
|
||||||
private readonly slotIndex: number;
|
private readonly slotIndex: number;
|
||||||
private readonly doReturn: boolean;
|
private readonly doReturn: boolean;
|
||||||
|
@ -4,7 +4,7 @@ import { PokemonPhasePriorityQueue } from "#app/queues/pokemon-phase-priority-qu
|
|||||||
export class SwitchSummonPhasePriorityQueue extends PokemonPhasePriorityQueue<SwitchSummonPhase> {
|
export class SwitchSummonPhasePriorityQueue extends PokemonPhasePriorityQueue<SwitchSummonPhase> {
|
||||||
public override push(phase: SwitchSummonPhase): void {
|
public override push(phase: SwitchSummonPhase): void {
|
||||||
// The same pokemon or slot cannot be switched into at the same time
|
// The same pokemon or slot cannot be switched into at the same time
|
||||||
this.queue.filter(
|
this.queue = this.queue.filter(
|
||||||
old =>
|
old =>
|
||||||
old.getPokemon() !== phase.getPokemon() &&
|
old.getPokemon() !== phase.getPokemon() &&
|
||||||
!(old.isPlayer() === phase.isPlayer() && old.getFieldIndex() === phase.getFieldIndex()),
|
!(old.isPlayer() === phase.isPlayer() && old.getFieldIndex() === phase.getFieldIndex()),
|
||||||
|
Loading…
Reference in New Issue
Block a user