diff --git a/src/data/ability.ts b/src/data/ability.ts index bb37cfda0e4..19fbab20aae 100644 --- a/src/data/ability.ts +++ b/src/data/ability.ts @@ -2748,8 +2748,6 @@ export class PreStatStageChangeAbAttr extends AbAttr { * Reflect all {@linkcode BattleStat} reductions caused by other Pokémon's moves and Abilities. * Currently only applies to Mirror Armor. */ -// TODO: CODE INTERACTION WITH MAGIC BOUNCE AS WELL -// TODO: CODE INTERACTION WITH STICKY WEB export class ReflectStatStageChangeAbAttr extends PreStatStageChangeAbAttr { /** {@linkcode BattleStat} to reflect */ private reflectedStat? : BattleStat; diff --git a/src/phases/move-effect-phase.ts b/src/phases/move-effect-phase.ts index 38a45c3258f..f55d1e671f4 100644 --- a/src/phases/move-effect-phase.ts +++ b/src/phases/move-effect-phase.ts @@ -90,7 +90,7 @@ export class MoveEffectPhase extends PokemonPhase { /** If an enemy used this move, set this as last enemy that used move or ability */ if (!user?.isPlayer()) { - /** If the move used was sticky web AND it was successful, save the id of pokemon that used it */ + /** If the move used was sticky web AND sticky web not already active, save the id of pokemon that used it */ if (this.move.moveId === 564 && user !== null && !this.scene.arena.hasTag(ArenaTagType.STICKY_WEB)) { this.scene.currentBattle.lastEnemyIDUsingStickyWeb = user.id; } diff --git a/src/phases/stat-stage-change-phase.ts b/src/phases/stat-stage-change-phase.ts index 4eb835cf3c3..09eb496a8f6 100644 --- a/src/phases/stat-stage-change-phase.ts +++ b/src/phases/stat-stage-change-phase.ts @@ -102,7 +102,6 @@ export class StatStageChangePhase extends PokemonPhase { if (!cancelled.value && !this.selfTarget && stages.value < 0) { applyPreStatStageChangeAbAttrs(ProtectStatAbAttr, pokemon, stat, cancelled, simulate); - // TODO: CODE INTERACTION WITH MAGIC BOUNCE AS WELL /** Potential stat reflection due to Mirror Armor, does not apply to Octolock end of turn effect */ if (opponentPokemon !== undefined && !pokemon.findTag(t => t instanceof OctolockTag) && !this.comingFromMirrorArmorUser) { applyPreStatStageChangeAbAttrs(ReflectStatStageChangeAbAttr, pokemon, stat, cancelled, simulate, opponentPokemon, this.stages); diff --git a/src/test/abilities/mirror_armor.test.ts b/src/test/abilities/mirror_armor.test.ts index 336a6fc42cd..556afa4b8db 100644 --- a/src/test/abilities/mirror_armor.test.ts +++ b/src/test/abilities/mirror_armor.test.ts @@ -1,5 +1,3 @@ -//test memnto as well and double battles and multiple stats and octolock -// test mirror armor infinite loop as well import { Stat } from "#enums/stat"; import { Abilities } from "#enums/abilities"; import { Moves } from "#enums/moves"; @@ -9,6 +7,8 @@ import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { BattlerIndex } from "#app/battle"; +// TODO: When Magic Bounce is implemented, make a test for its interaction with mirror guard, use screech + describe("Ability - Mirror Armor", () => { let phaserGame: Phaser.Game; let game: GameManager; @@ -28,10 +28,10 @@ describe("Ability - Mirror Armor", () => { game.override.battleType("single") .enemySpecies(Species.RATTATA) - .enemyMoveset([ Moves.SPLASH, Moves.MEMENTO, Moves.TICKLE, Moves.OCTOLOCK ]) + .enemyMoveset([ Moves.SPLASH, Moves.STICKY_WEB, Moves.TICKLE, Moves.OCTOLOCK ]) .enemyAbility(Abilities.BALL_FETCH) .startingLevel(2000) - .moveset([ Moves.SPLASH, Moves.MEMENTO, Moves.TICKLE, Moves.OCTOLOCK ]) + .moveset([ Moves.SPLASH, Moves.STICKY_WEB, Moves.TICKLE, Moves.OCTOLOCK ]) .ability(Abilities.BALL_FETCH); }); @@ -251,22 +251,65 @@ describe("Ability - Mirror Armor", () => { expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-1); }, 20000); - // it("traps the target pokemon", async () => { - // await game.classicMode.startBattle([ Species.GRAPPLOCT ]); + it("Both sides have mirror armor - does not loop, player loses attack", async () => { + game.override.enemyAbility(Abilities.MIRROR_ARMOR); + game.override.ability(Abilities.MIRROR_ARMOR); + game.override.ability(Abilities.INTIMIDATE); + await game.classicMode.startBattle([ Species.BULBASAUR ]); - // const enemyPokemon = game.scene.getEnemyPokemon()!; + const enemyPokemon = game.scene.getEnemyPokemon()!; + const userPokemon = game.scene.getPlayerPokemon()!; - // // before Octolock - enemy should not be trapped - // expect(enemyPokemon.findTag(t => t instanceof TrappedTag)).toBeUndefined(); + game.move.select(Moves.SPLASH); + await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER); + await game.toNextTurn(); - // game.move.select(Moves.OCTOLOCK); + expect(userPokemon.getStatStage(Stat.ATK)).toBe(-1); + expect(enemyPokemon.getStatStage(Stat.ATK)).toBe(0); + }, 20000); - // // after Octolock - enemy should be trapped - // await game.phaseInterceptor.to(MoveEndPhase); - // expect(enemyPokemon.findTag(t => t instanceof TrappedTag)).toBeDefined(); - // }); + it("Single battle + sticky web applied player side - player switches out and enemy should lose -1 speed", async () => { + game.override.ability(Abilities.MIRROR_ARMOR); + await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); -// TODO: Implement test for sticky web -// TODO: IMPLEMENT TEST FOR LOOPING MIRROR ARMORS BETWEEN OPPONENT AND PLAYER -// TODO: IMPLEMENT MAGIC GUARD INTERACITON TEST + const enemyPokemon = game.scene.getEnemyPokemon()!; + const userPokemon = game.scene.getPlayerPokemon()!; + + game.move.select(Moves.SPLASH); + await game.forceEnemyMove(Moves.STICKY_WEB, BattlerIndex.PLAYER); + await game.toNextTurn(); + + game.doSwitchPokemon(1); + await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER); + await game.toNextTurn(); + + expect(userPokemon.getStatStage(Stat.SPD)).toBe(0); + expect(enemyPokemon.getStatStage(Stat.SPD)).toBe(-1); + }, 20000); + + it("Double battle + sticky web applied player side - player switches out and enemy 1 should lose -1 speed", async () => { + game.override.battleType("double"); + game.override.ability(Abilities.MIRROR_ARMOR); + await game.classicMode.startBattle([ Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE ]); + + const [ enemy1, enemy2 ] = game.scene.getEnemyField(); + const [ player1, player2 ] = game.scene.getPlayerField(); + + game.move.select(Moves.SPLASH); + game.move.select(Moves.SPLASH, 1); + await game.forceEnemyMove(Moves.STICKY_WEB, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER_2); + await game.toNextTurn(); + + game.doSwitchPokemon(2); + game.move.select(Moves.SPLASH, 1); + await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER); + await game.forceEnemyMove(Moves.SPLASH, BattlerIndex.PLAYER_2); + await game.toNextTurn(); + + expect(enemy1.getStatStage(Stat.SPD)).toBe(-1); + expect(enemy2.getStatStage(Stat.SPD)).toBe(0); + expect(player1.getStatStage(Stat.SPD)).toBe(0); + expect(player2.getStatStage(Stat.SPD)).toBe(0); + }, 20000); });