pokerogue/src/test/moves/octolock.test.ts
Amani H. 89e80f3deb
[Refactor/Bug/Move] Overhaul Stats and Battle Items, Implement Several Stat Moves (#2699)
* Create Getters, Setters, and Types

* Work on `pokemon.ts`

* Adjust Types, Refactor `White Herb` Modifier

* Migrate `TempBattleStat` Usage

* Refactor `PokemonBaseStatModifier` Slightly

* Remove `BattleStat`, Use "Stat Stages" & New Names

* Address Phase `integers`

* Finalize `BattleStat` Removal

* Address Minor Manual NITs

* Apply Own Review Suggestions

* Fix Syntax Error

* Add Docs

* Overhaul X Items

* Implement Guard and Power Split with Unit Tests

* Add Several Unit Tests and Fixes

* Implement Speed Swap with Unit Tests

* Fix Keys in Summary Menu

* Fix Starf Berry Raising EVA and ACC

* Fix Contrary & Simple, Verify with Unit Tests

* Implement Power & Guard Swap with Unit Tests

* Add Move Effect Message to Speed Swap

* Add Move Effect Message to Power & Guard Split

* Add Localization Entries

* Adjust Last X Item Unit Test

* Overhaul X Items Unit Tests

* Finish Missing Docs

* Revamp Crit-Based Unit Tests & Dire Hit

* Address Initial NITs

* Apply NIT Batch

Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com>

* Fix Moody Test

* Address Multiple Messages for `ProtectStatAbAttr`

* Change `ignoreOverride` to `bypassSummonData`

* Adjust Italian Localization

Co-authored-by: Niccolò <123510358+NicusPulcis@users.noreply.github.com>

* Fix Moody

---------

Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com>
Co-authored-by: Niccolò <123510358+NicusPulcis@users.noreply.github.com>
2024-09-02 22:12:34 -04:00

118 lines
4.3 KiB
TypeScript

import { Stat } from "#enums/stat";
import { TrappedTag } from "#app/data/battler-tags";
import { CommandPhase } from "#app/phases/command-phase";
import { MoveEndPhase } from "#app/phases/move-end-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Moves - Octolock", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
game.override.battleType("single")
.enemySpecies(Species.RATTATA)
.enemyMoveset(SPLASH_ONLY)
.enemyAbility(Abilities.BALL_FETCH)
.startingLevel(2000)
.moveset([ Moves.OCTOLOCK, Moves.SPLASH ])
.ability(Abilities.BALL_FETCH);
});
it("lowers DEF and SPDEF stat stages of the target Pokemon by 1 each turn", { timeout: 10000 }, async () => {
await game.classicMode.startBattle([ Species.GRAPPLOCT ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
// use Octolock and advance to init phase of next turn to check for stat changes
game.move.select(Moves.OCTOLOCK);
await game.phaseInterceptor.to(TurnInitPhase);
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-1);
expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-1);
// take a second turn to make sure stat changes occur again
await game.phaseInterceptor.to(CommandPhase);
game.move.select(Moves.SPLASH);
await game.phaseInterceptor.to(TurnInitPhase);
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(-2);
expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-2);
});
it("if target pokemon has BIG_PECKS, should only lower SPDEF stat stage by 1", { timeout: 10000 }, async () => {
game.override.enemyAbility(Abilities.BIG_PECKS);
await game.classicMode.startBattle([ Species.GRAPPLOCT ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
// use Octolock and advance to init phase of next turn to check for stat changes
game.move.select(Moves.OCTOLOCK);
await game.phaseInterceptor.to(TurnInitPhase);
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(-1);
});
it("if target pokemon has WHITE_SMOKE, should not reduce any stat stages", { timeout: 10000 }, async () => {
game.override.enemyAbility(Abilities.WHITE_SMOKE);
await game.classicMode.startBattle([ Species.GRAPPLOCT ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
// use Octolock and advance to init phase of next turn to check for stat changes
game.move.select(Moves.OCTOLOCK);
await game.phaseInterceptor.to(TurnInitPhase);
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(0);
});
it("if target pokemon has CLEAR_BODY, should not reduce any stat stages", { timeout: 10000 }, async () => {
game.override.enemyAbility(Abilities.CLEAR_BODY);
await game.classicMode.startBattle([ Species.GRAPPLOCT ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
// use Octolock and advance to init phase of next turn to check for stat changes
game.move.select(Moves.OCTOLOCK);
await game.phaseInterceptor.to(TurnInitPhase);
expect(enemyPokemon.getStatStage(Stat.DEF)).toBe(0);
expect(enemyPokemon.getStatStage(Stat.SPDEF)).toBe(0);
});
it("traps the target pokemon", { timeout: 10000 }, async () => {
await game.classicMode.startBattle([ Species.GRAPPLOCT ]);
const enemyPokemon = game.scene.getEnemyPokemon()!;
// before Octolock - enemy should not be trapped
expect(enemyPokemon.findTag(t => t instanceof TrappedTag)).toBeUndefined();
game.move.select(Moves.OCTOLOCK);
// after Octolock - enemy should be trapped
await game.phaseInterceptor.to(MoveEndPhase);
expect(enemyPokemon.findTag(t => t instanceof TrappedTag)).toBeDefined();
});
});