pokerogue/test/phases/form-change-phase.test.ts
Bertie690 8734062401
[Test] Cleaned up tests to use updated test utils; part 1 (#6176)
* Removed bangs from `getEnemyParty` and `getPlayerParty`

* Replaced instances of consecutive `game.scene.getPlayerParty` with destructuring

* More array destructuring!!!

* Replaced `game.scene.getXXXParty()[0]` with `game.field.getEnemyPokemon`

* Deleted duplicate sturdy test case

* Fiexd syntax errors

* Fixed remaining issues; removed direct assignment to `Pokemon.moveset`

* Fixed remaining error
2025-08-19 19:21:40 -05:00

61 lines
2.1 KiB
TypeScript

import { modifierTypes } from "#data/data-lists";
import { AbilityId } from "#enums/ability-id";
import { MoveId } from "#enums/move-id";
import { PokemonType } from "#enums/pokemon-type";
import { SpeciesId } from "#enums/species-id";
import { generateModifierType } from "#mystery-encounters/encounter-phase-utils";
import { GameManager } from "#test/test-utils/game-manager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
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")
.criticalHits(false)
.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.field.getPlayerPokemon();
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]);
});
});