pokerogue/src/test/battle/double_battle.test.ts

59 lines
1.9 KiB
TypeScript
Raw Normal View History

import { Status, StatusEffect } from "#app/data/status-effect";
import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { TurnInitPhase } from "#app/phases/turn-init-phase";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager";
import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("Double Battles", () => {
let phaserGame: Phaser.Game;
let game: GameManager;
beforeAll(() => {
phaserGame = new Phaser.Game({
type: Phaser.HEADLESS,
});
});
afterEach(() => {
game.phaseInterceptor.restoreOg();
});
beforeEach(() => {
game = new GameManager(phaserGame);
});
// double-battle player's pokemon both fainted in same round, then revive one, and next double battle summons two player's pokemon successfully.
// (There were bugs that either only summon one when can summon two, player stuck in switchPhase etc)
it("3v2 edge case: player summons 2 pokemon on the next battle after being fainted and revived", async () => {
game.override.battleType("double").enemyMoveset(Moves.SPLASH).moveset(Moves.SPLASH);
await game.startBattle([
Species.BULBASAUR,
Species.CHARIZARD,
Species.SQUIRTLE,
]);
game.move.select(Moves.SPLASH);
game.move.select(Moves.SPLASH, 1);
for (const pokemon of game.scene.getPlayerField()) {
pokemon.hp = 0;
pokemon.status = new Status(StatusEffect.FAINT);
expect(pokemon.isFainted()).toBe(true);
}
await game.doKillOpponents();
await game.phaseInterceptor.to(BattleEndPhase);
game.doSelectModifier();
const charizard = game.scene.getParty().findIndex(p => p.species.speciesId === Species.CHARIZARD);
game.doRevivePokemon(charizard);
await game.phaseInterceptor.to(TurnInitPhase);
expect(game.scene.getPlayerField().filter(p => !p.isFainted())).toHaveLength(2);
}, 20000);
});