Make spikes use leftmost magic bounce target

This commit is contained in:
Sirz Benjie 2025-02-02 13:00:04 -06:00
parent acd27eb1da
commit 23b6ba8e43
No known key found for this signature in database
GPG Key ID: D4BFA840253CD6D7
3 changed files with 4 additions and 26 deletions

View File

@ -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

View File

@ -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[] = [];

View File

@ -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);
});
});