* Properly handle cases where enemy switches in due to revival * Fix user ally using move when revived * Move revival blessing function to move.ts * Properly filter for the right switch phase to remove * Re-add bug fix * Add test
This commit is contained in:
parent
1e876ec595
commit
817095d895
|
@ -16,6 +16,7 @@ import type { AttackMoveResult, TurnMove } from "../../field/pokemon";
|
|||
import type Pokemon from "../../field/pokemon";
|
||||
import {
|
||||
EnemyPokemon,
|
||||
FieldPosition,
|
||||
HitResult,
|
||||
MoveResult,
|
||||
PlayerPokemon,
|
||||
|
@ -6158,9 +6159,16 @@ export class RevivalBlessingAttr extends MoveEffectAttr {
|
|||
|
||||
if (globalScene.currentBattle.double && globalScene.getEnemyParty().length > 1) {
|
||||
const allyPokemon = user.getAlly();
|
||||
if (slotIndex <= 1) {
|
||||
globalScene.unshiftPhase(new SwitchSummonPhase(SwitchType.SWITCH, pokemon.getFieldIndex(), slotIndex, false, false));
|
||||
} else if (allyPokemon.isFainted()) {
|
||||
// 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.tryRemovePhase((phase: SwitchSummonPhase) => phase instanceof SwitchSummonPhase && 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.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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,4 +114,25 @@ describe("Moves - Revival Blessing", () => {
|
|||
expect(feebas.hp).toBe(toDmgValue(0.5 * feebas.getMaxHp()));
|
||||
expect(game.scene.getPlayerField()[0]).toBe(feebas);
|
||||
});
|
||||
|
||||
it("should not summon multiple pokemon to the same slot when reviving the enemy ally in doubles", async () => {
|
||||
game.override
|
||||
.battleType("double")
|
||||
.enemyMoveset([ Moves.REVIVAL_BLESSING ])
|
||||
.moveset([ Moves.SPLASH ])
|
||||
.startingWave(25); // 2nd rival battle - must have 3+ pokemon
|
||||
await game.classicMode.startBattle([ Species.ARCEUS, Species.GIRATINA ]);
|
||||
|
||||
const enemyFainting = game.scene.getEnemyField()[0];
|
||||
|
||||
game.move.select(Moves.SPLASH, 0);
|
||||
game.move.select(Moves.SPLASH, 1);
|
||||
await game.killPokemon(enemyFainting);
|
||||
|
||||
await game.phaseInterceptor.to("BerryPhase");
|
||||
await game.toNextTurn();
|
||||
// If there are incorrectly two switch phases into this slot, the fainted pokemon will end up in slot 3
|
||||
// Make sure it's still in slot 1
|
||||
expect(game.scene.getEnemyParty()[0]).toBe(enemyFainting);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue