2024-07-30 22:06:31 +08:00
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
import Phaser from "phaser";
|
2024-08-06 07:06:25 -07:00
|
|
|
import GameManager from "#test/utils/gameManager";
|
2024-07-30 22:06:31 +08:00
|
|
|
import { Species } from "#enums/species";
|
|
|
|
import { Moves } from "#enums/moves";
|
2024-08-06 07:06:25 -07:00
|
|
|
import { getMovePosition } from "#test/utils/gameManagerUtils";
|
2024-07-30 22:06:31 +08:00
|
|
|
import { StatusEffect } from "#app/data/status-effect.js";
|
|
|
|
import { allAbilities } from "#app/data/ability.js";
|
|
|
|
import { Abilities } from "#app/enums/abilities.js";
|
|
|
|
import { BattlerIndex } from "#app/battle.js";
|
2024-08-19 03:23:52 +01:00
|
|
|
import { CommandPhase } from "#app/phases/command-phase.js";
|
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
|
2024-07-30 22:06:31 +08:00
|
|
|
|
|
|
|
describe("Abilities - Pastel Veil", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
2024-08-06 07:06:25 -07:00
|
|
|
game.override.battleType("double");
|
|
|
|
game.override.moveset([Moves.SPLASH]);
|
|
|
|
game.override.enemyAbility(Abilities.BALL_FETCH);
|
|
|
|
game.override.enemySpecies(Species.MAGIKARP);
|
|
|
|
game.override.enemyMoveset([Moves.TOXIC_THREAD, Moves.TOXIC_THREAD, Moves.TOXIC_THREAD, Moves.TOXIC_THREAD]);
|
2024-07-30 22:06:31 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it("prevents the user and its allies from being afflicted by poison", async () => {
|
|
|
|
await game.startBattle([Species.GALAR_PONYTA, Species.MAGIKARP]);
|
|
|
|
const ponyta = game.scene.getPlayerField()[0];
|
|
|
|
|
|
|
|
vi.spyOn(ponyta, "getAbility").mockReturnValue(allAbilities[Abilities.PASTEL_VEIL]);
|
|
|
|
|
|
|
|
expect(ponyta.hasAbility(Abilities.PASTEL_VEIL)).toBe(true);
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
|
|
|
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
expect(game.scene.getPlayerField().every(p => p.status?.effect)).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("it heals the poisoned status condition of allies if user is sent out into battle", async () => {
|
|
|
|
await game.startBattle([Species.MAGIKARP, Species.MAGIKARP, Species.GALAR_PONYTA]);
|
2024-08-07 09:23:12 -07:00
|
|
|
const ponyta = game.scene.getParty().find(p => p.species.speciesId === Species.GALAR_PONYTA)!;
|
2024-07-30 22:06:31 +08:00
|
|
|
|
|
|
|
vi.spyOn(ponyta, "getAbility").mockReturnValue(allAbilities[Abilities.PASTEL_VEIL]);
|
|
|
|
|
|
|
|
expect(ponyta.hasAbility(Abilities.PASTEL_VEIL)).toBe(true);
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.SPLASH));
|
|
|
|
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
expect(game.scene.getPlayerField().some(p => p.status?.effect === StatusEffect.POISON)).toBe(true);
|
|
|
|
|
|
|
|
const poisonedMon = game.scene.getPlayerField().find(p => p.status?.effect === StatusEffect.POISON);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(CommandPhase);
|
2024-08-07 09:23:12 -07:00
|
|
|
game.doAttack(getMovePosition(game.scene, (poisonedMon!.getBattlerIndex() as BattlerIndex.PLAYER | BattlerIndex.PLAYER_2), Moves.SPLASH));
|
2024-07-30 22:06:31 +08:00
|
|
|
game.doSwitchPokemon(2);
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
expect(game.scene.getPlayerField().every(p => p.status?.effect)).toBe(false);
|
|
|
|
});
|
|
|
|
});
|