2024-09-22 19:38:09 -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-09-22 19:38:09 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
|
|
|
|
describe("Abilities - Synchronize", () => {
|
|
|
|
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")
|
|
|
|
.startingLevel(100)
|
|
|
|
.enemySpecies(Species.MAGIKARP)
|
|
|
|
.enemyAbility(Abilities.SYNCHRONIZE)
|
2024-10-04 13:08:31 +08:00
|
|
|
.moveset([ Moves.SPLASH, Moves.THUNDER_WAVE, Moves.SPORE, Moves.PSYCHO_SHIFT ])
|
2024-09-22 19:38:09 -07:00
|
|
|
.ability(Abilities.NO_GUARD);
|
2024-11-03 18:53:52 -08:00
|
|
|
});
|
2024-09-22 19:38:09 -07:00
|
|
|
|
|
|
|
it("does not trigger when no status is applied by opponent Pokemon", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.FEEBAS ]);
|
2024-09-22 19:38:09 -07:00
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
|
2024-11-03 18:53:52 -08:00
|
|
|
expect(game.scene.getPlayerPokemon()!.status).toBeUndefined();
|
2024-09-22 19:38:09 -07:00
|
|
|
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
|
2024-11-03 18:53:52 -08:00
|
|
|
});
|
2024-09-22 19:38:09 -07:00
|
|
|
|
|
|
|
it("sets the status of the source pokemon to Paralysis when paralyzed by it", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.FEEBAS ]);
|
2024-09-22 19:38:09 -07:00
|
|
|
|
|
|
|
game.move.select(Moves.THUNDER_WAVE);
|
|
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
|
2024-11-03 18:53:52 -08:00
|
|
|
expect(game.scene.getPlayerPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS);
|
|
|
|
expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS);
|
2024-09-22 19:38:09 -07:00
|
|
|
expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase");
|
2024-11-03 18:53:52 -08:00
|
|
|
});
|
2024-09-22 19:38:09 -07:00
|
|
|
|
|
|
|
it("does not trigger on Sleep", async () => {
|
|
|
|
await game.classicMode.startBattle();
|
|
|
|
|
|
|
|
game.move.select(Moves.SPORE);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
|
2024-11-03 18:53:52 -08:00
|
|
|
expect(game.scene.getPlayerPokemon()!.status?.effect).toBeUndefined();
|
|
|
|
expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.SLEEP);
|
2024-09-22 19:38:09 -07:00
|
|
|
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
|
2024-11-03 18:53:52 -08:00
|
|
|
});
|
2024-09-22 19:38:09 -07:00
|
|
|
|
|
|
|
it("does not trigger when Pokemon is statused by Toxic Spikes", async () => {
|
|
|
|
game.override
|
|
|
|
.ability(Abilities.SYNCHRONIZE)
|
|
|
|
.enemyAbility(Abilities.BALL_FETCH)
|
|
|
|
.enemyMoveset(Array(4).fill(Moves.TOXIC_SPIKES));
|
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.FEEBAS, Species.MILOTIC ]);
|
2024-09-22 19:38:09 -07:00
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
game.doSwitchPokemon(1);
|
|
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
|
2024-11-03 18:53:52 -08:00
|
|
|
expect(game.scene.getPlayerPokemon()!.status?.effect).toBe(StatusEffect.POISON);
|
|
|
|
expect(game.scene.getEnemyPokemon()!.status?.effect).toBeUndefined();
|
2024-09-22 19:38:09 -07:00
|
|
|
expect(game.phaseInterceptor.log).not.toContain("ShowAbilityPhase");
|
2024-11-03 18:53:52 -08:00
|
|
|
});
|
2024-09-22 19:38:09 -07:00
|
|
|
|
|
|
|
it("shows ability even if it fails to set the status of the opponent Pokemon", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.classicMode.startBattle([ Species.PIKACHU ]);
|
2024-09-22 19:38:09 -07:00
|
|
|
|
|
|
|
game.move.select(Moves.THUNDER_WAVE);
|
|
|
|
await game.phaseInterceptor.to("BerryPhase");
|
|
|
|
|
2024-11-03 18:53:52 -08:00
|
|
|
expect(game.scene.getPlayerPokemon()!.status?.effect).toBeUndefined();
|
|
|
|
expect(game.scene.getEnemyPokemon()!.status?.effect).toBe(StatusEffect.PARALYSIS);
|
2024-09-22 19:38:09 -07:00
|
|
|
expect(game.phaseInterceptor.log).toContain("ShowAbilityPhase");
|
2024-11-03 18:53:52 -08:00
|
|
|
});
|
2024-09-22 19:38:09 -07:00
|
|
|
});
|