From 7197b8584f16b0d10ffafa9fbf86da381eb91e57 Mon Sep 17 00:00:00 2001 From: PrabbyDD Date: Tue, 19 Nov 2024 17:28:13 -0800 Subject: [PATCH] changing tests around and fixing the issue --- src/data/battler-tags.ts | 4 ---- src/test/battlerTags/octolock.test.ts | 29 +-------------------------- src/test/moves/octolock.test.ts | 22 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 32 deletions(-) diff --git a/src/data/battler-tags.ts b/src/data/battler-tags.ts index ce25b56157c..75b7cddb904 100644 --- a/src/data/battler-tags.ts +++ b/src/data/battler-tags.ts @@ -1085,10 +1085,6 @@ export class OctolockTag extends TrappedTag { super(BattlerTagType.OCTOLOCK, BattlerTagLapseType.TURN_END, 1, Moves.OCTOLOCK, sourceId); } - canAdd(pokemon: Pokemon): boolean { - return !pokemon.getTag(BattlerTagType.OCTOLOCK); - } - lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean { const shouldLapse = lapseType !== BattlerTagLapseType.CUSTOM || super.lapse(pokemon, lapseType); diff --git a/src/test/battlerTags/octolock.test.ts b/src/test/battlerTags/octolock.test.ts index ebd92dc6401..9efce220fe8 100644 --- a/src/test/battlerTags/octolock.test.ts +++ b/src/test/battlerTags/octolock.test.ts @@ -1,9 +1,8 @@ import BattleScene from "#app/battle-scene"; import { describe, expect, it, vi } from "vitest"; import Pokemon from "#app/field/pokemon"; -import { BattlerTag, BattlerTagLapseType, OctolockTag, TrappedTag } from "#app/data/battler-tags"; +import { BattlerTagLapseType, OctolockTag, TrappedTag } from "#app/data/battler-tags"; import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase"; -import { BattlerTagType } from "#app/enums/battler-tag-type"; import { Stat } from "#enums/stat"; vi.mock("#app/battle-scene.js"); @@ -33,30 +32,4 @@ describe("BattlerTag - OctolockTag", () => { it ("traps its target (extends TrappedTag)", async () => { expect(new OctolockTag(1)).toBeInstanceOf(TrappedTag); }); - - it("can be added to pokemon who are not octolocked", async => { - const mockPokemon = { - getTag: vi.fn().mockReturnValue(undefined) as Pokemon["getTag"], - } as Pokemon; - - const subject = new OctolockTag(1); - - expect(subject.canAdd(mockPokemon)).toBeTruthy(); - - expect(mockPokemon.getTag).toHaveBeenCalledTimes(1); - expect(mockPokemon.getTag).toHaveBeenCalledWith(BattlerTagType.OCTOLOCK); - }); - - it("cannot be added to pokemon who are octolocked", async => { - const mockPokemon = { - getTag: vi.fn().mockReturnValue(new BattlerTag(null!, null!, null!, null!)) as Pokemon["getTag"], - } as Pokemon; - - const subject = new OctolockTag(1); - - expect(subject.canAdd(mockPokemon)).toBeFalsy(); - - expect(mockPokemon.getTag).toHaveBeenCalledTimes(1); - expect(mockPokemon.getTag).toHaveBeenCalledWith(BattlerTagType.OCTOLOCK); - }); }); diff --git a/src/test/moves/octolock.test.ts b/src/test/moves/octolock.test.ts index d80b71a51e1..84815a5d7ae 100644 --- a/src/test/moves/octolock.test.ts +++ b/src/test/moves/octolock.test.ts @@ -9,6 +9,7 @@ import { Species } from "#enums/species"; import GameManager from "#test/utils/gameManager"; import Phaser from "phaser"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; +import { BattlerIndex } from "#app/battle"; describe("Moves - Octolock", () => { let phaserGame: Phaser.Game; @@ -113,4 +114,25 @@ describe("Moves - Octolock", () => { await game.phaseInterceptor.to(MoveEndPhase); expect(enemyPokemon.findTag(t => t instanceof TrappedTag)).toBeDefined(); }); + + it("does not work on ghost type pokemon", async () => { + game.override.enemySpecies(Species.GRAPPLOCT); + game.override.enemyMoveset(Moves.OCTOLOCK); + game.override.moveset(Moves.SPLASH); + await game.classicMode.startBattle([ Species.GASTLY ]); + + const playerPokemon = game.scene.getPlayerPokemon()!; + + // before Octolock - player should not be trapped + expect(playerPokemon.findTag(t => t instanceof TrappedTag)).toBeUndefined(); + + game.forceEnemyMove(Moves.OCTOLOCK, BattlerIndex.PLAYER); + game.move.select(Moves.OCTOLOCK); + game.toNextTurn(); + + // after Octolock - player should still not be trapped, and no stat loss + expect(playerPokemon.findTag(t => t instanceof TrappedTag)).toBeUndefined(); + expect(playerPokemon.getStatStage(Stat.DEF)).toBe(0); + expect(playerPokemon.getStatStage(Stat.SPDEF)).toBe(0); + }); });