2024-11-08 14:44:34 -08:00
|
|
|
import { Status } from "#app/data/status-effect";
|
2024-08-22 06:49:33 -07:00
|
|
|
import { QuietFormChangePhase } from "#app/phases/quiet-form-change-phase";
|
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
2024-07-25 16:03:26 -07:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2024-11-08 14:44:34 -08:00
|
|
|
import { StatusEffect } from "#enums/status-effect";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-08-13 14:14:49 -07:00
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
2024-06-13 05:36:12 -04:00
|
|
|
|
2024-09-20 14:05:45 -07:00
|
|
|
|
2024-06-13 05:36:12 -04:00
|
|
|
describe("Abilities - ZERO TO HERO", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
2024-08-13 14:14:49 -07:00
|
|
|
const baseForm = 0;
|
|
|
|
const heroForm = 1;
|
2024-06-13 05:36:12 -04:00
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
2024-08-13 14:14:49 -07:00
|
|
|
game.override
|
|
|
|
.battleType("single")
|
2024-09-09 09:55:11 -07:00
|
|
|
.moveset(Moves.SPLASH)
|
|
|
|
.enemyMoveset(Moves.SPLASH)
|
2024-08-13 14:14:49 -07:00
|
|
|
.enemyAbility(Abilities.BALL_FETCH);
|
2024-06-13 05:36:12 -04:00
|
|
|
});
|
|
|
|
|
2024-08-13 14:14:49 -07:00
|
|
|
it("should swap to base form on arena reset", async () => {
|
|
|
|
game.override.startingWave(4);
|
|
|
|
game.override.starterForms({
|
|
|
|
[Species.PALAFIN]: heroForm,
|
|
|
|
});
|
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.FEEBAS, Species.PALAFIN, Species.PALAFIN ]);
|
2024-08-13 14:14:49 -07:00
|
|
|
|
2024-11-03 18:53:52 -08:00
|
|
|
const palafin1 = game.scene.getPlayerParty()[1];
|
|
|
|
const palafin2 = game.scene.getPlayerParty()[2];
|
2024-08-13 14:14:49 -07:00
|
|
|
expect(palafin1.formIndex).toBe(heroForm);
|
|
|
|
expect(palafin2.formIndex).toBe(heroForm);
|
|
|
|
palafin2.hp = 0;
|
|
|
|
palafin2.status = new Status(StatusEffect.FAINT);
|
|
|
|
expect(palafin2.isFainted()).toBe(true);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.SPLASH);
|
2024-08-13 14:14:49 -07:00
|
|
|
await game.doKillOpponents();
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
game.doSelectModifier();
|
|
|
|
await game.phaseInterceptor.to(QuietFormChangePhase);
|
|
|
|
await game.phaseInterceptor.to(QuietFormChangePhase);
|
|
|
|
|
|
|
|
expect(palafin1.formIndex).toBe(baseForm);
|
|
|
|
expect(palafin2.formIndex).toBe(baseForm);
|
2024-09-20 14:05:45 -07:00
|
|
|
});
|
2024-08-13 14:14:49 -07:00
|
|
|
|
|
|
|
it("should swap to Hero form when switching out during a battle", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.PALAFIN, Species.FEEBAS ]);
|
2024-08-13 14:14:49 -07:00
|
|
|
|
|
|
|
const palafin = game.scene.getPlayerPokemon()!;
|
|
|
|
expect(palafin.formIndex).toBe(baseForm);
|
|
|
|
|
|
|
|
game.doSwitchPokemon(1);
|
|
|
|
await game.phaseInterceptor.to(QuietFormChangePhase);
|
|
|
|
expect(palafin.formIndex).toBe(heroForm);
|
2024-09-20 14:05:45 -07:00
|
|
|
});
|
2024-08-13 14:14:49 -07:00
|
|
|
|
|
|
|
it("should not swap to Hero form if switching due to faint", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.PALAFIN, Species.FEEBAS ]);
|
2024-08-13 14:14:49 -07:00
|
|
|
|
|
|
|
const palafin = game.scene.getPlayerPokemon()!;
|
|
|
|
expect(palafin.formIndex).toBe(baseForm);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.SPLASH);
|
2024-08-13 14:14:49 -07:00
|
|
|
await game.killPokemon(palafin);
|
|
|
|
game.doSelectPartyPokemon(1);
|
|
|
|
await game.toNextTurn();
|
|
|
|
expect(palafin.formIndex).toBe(baseForm);
|
2024-09-20 14:05:45 -07:00
|
|
|
});
|
2024-08-13 14:14:49 -07:00
|
|
|
|
|
|
|
it("should stay hero form if fainted and then revived", async () => {
|
|
|
|
game.override.starterForms({
|
|
|
|
[Species.PALAFIN]: heroForm,
|
|
|
|
});
|
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.PALAFIN, Species.FEEBAS ]);
|
2024-08-13 14:14:49 -07:00
|
|
|
|
|
|
|
const palafin = game.scene.getPlayerPokemon()!;
|
|
|
|
expect(palafin.formIndex).toBe(heroForm);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.SPLASH);
|
2024-08-13 14:14:49 -07:00
|
|
|
await game.killPokemon(palafin);
|
|
|
|
game.doSelectPartyPokemon(1);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
game.doRevivePokemon(1);
|
|
|
|
game.doSwitchPokemon(1);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
expect(palafin.formIndex).toBe(heroForm);
|
2024-09-20 14:05:45 -07:00
|
|
|
});
|
2024-06-13 05:36:12 -04:00
|
|
|
});
|