2024-06-13 18:44:23 -04:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2025-02-22 22:52:07 -06:00
|
|
|
import GameManager from "#test/testUtils/gameManager";
|
2024-07-25 16:36:39 -07:00
|
|
|
import Phaser from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
2024-06-12 00:55:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
describe("Moves - Spikes", () => {
|
|
|
|
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-09-01 20:32:31 -07:00
|
|
|
game.override
|
|
|
|
.battleType("single")
|
|
|
|
.enemySpecies(Species.MAGIKARP)
|
|
|
|
.enemyAbility(Abilities.BALL_FETCH)
|
|
|
|
.ability(Abilities.BALL_FETCH)
|
2024-09-09 09:55:11 -07:00
|
|
|
.enemyMoveset(Moves.SPLASH)
|
2024-10-04 13:08:31 +08:00
|
|
|
.moveset([ Moves.SPIKES, Moves.SPLASH, Moves.ROAR ]);
|
2024-06-12 00:55:16 +02:00
|
|
|
});
|
|
|
|
|
2024-09-01 20:32:31 -07:00
|
|
|
it("should not damage the team that set them", async () => {
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.MIGHTYENA, Species.POOCHYENA ]);
|
2024-09-01 20:32:31 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.SPIKES);
|
2024-06-12 00:55:16 +02:00
|
|
|
await game.toNextTurn();
|
2024-09-01 20:32:31 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.SPLASH);
|
2024-06-12 00:55:16 +02:00
|
|
|
await game.toNextTurn();
|
|
|
|
|
2024-06-12 14:49:07 -04:00
|
|
|
game.doSwitchPokemon(1);
|
2024-09-01 20:32:31 -07:00
|
|
|
await game.toNextTurn();
|
2024-06-12 00:55:16 +02:00
|
|
|
|
2024-06-12 14:49:07 -04:00
|
|
|
game.doSwitchPokemon(1);
|
2024-09-01 20:32:31 -07:00
|
|
|
await game.toNextTurn();
|
2024-06-12 00:55:16 +02:00
|
|
|
|
2024-11-03 18:53:52 -08:00
|
|
|
const player = game.scene.getPlayerParty()[0];
|
2024-09-01 20:32:31 -07:00
|
|
|
expect(player.hp).toBe(player.getMaxHp());
|
2024-06-12 00:55:16 +02:00
|
|
|
}, 20000);
|
|
|
|
|
2024-09-01 20:32:31 -07:00
|
|
|
it("should damage opposing pokemon that are forced to switch in", async () => {
|
2024-07-25 14:25:31 -07:00
|
|
|
game.override.startingWave(5);
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.MIGHTYENA, Species.POOCHYENA ]);
|
2024-09-01 20:32:31 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.SPIKES);
|
2024-06-12 00:55:16 +02:00
|
|
|
await game.toNextTurn();
|
2024-09-01 20:32:31 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.ROAR);
|
2024-06-12 00:55:16 +02:00
|
|
|
await game.toNextTurn();
|
2024-09-01 20:32:31 -07:00
|
|
|
|
|
|
|
const enemy = game.scene.getEnemyParty()[0];
|
|
|
|
expect(enemy.hp).toBeLessThan(enemy.getMaxHp());
|
2024-06-12 00:55:16 +02:00
|
|
|
}, 20000);
|
|
|
|
|
2024-09-01 20:32:31 -07:00
|
|
|
it("should damage opposing pokemon that choose to switch in", async () => {
|
2024-07-25 14:25:31 -07:00
|
|
|
game.override.startingWave(5);
|
2024-10-04 13:08:31 +08:00
|
|
|
await game.startBattle([ Species.MIGHTYENA, Species.POOCHYENA ]);
|
2024-09-01 20:32:31 -07:00
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.SPIKES);
|
2024-06-12 00:55:16 +02:00
|
|
|
await game.toNextTurn();
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(Moves.SPLASH);
|
2024-09-04 10:56:57 -07:00
|
|
|
game.forceEnemyToSwitch();
|
2024-06-12 00:55:16 +02:00
|
|
|
await game.toNextTurn();
|
2024-09-01 20:32:31 -07:00
|
|
|
|
|
|
|
const enemy = game.scene.getEnemyParty()[0];
|
|
|
|
expect(enemy.hp).toBeLessThan(enemy.getMaxHp());
|
2024-06-12 00:55:16 +02:00
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
});
|