pokerogue/test/phases/form-change-phase.test.ts
Sirz Benjie 1029afcdbf
[Refactor] Remove circular dependencies (part 4) (#5964)
* Add abilityAttr.is methods

* [WIP] move modifier stuff around

* Untangle circular deps from modifiers

* Move unlockables to own file

* Untangle all circular deps outside of MEs

* Move constants in MEs to their own files

* Re-add missing import to battle.ts

* Add necessary overload for getTag

* Add missing type import in weather.ts

* Init modifier types and pools in loading-scene

* Remove stray commented code

* Apply kev's suggestions from code review

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
2025-06-11 19:42:04 -07:00

61 lines
2.1 KiB
TypeScript

import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id";
import { SpeciesId } from "#enums/species-id";
import GameManager from "#test/testUtils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
import { PokemonType } from "#enums/pokemon-type";
import { generateModifierType } from "#app/data/mystery-encounters/utils/encounter-phase-utils";
import { modifierTypes } from "#app/data/data-lists";
describe("Form Change Phase", () => {
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
.moveset([MoveId.SPLASH])
.ability(AbilityId.BALL_FETCH)
.battleStyle("single")
.disableCrits()
.enemySpecies(SpeciesId.MAGIKARP)
.enemyAbility(AbilityId.BALL_FETCH)
.enemyMoveset(MoveId.SPLASH);
});
it("Zacian should successfully change into Crowned form", async () => {
await game.classicMode.startBattle([SpeciesId.ZACIAN]);
// Before the form change: Should be Hero form
const zacian = game.scene.getPlayerParty()[0];
expect(zacian.getFormKey()).toBe("hero-of-many-battles");
expect(zacian.getTypes()).toStrictEqual([PokemonType.FAIRY]);
expect(zacian.calculateBaseStats()).toStrictEqual([92, 120, 115, 80, 115, 138]);
// Give Zacian a Rusted Sword
const rustedSwordType = generateModifierType(modifierTypes.RARE_FORM_CHANGE_ITEM)!;
const rustedSword = rustedSwordType.newModifier(zacian);
await game.scene.addModifier(rustedSword);
game.move.select(MoveId.SPLASH);
await game.toNextTurn();
// After the form change: Should be Crowned form
expect(game.phaseInterceptor.log.includes("FormChangePhase")).toBe(true);
expect(zacian.getFormKey()).toBe("crowned");
expect(zacian.getTypes()).toStrictEqual([PokemonType.FAIRY, PokemonType.STEEL]);
expect(zacian.calculateBaseStats()).toStrictEqual([92, 150, 115, 80, 115, 148]);
});
});