2024-08-06 07:06:25 -07:00
|
|
|
import { CommandPhase } from "#app/phases";
|
|
|
|
import GameManager from "#test/utils/gameManager";
|
2024-06-13 18:44:23 -04:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
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);
|
|
|
|
game.scene.battleStyle = 1;
|
2024-07-25 14:48:48 -07:00
|
|
|
game.override.battleType("single");
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(Species.RATTATA);
|
2024-07-25 15:05:32 -07:00
|
|
|
game.override.enemyAbility(Abilities.HYDRATION);
|
2024-07-25 16:29:31 -07:00
|
|
|
game.override.enemyPassiveAbility(Abilities.HYDRATION);
|
2024-07-25 15:35:20 -07:00
|
|
|
game.override.ability(Abilities.HYDRATION);
|
2024-07-25 16:36:39 -07:00
|
|
|
game.override.passiveAbility(Abilities.HYDRATION);
|
2024-07-25 14:25:31 -07:00
|
|
|
game.override.startingWave(3);
|
2024-07-25 15:18:14 -07:00
|
|
|
game.override.enemyMoveset([Moves.SPLASH,Moves.SPLASH,Moves.SPLASH,Moves.SPLASH]);
|
2024-07-25 15:51:05 -07:00
|
|
|
game.override.moveset([Moves.SPIKES,Moves.SPLASH, Moves.ROAR]);
|
2024-06-12 00:55:16 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
it("single - wild - stay on field - no damage", async() => {
|
|
|
|
// player set spikes on the field and do splash for 3 turns
|
|
|
|
// opponent do splash for 4 turns
|
|
|
|
// nobody should take damage
|
|
|
|
await game.runToSummon([
|
|
|
|
Species.MIGHTYENA,
|
|
|
|
Species.POOCHYENA,
|
|
|
|
]);
|
|
|
|
await game.phaseInterceptor.to(CommandPhase, true);
|
|
|
|
const initialHp = game.scene.getParty()[0].hp;
|
|
|
|
expect(game.scene.getParty()[0].hp).toBe(initialHp);
|
|
|
|
game.doAttack(0);
|
|
|
|
await game.toNextTurn();
|
|
|
|
game.doAttack(1);
|
|
|
|
await game.toNextTurn();
|
|
|
|
game.doAttack(1);
|
|
|
|
await game.toNextTurn();
|
|
|
|
game.doAttack(1);
|
|
|
|
await game.toNextTurn();
|
|
|
|
game.doAttack(1);
|
|
|
|
await game.toNextTurn();
|
|
|
|
expect(game.scene.getParty()[0].hp).toBe(initialHp);
|
|
|
|
console.log(game.textInterceptor.logs);
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
it("single - wild - take some damage", async() => {
|
|
|
|
// player set spikes on the field and switch back to back
|
|
|
|
// opponent do splash for 2 turns
|
|
|
|
// nobody should take damage
|
|
|
|
await game.runToSummon([
|
|
|
|
Species.MIGHTYENA,
|
|
|
|
Species.POOCHYENA,
|
|
|
|
]);
|
|
|
|
await game.phaseInterceptor.to(CommandPhase, false);
|
|
|
|
|
|
|
|
const initialHp = game.scene.getParty()[0].hp;
|
2024-06-12 14:49:07 -04:00
|
|
|
game.doSwitchPokemon(1);
|
2024-06-12 00:55:16 +02:00
|
|
|
await game.phaseInterceptor.run(CommandPhase);
|
|
|
|
await game.phaseInterceptor.to(CommandPhase, false);
|
|
|
|
|
2024-06-12 14:49:07 -04:00
|
|
|
game.doSwitchPokemon(1);
|
2024-06-12 00:55:16 +02:00
|
|
|
await game.phaseInterceptor.run(CommandPhase);
|
|
|
|
await game.phaseInterceptor.to(CommandPhase, false);
|
|
|
|
|
|
|
|
expect(game.scene.getParty()[0].hp).toBe(initialHp);
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
it("trainer - wild - force switch opponent - should take damage", async() => {
|
2024-07-25 14:25:31 -07:00
|
|
|
game.override.startingWave(5);
|
2024-06-12 00:55:16 +02:00
|
|
|
// player set spikes on the field and do splash for 3 turns
|
|
|
|
// opponent do splash for 4 turns
|
|
|
|
// nobody should take damage
|
|
|
|
await game.runToSummon([
|
|
|
|
Species.MIGHTYENA,
|
|
|
|
Species.POOCHYENA,
|
|
|
|
]);
|
|
|
|
await game.phaseInterceptor.to(CommandPhase, true);
|
|
|
|
const initialHpOpponent = game.scene.currentBattle.enemyParty[1].hp;
|
|
|
|
game.doAttack(0);
|
|
|
|
await game.toNextTurn();
|
|
|
|
game.doAttack(2);
|
|
|
|
await game.toNextTurn();
|
|
|
|
expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(initialHpOpponent);
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
it("trainer - wild - force switch by himself opponent - should take damage", async() => {
|
2024-07-25 14:25:31 -07:00
|
|
|
game.override.startingWave(5);
|
2024-07-25 15:29:19 -07:00
|
|
|
game.override.startingLevel(5000);
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(0);
|
2024-06-12 00:55:16 +02:00
|
|
|
// turn 1: player set spikes, opponent do splash
|
|
|
|
// turn 2: player do splash, opponent switch pokemon
|
|
|
|
// opponent pokemon should trigger spikes and lose HP
|
|
|
|
await game.runToSummon([
|
|
|
|
Species.MIGHTYENA,
|
|
|
|
Species.POOCHYENA,
|
|
|
|
]);
|
|
|
|
await game.phaseInterceptor.to(CommandPhase, true);
|
|
|
|
const initialHpOpponent = game.scene.currentBattle.enemyParty[1].hp;
|
|
|
|
game.doAttack(0);
|
|
|
|
await game.toNextTurn();
|
|
|
|
|
|
|
|
game.forceOpponentToSwitch();
|
|
|
|
game.doAttack(1);
|
|
|
|
await game.toNextTurn();
|
|
|
|
expect(game.scene.currentBattle.enemyParty[0].hp).toBeLessThan(initialHpOpponent);
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
});
|