mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-29 19:52:27 +02:00
Use leaveField everywhere
This commit is contained in:
parent
b922e94d0b
commit
e60939ec04
@ -148,7 +148,7 @@ export const DancingLessonsEncounter: MysteryEncounter =
|
||||
|
||||
// Adds a real Pokemon sprite to the field (required for the animation)
|
||||
globalScene.getEnemyParty().forEach(enemyPokemon => {
|
||||
globalScene.field.remove(enemyPokemon, true);
|
||||
enemyPokemon.leaveField(true, true, true);
|
||||
});
|
||||
globalScene.currentBattle.enemyParty = [ oricorio ];
|
||||
globalScene.field.add(oricorio);
|
||||
|
@ -229,7 +229,7 @@ function handleLoseMinigame() {
|
||||
// End the battle
|
||||
if (wobbuffet) {
|
||||
wobbuffet.hideInfo();
|
||||
globalScene.field.remove(wobbuffet);
|
||||
wobbuffet.leaveField();
|
||||
}
|
||||
transitionMysteryEncounterIntroVisuals(true, true);
|
||||
globalScene.currentBattle.enemyParty = [];
|
||||
@ -278,7 +278,7 @@ function handleNextTurn() {
|
||||
|
||||
// End the battle
|
||||
wobbuffet.hideInfo();
|
||||
globalScene.field.remove(wobbuffet);
|
||||
wobbuffet.leaveField();
|
||||
globalScene.currentBattle.enemyParty = [];
|
||||
globalScene.currentBattle.mysteryEncounter!.doContinueEncounter = undefined;
|
||||
leaveEncounterWithoutBattle(isHealPhase);
|
||||
|
@ -575,7 +575,7 @@ function onGameOver() {
|
||||
ease: "Sine.easeIn",
|
||||
scale: 0.5,
|
||||
onComplete: () => {
|
||||
globalScene.field.remove(pokemon, true);
|
||||
pokemon.leaveField(true, true, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ export async function initBattleWithEnemyConfig(partyConfig: EnemyPartyConfig):
|
||||
}
|
||||
|
||||
globalScene.getEnemyParty().forEach(enemyPokemon => {
|
||||
globalScene.field.remove(enemyPokemon, true);
|
||||
enemyPokemon.leaveField(true, true, true);
|
||||
});
|
||||
battle.enemyParty = [];
|
||||
battle.double = doubleBattle;
|
||||
@ -809,7 +809,7 @@ export function transitionMysteryEncounterIntroVisuals(hide: boolean = true, des
|
||||
globalScene.field.remove(introVisuals, true);
|
||||
|
||||
enemyPokemon.forEach(pokemon => {
|
||||
globalScene.field.remove(pokemon, true);
|
||||
pokemon.leaveField(true, true, true);
|
||||
});
|
||||
|
||||
globalScene.currentBattle.mysteryEncounter!.introVisuals = undefined;
|
||||
|
@ -592,7 +592,7 @@ export async function catchPokemon(pokemon: EnemyPokemon, pokeball: Phaser.GameO
|
||||
};
|
||||
const removePokemon = () => {
|
||||
if (pokemon) {
|
||||
globalScene.field.remove(pokemon, true);
|
||||
pokemon.leaveField(true, true, true);
|
||||
}
|
||||
};
|
||||
const addToParty = (slotIndex?: number) => {
|
||||
@ -695,7 +695,7 @@ export async function doPokemonFlee(pokemon: EnemyPokemon): Promise<void> {
|
||||
scale: pokemon.getSpriteScale(),
|
||||
onComplete: () => {
|
||||
pokemon.setVisible(false);
|
||||
globalScene.field.remove(pokemon, true);
|
||||
pokemon.leaveField(true, true, true);
|
||||
showEncounterText(i18next.t("battle:pokemonFled", { pokemonName: pokemon.getNameToRender() }), null, 600, false)
|
||||
.then(() => {
|
||||
resolve();
|
||||
@ -723,7 +723,7 @@ export function doPlayerFlee(pokemon: EnemyPokemon): Promise<void> {
|
||||
scale: pokemon.getSpriteScale(),
|
||||
onComplete: () => {
|
||||
pokemon.setVisible(false);
|
||||
globalScene.field.remove(pokemon, true);
|
||||
pokemon.leaveField(true, true, true);
|
||||
showEncounterText(i18next.t("battle:playerFled", { pokemonName: pokemon.getNameToRender() }), null, 600, false)
|
||||
.then(() => {
|
||||
resolve();
|
||||
|
@ -4118,9 +4118,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
* @param hideInfo Indicates if this should also play the animation to hide the Pokemon's
|
||||
* info container.
|
||||
*/
|
||||
leaveField(clearEffects: boolean = true, hideInfo: boolean = true) {
|
||||
leaveField(clearEffects: boolean = true, hideInfo: boolean = true, destroy: boolean = false) {
|
||||
this.resetSprite();
|
||||
this.resetTurnData();
|
||||
globalScene.getField(true).filter(p => p !== this).forEach(p => p.removeTagsBySourceId(this.id));
|
||||
|
||||
if (clearEffects) {
|
||||
this.destroySubstitute();
|
||||
this.resetSummonData(); // this also calls `resetBattleSummonData`
|
||||
@ -4128,10 +4130,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||
if (hideInfo) {
|
||||
this.hideInfo();
|
||||
}
|
||||
// Trigger abilities that activate upon leaving the field
|
||||
applyPreLeaveFieldAbAttrs(PreLeaveFieldAbAttr, this);
|
||||
globalScene.field.remove(this);
|
||||
this.setSwitchOutStatus(true);
|
||||
globalScene.triggerPokemonFormChange(this, SpeciesFormChangeActiveTrigger, true);
|
||||
globalScene.field.remove(this, destroy);
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
|
@ -241,11 +241,10 @@ export class AttemptCapturePhase extends PokemonPhase {
|
||||
};
|
||||
const removePokemon = () => {
|
||||
globalScene.addFaintedEnemyScore(pokemon);
|
||||
globalScene.getPlayerField().filter(p => p.isActive(true)).forEach(playerPokemon => playerPokemon.removeTagsBySourceId(pokemon.id));
|
||||
pokemon.hp = 0;
|
||||
pokemon.trySetStatus(StatusEffect.FAINT);
|
||||
globalScene.clearEnemyHeldItemModifiers();
|
||||
globalScene.field.remove(pokemon, true);
|
||||
pokemon.leaveField(true, true, true);
|
||||
};
|
||||
const addToParty = (slotIndex?: number) => {
|
||||
const newPokemon = pokemon.addToParty(this.pokeballType, slotIndex);
|
||||
|
@ -181,9 +181,7 @@ export class FaintPhase extends PokemonPhase {
|
||||
y: pokemon.y + 150,
|
||||
ease: "Sine.easeIn",
|
||||
onComplete: () => {
|
||||
pokemon.resetSprite();
|
||||
pokemon.lapseTags(BattlerTagLapseType.FAINT);
|
||||
globalScene.getField(true).filter(p => p !== pokemon).forEach(p => p.removeTagsBySourceId(pokemon.id));
|
||||
|
||||
pokemon.y -= 150;
|
||||
pokemon.trySetStatus(StatusEffect.FAINT);
|
||||
@ -193,7 +191,7 @@ export class FaintPhase extends PokemonPhase {
|
||||
globalScene.addFaintedEnemyScore(pokemon as EnemyPokemon);
|
||||
globalScene.currentBattle.addPostBattleLoot(pokemon as EnemyPokemon);
|
||||
}
|
||||
globalScene.field.remove(pokemon);
|
||||
pokemon.leaveField();
|
||||
this.end();
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user