2024-08-22 06:49:33 -07:00
|
|
|
import { Status, StatusEffect } from "#app/data/status-effect";
|
|
|
|
import { BattleEndPhase } from "#app/phases/battle-end-phase";
|
|
|
|
import { TurnInitPhase } from "#app/phases/turn-init-phase";
|
2024-08-02 19:30:50 -07:00
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2024-08-22 06:49:33 -07:00
|
|
|
import GameManager from "#test/utils/gameManager";
|
2024-08-02 19:30:50 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
|
2024-08-11 21:54:42 -07:00
|
|
|
describe("Double Battles", () => {
|
2024-08-02 19:30:50 -07:00
|
|
|
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)
|
2024-08-22 06:49:33 -07:00
|
|
|
it("3v2 edge case: player summons 2 pokemon on the next battle after being fainted and revived", async () => {
|
2024-09-09 09:55:11 -07:00
|
|
|
game.override.battleType("double").enemyMoveset(Moves.SPLASH).moveset(Moves.SPLASH);
|
2024-08-02 19:30:50 -07:00
|
|
|
await game.startBattle([
|
|
|
|
Species.BULBASAUR,
|
|
|
|
Species.CHARIZARD,
|
|
|
|
Species.SQUIRTLE,
|
|
|
|
]);
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
game.move.select(Moves.SPLASH, 1);
|
2024-08-02 19:30:50 -07:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|