2024-09-02 22:12:34 -04:00
|
|
|
import { Stat } from "#enums/stat";
|
2024-06-27 12:21:24 -07:00
|
|
|
import { Abilities } from "#enums/abilities";
|
2024-07-25 16:10:38 -07:00
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-07-25 16:10:38 -07:00
|
|
|
import Phaser from "phaser";
|
2024-08-09 22:37:10 +08:00
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
2024-09-02 22:12:34 -04:00
|
|
|
import { MoveEndPhase } from "#app/phases/move-end-phase";
|
|
|
|
import { StatStageChangePhase } from "#app/phases/stat-stage-change-phase";
|
2024-06-27 12:21:24 -07:00
|
|
|
|
2024-09-20 14:05:45 -07:00
|
|
|
|
2024-06-27 12:21:24 -07:00
|
|
|
describe("Moves - Make It Rain", () => {
|
|
|
|
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-07-25 14:48:48 -07:00
|
|
|
game.override.battleType("double");
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.moveset([ Moves.MAKE_IT_RAIN, Moves.SPLASH ]);
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(Species.SNORLAX);
|
2024-07-25 15:05:32 -07:00
|
|
|
game.override.enemyAbility(Abilities.INSOMNIA);
|
2024-09-09 09:55:11 -07:00
|
|
|
game.override.enemyMoveset(Moves.SPLASH);
|
2024-07-25 15:29:19 -07:00
|
|
|
game.override.startingLevel(100);
|
2024-07-25 16:10:38 -07:00
|
|
|
game.override.enemyLevel(100);
|
2024-06-27 12:21:24 -07:00
|
|
|
});
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
it("should only lower SPATK stat stage by 1 once in a double battle", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]);
|
2024-06-27 12:21:24 -07:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
2024-06-27 12:21:24 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.MAKE_IT_RAIN);
|
|
|
|
game.move.select(Moves.SPLASH, 1);
|
2024-06-27 12:21:24 -07:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(MoveEndPhase);
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(-1);
|
2024-09-20 14:05:45 -07:00
|
|
|
});
|
2024-06-27 16:52:13 -07:00
|
|
|
|
|
|
|
it("should apply effects even if the target faints", async () => {
|
2024-07-25 16:10:38 -07:00
|
|
|
game.override.enemyLevel(1); // ensures the enemy will faint
|
2024-07-25 14:48:48 -07:00
|
|
|
game.override.battleType("single");
|
2024-06-27 16:52:13 -07:00
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.CHARIZARD ]);
|
2024-06-27 16:52:13 -07:00
|
|
|
|
2024-08-07 09:23:12 -07:00
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
2024-06-27 16:52:13 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.MAKE_IT_RAIN);
|
2024-06-27 16:52:13 -07:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
await game.phaseInterceptor.to(StatStageChangePhase);
|
2024-06-27 16:52:13 -07:00
|
|
|
|
|
|
|
expect(enemyPokemon.isFainted()).toBe(true);
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(-1);
|
2024-09-20 14:05:45 -07:00
|
|
|
});
|
2024-06-29 10:59:26 -07:00
|
|
|
|
|
|
|
it("should reduce Sp. Atk. once after KOing two enemies", async () => {
|
2024-07-25 16:10:38 -07:00
|
|
|
game.override.enemyLevel(1); // ensures the enemy will faint
|
2024-06-29 10:59:26 -07:00
|
|
|
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]);
|
2024-06-29 10:59:26 -07:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
2024-06-29 10:59:26 -07:00
|
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.MAKE_IT_RAIN);
|
|
|
|
game.move.select(Moves.SPLASH, 1);
|
2024-06-29 10:59:26 -07:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
await game.phaseInterceptor.to(StatStageChangePhase);
|
2024-06-29 10:59:26 -07:00
|
|
|
|
|
|
|
enemyPokemon.forEach(p => expect(p.isFainted()).toBe(true));
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(-1);
|
2024-09-20 14:05:45 -07:00
|
|
|
});
|
2024-08-04 22:19:49 -07:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
it("should lower SPATK stat stage by 1 if it only hits the second target", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.CHARIZARD, Species.BLASTOISE ]);
|
2024-08-04 22:19:49 -07:00
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
2024-08-04 22:19:49 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.MAKE_IT_RAIN);
|
|
|
|
game.move.select(Moves.SPLASH, 1);
|
2024-08-04 22:19:49 -07:00
|
|
|
|
|
|
|
// Make Make It Rain miss the first target
|
2024-08-09 22:37:10 +08:00
|
|
|
await game.move.forceMiss(true);
|
2024-08-04 22:19:49 -07:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(MoveEndPhase);
|
|
|
|
|
2024-09-02 22:12:34 -04:00
|
|
|
expect(playerPokemon.getStatStage(Stat.SPATK)).toBe(-1);
|
2024-09-20 14:05:45 -07:00
|
|
|
});
|
2024-06-27 12:21:24 -07:00
|
|
|
});
|