mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-21 07:42:25 +02:00
Properly handle cases where enemy switches in due to revival
This commit is contained in:
parent
ca0522436a
commit
1567ae9fed
@ -3,7 +3,7 @@ import { CommandedTag, EncoreTag, GulpMissileTag, HelpingHandTag, SemiInvulnerab
|
|||||||
import { getPokemonNameWithAffix } from "../messages";
|
import { getPokemonNameWithAffix } from "../messages";
|
||||||
import type { AttackMoveResult, TurnMove } from "../field/pokemon";
|
import type { AttackMoveResult, TurnMove } from "../field/pokemon";
|
||||||
import type Pokemon from "../field/pokemon";
|
import type Pokemon from "../field/pokemon";
|
||||||
import { EnemyPokemon, HitResult, MoveResult, PlayerPokemon, PokemonMove } from "../field/pokemon";
|
import { EnemyPokemon, FieldPosition, HitResult, MoveResult, PlayerPokemon, PokemonMove } from "../field/pokemon";
|
||||||
import { getNonVolatileStatusEffects, getStatusEffectHealText, isNonVolatileStatusEffect } from "./status-effect";
|
import { getNonVolatileStatusEffects, getStatusEffectHealText, isNonVolatileStatusEffect } from "./status-effect";
|
||||||
import { getTypeDamageMultiplier } from "./type";
|
import { getTypeDamageMultiplier } from "./type";
|
||||||
import { Type } from "#enums/type";
|
import { Type } from "#enums/type";
|
||||||
@ -5945,12 +5945,18 @@ export class RevivalBlessingAttr extends MoveEffectAttr {
|
|||||||
pokemon.resetStatus();
|
pokemon.resetStatus();
|
||||||
pokemon.heal(Math.min(Utils.toDmgValue(0.5 * pokemon.getMaxHp()), pokemon.getMaxHp()));
|
pokemon.heal(Math.min(Utils.toDmgValue(0.5 * pokemon.getMaxHp()), pokemon.getMaxHp()));
|
||||||
globalScene.queueMessage(i18next.t("moveTriggers:revivalBlessing", { pokemonName: getPokemonNameWithAffix(pokemon) }), 0, true);
|
globalScene.queueMessage(i18next.t("moveTriggers:revivalBlessing", { pokemonName: getPokemonNameWithAffix(pokemon) }), 0, true);
|
||||||
|
|
||||||
if (globalScene.currentBattle.double && globalScene.getEnemyParty().length > 1) {
|
if (globalScene.currentBattle.double && globalScene.getEnemyParty().length > 1) {
|
||||||
const allyPokemon = user.getAlly();
|
const allyPokemon = user.getAlly();
|
||||||
if (slotIndex <= 1) {
|
// Handle cases where revived pokemon needs to get switched in on same turn
|
||||||
globalScene.unshiftPhase(new SwitchSummonPhase(SwitchType.SWITCH, pokemon.getFieldIndex(), slotIndex, false, false));
|
if (allyPokemon.isFainted() || allyPokemon === pokemon) {
|
||||||
} else if (allyPokemon.isFainted()) {
|
// Enemy switch phase should be removed and replaced with the revived pkmn switching in
|
||||||
|
globalScene.tryRemovePhase((phase: SwitchSummonPhase) => phase instanceof SwitchSummonPhase && !phase.getPlayer());
|
||||||
|
// 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.findPhase((phase: MovePhase) => phase.pokemon === pokemon)?.cancel();
|
||||||
|
if (user.fieldPosition === FieldPosition.CENTER) {
|
||||||
|
user.setFieldPosition(FieldPosition.LEFT);
|
||||||
|
}
|
||||||
globalScene.unshiftPhase(new SwitchSummonPhase(SwitchType.SWITCH, allyPokemon.getFieldIndex(), slotIndex, false, false));
|
globalScene.unshiftPhase(new SwitchSummonPhase(SwitchType.SWITCH, allyPokemon.getFieldIndex(), slotIndex, false, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,4 +24,8 @@ export abstract class PartyMemberPokemonPhase extends FieldPhase {
|
|||||||
getPokemon(): Pokemon {
|
getPokemon(): Pokemon {
|
||||||
return this.getParty()[this.partyMemberIndex];
|
return this.getParty()[this.partyMemberIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPlayer(): boolean {
|
||||||
|
return this.player;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user