mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2024-11-25 08:16:04 +00:00
changing tests around and fixing the issue
This commit is contained in:
parent
6442b8345f
commit
7197b8584f
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user