2024-07-25 16:10:38 -07:00
|
|
|
import { BattleStat } from "#app/data/battle-stat.js";
|
2024-06-27 12:21:24 -07:00
|
|
|
import {
|
2024-08-04 22:19:49 -07:00
|
|
|
MoveEffectPhase,
|
2024-06-27 12:21:24 -07:00
|
|
|
MoveEndPhase,
|
2024-06-27 16:52:13 -07:00
|
|
|
StatChangePhase,
|
2024-06-27 12:21:24 -07:00
|
|
|
} from "#app/phases";
|
2024-07-25 16:10:38 -07:00
|
|
|
import GameManager from "#app/test/utils/gameManager";
|
2024-06-27 12:21:24 -07:00
|
|
|
import { getMovePosition } from "#app/test/utils/gameManagerUtils";
|
|
|
|
import { Abilities } from "#enums/abilities";
|
2024-07-25 16:10:38 -07:00
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
|
|
|
import Phaser from "phaser";
|
2024-08-04 22:19:49 -07:00
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
2024-07-25 15:18:14 -07:00
|
|
|
import { SPLASH_ONLY } from "../utils/testUtils";
|
2024-06-27 12:21:24 -07:00
|
|
|
|
2024-06-29 10:59:26 -07:00
|
|
|
const TIMEOUT = 20 * 1000;
|
|
|
|
|
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-07-25 15:51:05 -07: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-07-25 15:18:14 -07:00
|
|
|
game.override.enemyMoveset(SPLASH_ONLY);
|
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
|
|
|
});
|
|
|
|
|
|
|
|
it("should only reduce Sp. Atk. once in a double battle", async () => {
|
|
|
|
await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]);
|
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.MAKE_IT_RAIN));
|
|
|
|
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(MoveEndPhase);
|
|
|
|
|
|
|
|
expect(playerPokemon[0].summonData.battleStats[BattleStat.SPATK]).toBe(-1);
|
2024-06-29 10:59:26 -07:00
|
|
|
}, TIMEOUT);
|
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
|
|
|
|
|
|
|
await game.startBattle([Species.CHARIZARD]);
|
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerPokemon();
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon();
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.MAKE_IT_RAIN));
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(StatChangePhase);
|
|
|
|
|
|
|
|
expect(enemyPokemon.isFainted()).toBe(true);
|
|
|
|
expect(playerPokemon.summonData.battleStats[BattleStat.SPATK]).toBe(-1);
|
2024-06-29 10:59:26 -07:00
|
|
|
}, TIMEOUT);
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]);
|
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.MAKE_IT_RAIN));
|
|
|
|
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(StatChangePhase);
|
|
|
|
|
|
|
|
enemyPokemon.forEach(p => expect(p.isFainted()).toBe(true));
|
|
|
|
expect(playerPokemon[0].summonData.battleStats[BattleStat.SPATK]).toBe(-1);
|
|
|
|
}, TIMEOUT);
|
2024-08-04 22:19:49 -07:00
|
|
|
|
|
|
|
it("should reduce Sp. Atk if it only hits the second target", async () => {
|
|
|
|
await game.startBattle([Species.CHARIZARD, Species.BLASTOISE]);
|
|
|
|
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.MAKE_IT_RAIN));
|
|
|
|
game.doAttack(getMovePosition(game.scene, 1, Moves.SPLASH));
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(MoveEffectPhase, false);
|
|
|
|
|
|
|
|
// Make Make It Rain miss the first target
|
|
|
|
const moveEffectPhase = game.scene.getCurrentPhase() as MoveEffectPhase;
|
|
|
|
vi.spyOn(moveEffectPhase, "hitCheck").mockReturnValueOnce(false);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(MoveEndPhase);
|
|
|
|
|
|
|
|
expect(playerPokemon[0].summonData.battleStats[BattleStat.SPATK]).toBe(-1);
|
|
|
|
}, TIMEOUT);
|
2024-06-27 12:21:24 -07:00
|
|
|
});
|