2024-08-22 06:49:33 -07:00
|
|
|
import { Abilities } from "#app/enums/abilities";
|
|
|
|
import { Moves } from "#app/enums/moves";
|
|
|
|
import { Species } from "#app/enums/species";
|
|
|
|
import { StatusEffect } from "#app/enums/status-effect";
|
|
|
|
import { MoveEffectPhase } from "#app/phases/move-effect-phase";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-08-22 06:49:33 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
2024-07-29 16:27:50 -07:00
|
|
|
|
|
|
|
describe("Moves - Beat Up", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
2024-08-06 07:06:25 -07:00
|
|
|
game.override.battleType("single");
|
2024-07-29 16:27:50 -07:00
|
|
|
|
2024-08-06 07:06:25 -07:00
|
|
|
game.override.enemySpecies(Species.SNORLAX);
|
|
|
|
game.override.enemyLevel(100);
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.enemyMoveset([ Moves.SPLASH ]);
|
2024-08-06 07:06:25 -07:00
|
|
|
game.override.enemyAbility(Abilities.INSOMNIA);
|
2024-07-29 16:27:50 -07:00
|
|
|
|
2024-08-06 07:06:25 -07:00
|
|
|
game.override.startingLevel(100);
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.moveset([ Moves.BEAT_UP ]);
|
2024-07-29 16:27:50 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
it(
|
|
|
|
"should hit once for each healthy player Pokemon",
|
|
|
|
async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.MAGIKARP, Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.PIKACHU, Species.EEVEE ]);
|
2024-07-29 16:27:50 -07:00
|
|
|
|
2024-08-07 09:23:12 -07:00
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
2024-07-29 16:27:50 -07:00
|
|
|
let enemyStartingHp = enemyPokemon.hp;
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.BEAT_UP);
|
2024-07-29 16:27:50 -07:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(MoveEffectPhase);
|
|
|
|
|
|
|
|
expect(playerPokemon.turnData.hitCount).toBe(6);
|
|
|
|
expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp);
|
|
|
|
|
|
|
|
while (playerPokemon.turnData.hitsLeft > 0) {
|
|
|
|
enemyStartingHp = enemyPokemon.hp;
|
|
|
|
await game.phaseInterceptor.to(MoveEffectPhase);
|
|
|
|
expect(enemyPokemon.hp).toBeLessThan(enemyStartingHp);
|
|
|
|
}
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-07-29 16:27:50 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
it(
|
|
|
|
"should not count player Pokemon with status effects towards hit count",
|
|
|
|
async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.MAGIKARP, Species.BULBASAUR, Species.CHARMANDER, Species.SQUIRTLE, Species.PIKACHU, Species.EEVEE ]);
|
2024-07-29 16:27:50 -07:00
|
|
|
|
2024-08-07 09:23:12 -07:00
|
|
|
const playerPokemon = game.scene.getPlayerPokemon()!;
|
2024-07-29 16:27:50 -07:00
|
|
|
|
2024-11-03 18:53:52 -08:00
|
|
|
game.scene.getPlayerParty()[1].trySetStatus(StatusEffect.BURN);
|
2024-07-29 16:27:50 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.BEAT_UP);
|
2024-07-29 16:27:50 -07:00
|
|
|
|
|
|
|
await game.phaseInterceptor.to(MoveEffectPhase);
|
|
|
|
|
|
|
|
expect(playerPokemon.turnData.hitCount).toBe(5);
|
2024-09-20 14:05:45 -07:00
|
|
|
}
|
2024-07-29 16:27:50 -07:00
|
|
|
);
|
|
|
|
});
|