2024-07-25 16:18:47 -07:00
|
|
|
import { Stat } from "#app/data/pokemon-stat";
|
2024-08-06 07:06:25 -07:00
|
|
|
import GameManager from "#test/utils/gameManager";
|
|
|
|
import { getMovePosition } from "#test/utils/gameManagerUtils";
|
2024-07-25 16:18:47 -07:00
|
|
|
import { Command } from "#app/ui/command-ui-handler";
|
|
|
|
import { Mode } from "#app/ui/ui";
|
2024-06-13 18:44:23 -04:00
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2024-07-25 16:18:47 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
2024-08-19 03:23:52 +01:00
|
|
|
import { CommandPhase } from "#app/phases/command-phase.js";
|
|
|
|
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase.js";
|
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase.js";
|
2024-06-08 00:33:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
describe("Moves - Tackle", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
|
|
|
const moveToUse = Moves.TACKLE;
|
2024-07-25 14:48:48 -07:00
|
|
|
game.override.battleType("single");
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(Species.MAGIKARP);
|
2024-07-25 15:29:19 -07:00
|
|
|
game.override.startingLevel(1);
|
2024-07-25 14:25:31 -07:00
|
|
|
game.override.startingWave(97);
|
2024-07-25 15:51:05 -07:00
|
|
|
game.override.moveset([moveToUse]);
|
2024-07-25 15:18:14 -07:00
|
|
|
game.override.enemyMoveset([Moves.GROWTH,Moves.GROWTH,Moves.GROWTH,Moves.GROWTH]);
|
2024-07-25 16:18:47 -07:00
|
|
|
game.override.disableCrits();
|
2024-06-08 00:33:45 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it("TACKLE against ghost", async() => {
|
|
|
|
const moveToUse = Moves.TACKLE;
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(Species.GENGAR);
|
2024-06-08 00:33:45 +02:00
|
|
|
await game.startBattle([
|
|
|
|
Species.MIGHTYENA,
|
|
|
|
]);
|
|
|
|
const hpOpponent = game.scene.currentBattle.enemyParty[0].hp;
|
|
|
|
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
|
|
|
|
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
|
|
|
});
|
|
|
|
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
|
|
|
|
const movePosition = getMovePosition(game.scene, 0, moveToUse);
|
|
|
|
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
|
|
|
});
|
|
|
|
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase);
|
|
|
|
const hpLost = hpOpponent - game.scene.currentBattle.enemyParty[0].hp;
|
|
|
|
expect(hpLost).toBe(0);
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
it("TACKLE against not resistant", async() => {
|
|
|
|
const moveToUse = Moves.TACKLE;
|
|
|
|
await game.startBattle([
|
|
|
|
Species.MIGHTYENA,
|
|
|
|
]);
|
|
|
|
game.scene.currentBattle.enemyParty[0].stats[Stat.DEF] = 50;
|
|
|
|
game.scene.getParty()[0].stats[Stat.ATK] = 50;
|
|
|
|
|
|
|
|
|
|
|
|
const hpOpponent = game.scene.currentBattle.enemyParty[0].hp;
|
|
|
|
|
|
|
|
game.onNextPrompt("CommandPhase", Mode.COMMAND, () => {
|
|
|
|
game.scene.ui.setMode(Mode.FIGHT, (game.scene.getCurrentPhase() as CommandPhase).getFieldIndex());
|
|
|
|
});
|
|
|
|
game.onNextPrompt("CommandPhase", Mode.FIGHT, () => {
|
|
|
|
const movePosition = getMovePosition(game.scene, 0, moveToUse);
|
|
|
|
(game.scene.getCurrentPhase() as CommandPhase).handleCommand(Command.FIGHT, movePosition, false);
|
|
|
|
});
|
|
|
|
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase);
|
|
|
|
const hpLost = hpOpponent - game.scene.currentBattle.enemyParty[0].hp;
|
|
|
|
expect(hpLost).toBeGreaterThan(0);
|
|
|
|
expect(hpLost).toBe(4);
|
|
|
|
}, 20000);
|
|
|
|
});
|