From 23b6ba8e432a23118b8730b7075cb4228ac65d96 Mon Sep 17 00:00:00 2001 From: Sirz Benjie <142067137+SirzBenjie@users.noreply.github.com> Date: Sun, 2 Feb 2025 13:00:04 -0600 Subject: [PATCH] Make spikes use leftmost magic bounce target --- src/data/move.ts | 3 ++- src/phases/move-effect-phase.ts | 14 ++------------ src/test/abilities/magic_bounce.test.ts | 13 ------------- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index acb0f65e54c..16b4e60300a 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -9148,7 +9148,8 @@ export function initMoves() { new AttackMove(Moves.SUPERPOWER, Type.FIGHTING, MoveCategory.PHYSICAL, 120, 100, 5, -1, 0, 3) .attr(StatStageChangeAttr, [ Stat.ATK, Stat.DEF ], -1, true), new SelfStatusMove(Moves.MAGIC_COAT, Type.PSYCHIC, -1, 15, -1, 4, 3) - .attr(AddBattlerTagAttr, BattlerTagType.MAGIC_COAT, true, false) + .attr(AddBattlerTagAttr, BattlerTagType.MAGIC_COAT, true, true, 0) + .condition(failIfLastCondition) // Interactions with stomping tantrum, instruct, and other moves that // rely on move history // Also will not reflect roar / whirlwind if the target has ForceSwitchOutImmunityAbAttr diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index 1a479688081..5a828dfc3fb 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -66,8 +66,6 @@ import { type nil } from "#app/utils"; import { BattlerTagType } from "#enums/battler-tag-type"; import type { Moves } from "#enums/moves"; import i18next from "i18next"; -import { Stat } from "#app/enums/stat"; -import { ArenaTagType } from "#app/enums/arena-tag-type"; import type { Phase } from "#app/phase"; import { ShowAbilityPhase } from "./show-ability-phase"; import { MovePhase } from "./move-phase"; @@ -222,23 +220,15 @@ export class MoveEffectPhase extends PokemonPhase { let hasHit: boolean = false; // Prevent ENEMY_SIDE targeted moves from occurring twice in double battles - // and determine which enemy will magic bounce based on speed order, respecting trick room + // and check which target will magic bounce. const trueTargets: Pokemon[] = move.moveTarget !== MoveTarget.ENEMY_SIDE ? targets : (() => { const magicCoatTargets = targets.filter(t => t.getTag(BattlerTagType.MAGIC_COAT) || t.hasAbilityWithAttr(ReflectStatusMoveAbAttr)); // only magic coat effect cares about order if (!mayBounce || magicCoatTargets.length === 0) { return [ targets[0] ]; - } else if (magicCoatTargets.length === 1) { - return magicCoatTargets; } - - // Filter the list of magic coat targets to those with the highest speed, or lowest if trick room is active. - const speeds = magicCoatTargets.map(p => p.getEffectiveStat(Stat.SPD) ?? 0); - const targetSpeed = globalScene.arena.hasTag(ArenaTagType.TRICK_ROOM) ? Math.min(...speeds) : Math.max(...speeds); - const filteredTargets = magicCoatTargets.filter((_, idx) => speeds[idx] === targetSpeed); - // In the event of a speed tie, choose a pokemon at random that will bounce the move. - return filteredTargets.length === 1 ? filteredTargets : [ filteredTargets[globalScene.randBattleSeedInt(filteredTargets.length)] ]; + return [ magicCoatTargets[0] ]; })(); const queuedPhases: Phase[] = []; diff --git a/src/test/abilities/magic_bounce.test.ts b/src/test/abilities/magic_bounce.test.ts index 818d66f4e11..0e7dafa784d 100644 --- a/src/test/abilities/magic_bounce.test.ts +++ b/src/test/abilities/magic_bounce.test.ts @@ -308,18 +308,5 @@ describe("Abilities - Magic Bounce", () => { await game.phaseInterceptor.to("BerryPhase"); expect(game.scene.arena.getTagOnSide(ArenaTagType.STICKY_WEB, ArenaTagSide.PLAYER)?.getSourcePokemon()?.getBattlerIndex()).toBe(BattlerIndex.ENEMY_2); }); - - it("should bounce back moves like spikes when the magic bounce user is semi-invulnerable", async () => { - await game.classicMode.startBattle([ Species.MAGIKARP ]); - game.override.moveset([ Moves.SPIKES ]); - game.override.enemyMoveset([ Moves.FLY ]); - - game.move.select(Moves.SPIKES); - await game.forceEnemyMove(Moves.FLY); - await game.setTurnOrder([ BattlerIndex.ENEMY, BattlerIndex.PLAYER ]); - await game.phaseInterceptor.to("BerryPhase"); - - expect(game.scene.arena.getTagOnSide(ArenaTagType.SPIKES, ArenaTagSide.PLAYER)!["layers"]).toBe(1); - }); });