mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-03 16:38:23 +00:00
* Optimize Unit tests - Battery - Unseen Fist - Rage Powder - Follow Me - Spotlight - Power Spot * Fix Screen Cleaner unit test bug
109 lines
4.3 KiB
TypeScript
109 lines
4.3 KiB
TypeScript
import {afterEach, beforeAll, beforeEach, describe, expect, test, vi} from "vitest";
|
|
import Phaser from "phaser";
|
|
import GameManager from "#app/test/utils/gameManager";
|
|
import * as overrides from "#app/overrides";
|
|
import {
|
|
CommandPhase,
|
|
SelectTargetPhase,
|
|
TurnEndPhase,
|
|
} from "#app/phases";
|
|
import {getMovePosition} from "#app/test/utils/gameManagerUtils";
|
|
import { Abilities } from "#enums/abilities";
|
|
import { Moves } from "#enums/moves";
|
|
import { Species } from "#enums/species";
|
|
import { BattlerIndex } from "#app/battle.js";
|
|
|
|
const TIMEOUT = 20 * 1000;
|
|
|
|
describe("Moves - Rage Powder", () => {
|
|
let phaserGame: Phaser.Game;
|
|
let game: GameManager;
|
|
|
|
beforeAll(() => {
|
|
phaserGame = new Phaser.Game({
|
|
type: Phaser.HEADLESS,
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
game.phaseInterceptor.restoreOg();
|
|
});
|
|
|
|
beforeEach(() => {
|
|
game = new GameManager(phaserGame);
|
|
vi.spyOn(overrides, "DOUBLE_BATTLE_OVERRIDE", "get").mockReturnValue(true);
|
|
vi.spyOn(overrides, "STARTER_SPECIES_OVERRIDE", "get").mockReturnValue(Species.AMOONGUSS);
|
|
vi.spyOn(overrides, "OPP_SPECIES_OVERRIDE", "get").mockReturnValue(Species.SNORLAX);
|
|
vi.spyOn(overrides, "STARTING_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
|
vi.spyOn(overrides, "OPP_LEVEL_OVERRIDE", "get").mockReturnValue(100);
|
|
vi.spyOn(overrides, "MOVESET_OVERRIDE", "get").mockReturnValue([ Moves.FOLLOW_ME, Moves.RAGE_POWDER, Moves.SPOTLIGHT, Moves.QUICK_ATTACK ]);
|
|
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([Moves.TACKLE,Moves.TACKLE,Moves.TACKLE,Moves.TACKLE]);
|
|
});
|
|
|
|
test(
|
|
"move effect should be bypassed by Grass type",
|
|
async () => {
|
|
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([ Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER ]);
|
|
|
|
await game.startBattle([ Species.AMOONGUSS, Species.VENUSAUR ]);
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
expect(playerPokemon.length).toBe(2);
|
|
playerPokemon.forEach(p => expect(p).not.toBe(undefined));
|
|
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
expect(enemyPokemon.length).toBe(2);
|
|
enemyPokemon.forEach(p => expect(p).not.toBe(undefined));
|
|
|
|
enemyPokemon.forEach(p => p.hp = 200);
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK));
|
|
await game.phaseInterceptor.to(SelectTargetPhase, false);
|
|
game.doSelectTarget(BattlerIndex.ENEMY);
|
|
await game.phaseInterceptor.to(CommandPhase);
|
|
|
|
game.doAttack(getMovePosition(game.scene, 1, Moves.QUICK_ATTACK));
|
|
await game.phaseInterceptor.to(SelectTargetPhase, false);
|
|
game.doSelectTarget(BattlerIndex.ENEMY_2);
|
|
await game.phaseInterceptor.to(TurnEndPhase, false);
|
|
|
|
// If redirection was bypassed, both enemies should be damaged
|
|
enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(200));
|
|
}, TIMEOUT
|
|
);
|
|
|
|
test(
|
|
"move effect should be bypassed by Overcoat",
|
|
async () => {
|
|
vi.spyOn(overrides, "ABILITY_OVERRIDE", "get").mockReturnValue(Abilities.OVERCOAT);
|
|
vi.spyOn(overrides, "OPP_MOVESET_OVERRIDE", "get").mockReturnValue([ Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER, Moves.RAGE_POWDER ]);
|
|
|
|
// Test with two non-Grass type player Pokemon
|
|
await game.startBattle([ Species.BLASTOISE, Species.CHARIZARD ]);
|
|
|
|
const playerPokemon = game.scene.getPlayerField();
|
|
expect(playerPokemon.length).toBe(2);
|
|
playerPokemon.forEach(p => expect(p).not.toBe(undefined));
|
|
|
|
const enemyPokemon = game.scene.getEnemyField();
|
|
expect(enemyPokemon.length).toBe(2);
|
|
enemyPokemon.forEach(p => expect(p).not.toBe(undefined));
|
|
|
|
enemyPokemon.forEach(p => p.hp = 200);
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.QUICK_ATTACK));
|
|
await game.phaseInterceptor.to(SelectTargetPhase, false);
|
|
game.doSelectTarget(BattlerIndex.ENEMY);
|
|
await game.phaseInterceptor.to(CommandPhase);
|
|
|
|
game.doAttack(getMovePosition(game.scene, 1, Moves.QUICK_ATTACK));
|
|
await game.phaseInterceptor.to(SelectTargetPhase, false);
|
|
game.doSelectTarget(BattlerIndex.ENEMY_2);
|
|
await game.phaseInterceptor.to(TurnEndPhase, false);
|
|
|
|
// If redirection was bypassed, both enemies should be damaged
|
|
enemyPokemon.forEach(p => expect(p.hp).toBeLessThan(200));
|
|
}, TIMEOUT
|
|
);
|
|
});
|