From 817095d8950d75c062c7c41ecf24c2f3c1bfe2d3 Mon Sep 17 00:00:00 2001 From: Dean <69436131+emdeann@users.noreply.github.com> Date: Sun, 23 Mar 2025 13:47:51 -0700 Subject: [PATCH] [Bug] Fix #2769 Revival Blessing Softlock in doubles (#5141) * 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 --- src/data/moves/move.ts | 14 +++++++++++--- test/moves/revival_blessing.test.ts | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/data/moves/move.ts b/src/data/moves/move.ts index c7b5b4aec6b..9d470b86186 100644 --- a/src/data/moves/move.ts +++ b/src/data/moves/move.ts @@ -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)); } } diff --git a/test/moves/revival_blessing.test.ts b/test/moves/revival_blessing.test.ts index 187b5e62e76..1ceb850edea 100644 --- a/test/moves/revival_blessing.test.ts +++ b/test/moves/revival_blessing.test.ts @@ -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); + }); });