From 6e1230ff6d23c8770b4a4c3adf60fd1e1dda87b7 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Sun, 2 Feb 2025 16:41:08 -0600 Subject: [PATCH] Fix magic bounce semi-invulnerable interaction This was based on smogon's incorrect handling of this situation --- src/phases/move-effect-phase.ts | 8 +------- src/test/abilities/magic_bounce.test.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index d14adf416f9..c694bad72fa 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -674,7 +674,6 @@ export class MoveEffectPhase extends PokemonPhase { * - An ability like {@linkcode Abilities.NO_GUARD | No Guard} * - A poison type using {@linkcode Moves.TOXIC | Toxic} * - A move like {@linkcode Moves.LOCK_ON | Lock-On} or {@linkcode Moves.MIND_READER | Mind Reader}. - * - A move like {@linkcode Moves.SPIEKS | Spikes} or {@linkcode Moves.SANDSTORM | Sandstorm} that targets the field * * Does *not* check against effects {@linkcode Moves.GLAIVE_RUSH | Glaive Rush} status (which * should not bypass semi-invulnerability), or interactions like Earthquake hitting against Dig, @@ -687,9 +686,6 @@ export class MoveEffectPhase extends PokemonPhase { if (!user) { return false; } - if ([ MoveTarget.USER, MoveTarget.ENEMY_SIDE, MoveTarget.USER_SIDE, MoveTarget.BOTH_SIDES ].includes(this.move.getMove().moveTarget)) { - return true; - } if (user.hasAbilityWithAttr(AlwaysHitAbAttr) || target.hasAbilityWithAttr(AlwaysHitAbAttr)) { return true; } @@ -712,9 +708,7 @@ export class MoveEffectPhase extends PokemonPhase { return false; } const move = this.move.getMove(); - /** Does the move target the field instead of the target itself? */ - const isIndirectTarget = move.moveTarget in [ MoveTarget.USER, MoveTarget.ENEMY_SIDE, MoveTarget.USER_SIDE, MoveTarget.BOTH_SIDES ]; - return isIndirectTarget || move.getAttrs(HitsTagAttr).some(hta => hta.tagType === semiInvulnerableTag.tagType); + return move.getAttrs(HitsTagAttr).some(hta => hta.tagType === semiInvulnerableTag.tagType); } /** @returns The {@linkcode Pokemon} using this phase's invoked move */ diff --git a/src/test/abilities/magic_bounce.test.ts b/src/test/abilities/magic_bounce.test.ts index 502b4369cd8..01f94712bb5 100644 --- a/src/test/abilities/magic_bounce.test.ts +++ b/src/test/abilities/magic_bounce.test.ts @@ -149,6 +149,17 @@ describe("Abilities - Magic Bounce", () => { expect(game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.PLAYER)!["layers"]).toBe(1); }); + it("should not bounce spikes when the target is in the semi-invulnerable state", async () => { + game.override.moveset([ Moves.SPIKES ]); + game.override.enemyMoveset([ Moves.FLY ]); + await game.classicMode.startBattle([ Species.MAGIKARP ]); + + game.move.select(Moves.SPIKES); + await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); + await game.phaseInterceptor.to("BerryPhase"); + expect(game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.ENEMY)!["layers"]).toBe(1); + }); + it("should not bounce back curse", async() => { game.override.starterSpecies(Species.GASTLY); await game.classicMode.startBattle([ Species.GASTLY ]);