2024-08-22 06:49:33 -07:00
|
|
|
import { BattlerIndex } from "#app/battle";
|
|
|
|
import { allMoves } from "#app/data/move";
|
|
|
|
import { BattleEndPhase } from "#app/phases/battle-end-phase";
|
|
|
|
import { BerryPhase } from "#app/phases/berry-phase";
|
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
2024-08-07 17:44:34 -07:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, test, vi } from "vitest";
|
|
|
|
import GameManager from "../utils/gameManager";
|
2024-08-22 06:49:33 -07:00
|
|
|
import { SPLASH_ONLY } from "../utils/testUtils";
|
2024-08-07 17:44:34 -07:00
|
|
|
|
|
|
|
const TIMEOUT = 20 * 1000;
|
|
|
|
|
|
|
|
describe("Moves - Dragon Tail", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
|
|
|
game.override.battleType("single")
|
|
|
|
.moveset([Moves.DRAGON_TAIL, Moves.SPLASH])
|
|
|
|
.enemySpecies(Species.WAILORD)
|
|
|
|
.enemyMoveset(SPLASH_ONLY)
|
|
|
|
.startingLevel(5)
|
|
|
|
.enemyLevel(5);
|
|
|
|
|
|
|
|
vi.spyOn(allMoves[Moves.DRAGON_TAIL], "accuracy", "get").mockReturnValue(100);
|
|
|
|
});
|
|
|
|
|
|
|
|
test(
|
|
|
|
"Single battle should cause opponent to flee, and not crash",
|
|
|
|
async () => {
|
|
|
|
await game.startBattle([Species.DRATINI]);
|
|
|
|
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.DRAGON_TAIL);
|
2024-08-07 17:44:34 -07:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(BerryPhase);
|
|
|
|
|
|
|
|
const isVisible = enemyPokemon.visible;
|
|
|
|
const hasFled = enemyPokemon.wildFlee;
|
|
|
|
expect(!isVisible && hasFled).toBe(true);
|
|
|
|
|
|
|
|
// simply want to test that the game makes it this far without crashing
|
|
|
|
await game.phaseInterceptor.to(BattleEndPhase);
|
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
|
|
|
"Single battle should cause opponent to flee, display ability, and not crash",
|
|
|
|
async () => {
|
|
|
|
game.override.enemyAbility(Abilities.ROUGH_SKIN);
|
|
|
|
await game.startBattle([Species.DRATINI]);
|
|
|
|
|
|
|
|
const leadPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.DRAGON_TAIL);
|
2024-08-07 17:44:34 -07:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(BerryPhase);
|
|
|
|
|
|
|
|
const isVisible = enemyPokemon.visible;
|
|
|
|
const hasFled = enemyPokemon.wildFlee;
|
|
|
|
expect(!isVisible && hasFled).toBe(true);
|
|
|
|
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
|
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
2024-08-22 06:49:33 -07:00
|
|
|
"Double battles should proceed without crashing",
|
2024-08-07 17:44:34 -07:00
|
|
|
async () => {
|
|
|
|
game.override.battleType("double").enemyMoveset(SPLASH_ONLY);
|
|
|
|
game.override.moveset([Moves.DRAGON_TAIL, Moves.SPLASH, Moves.FLAMETHROWER])
|
|
|
|
.enemyAbility(Abilities.ROUGH_SKIN);
|
|
|
|
await game.startBattle([Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD]);
|
|
|
|
|
|
|
|
const leadPokemon = game.scene.getParty()[0]!;
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
const enemyLeadPokemon = game.scene.getEnemyParty()[0]!;
|
|
|
|
const enemySecPokemon = game.scene.getEnemyParty()[1]!;
|
2024-08-07 17:44:34 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.DRAGON_TAIL, 0, BattlerIndex.ENEMY);
|
|
|
|
game.move.select(Moves.SPLASH, 1);
|
2024-08-07 17:44:34 -07:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
const isVisibleLead = enemyLeadPokemon.visible;
|
|
|
|
const hasFledLead = enemyLeadPokemon.wildFlee;
|
|
|
|
const isVisibleSec = enemySecPokemon.visible;
|
|
|
|
const hasFledSec = enemySecPokemon.wildFlee;
|
|
|
|
expect(!isVisibleLead && hasFledLead && isVisibleSec && !hasFledSec).toBe(true);
|
|
|
|
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
|
|
|
|
|
|
|
|
// second turn
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.FLAMETHROWER, 0, BattlerIndex.ENEMY_2);
|
|
|
|
game.move.select(Moves.SPLASH, 1);
|
2024-08-07 17:44:34 -07:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(BerryPhase);
|
|
|
|
expect(enemySecPokemon.hp).toBeLessThan(enemySecPokemon.getMaxHp());
|
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
|
|
|
|
test(
|
2024-08-22 06:49:33 -07:00
|
|
|
"Flee move redirection works",
|
2024-08-07 17:44:34 -07:00
|
|
|
async () => {
|
|
|
|
game.override.battleType("double").enemyMoveset(SPLASH_ONLY);
|
|
|
|
game.override.moveset([Moves.DRAGON_TAIL, Moves.SPLASH, Moves.FLAMETHROWER]);
|
|
|
|
game.override.enemyAbility(Abilities.ROUGH_SKIN);
|
|
|
|
await game.startBattle([Species.DRATINI, Species.DRATINI, Species.WAILORD, Species.WAILORD]);
|
|
|
|
|
|
|
|
const leadPokemon = game.scene.getParty()[0]!;
|
|
|
|
const secPokemon = game.scene.getParty()[1]!;
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
const enemyLeadPokemon = game.scene.getEnemyParty()[0]!;
|
|
|
|
const enemySecPokemon = game.scene.getEnemyParty()[1]!;
|
2024-08-07 17:44:34 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.DRAGON_TAIL, 0, BattlerIndex.ENEMY);
|
2024-08-07 17:44:34 -07:00
|
|
|
// target the same pokemon, second move should be redirected after first flees
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.DRAGON_TAIL, 1, BattlerIndex.ENEMY);
|
2024-08-07 17:44:34 -07:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(BerryPhase);
|
|
|
|
|
|
|
|
const isVisibleLead = enemyLeadPokemon.visible;
|
|
|
|
const hasFledLead = enemyLeadPokemon.wildFlee;
|
|
|
|
const isVisibleSec = enemySecPokemon.visible;
|
|
|
|
const hasFledSec = enemySecPokemon.wildFlee;
|
|
|
|
expect(!isVisibleLead && hasFledLead && !isVisibleSec && hasFledSec).toBe(true);
|
|
|
|
expect(leadPokemon.hp).toBeLessThan(leadPokemon.getMaxHp());
|
|
|
|
expect(secPokemon.hp).toBeLessThan(secPokemon.getMaxHp());
|
|
|
|
expect(enemyLeadPokemon.hp).toBeLessThan(enemyLeadPokemon.getMaxHp());
|
|
|
|
expect(enemySecPokemon.hp).toBeLessThan(enemySecPokemon.getMaxHp());
|
|
|
|
}, TIMEOUT
|
|
|
|
);
|
|
|
|
});
|