Update Toxic Orb test

This commit is contained in:
NightKev 2024-08-31 22:25:31 -07:00
parent c63745bd7d
commit c76642798d
1 changed files with 22 additions and 29 deletions

View File

@ -1,15 +1,14 @@
import { StatusEffect } from "#app/data/status-effect"; import { StatusEffect } from "#app/data/status-effect";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { MessagePhase } from "#app/phases/message-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import i18next, { initI18n } from "#app/plugins/i18n"; import i18next, { initI18n } from "#app/plugins/i18n";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
import { Species } from "#enums/species"; import { Species } from "#enums/species";
import GameManager from "#test/utils/gameManager"; import GameManager from "#test/utils/gameManager";
import { SPLASH_ONLY } from "#test/utils/testUtils";
import Phaser from "phaser"; import Phaser from "phaser";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
const TIMEOUT = 20 * 1000;
describe("Items - Toxic orb", () => { describe("Items - Toxic orb", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
@ -27,40 +26,34 @@ describe("Items - Toxic orb", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
const moveToUse = Moves.GROWTH; game.override
const oppMoveToUse = Moves.TACKLE; .battleType("single")
game.override.battleType("single"); .enemySpecies(Species.RATTATA)
game.override.enemySpecies(Species.RATTATA); .ability(Abilities.BALL_FETCH)
game.override.ability(Abilities.INSOMNIA); .enemyAbility(Abilities.BALL_FETCH)
game.override.enemyAbility(Abilities.INSOMNIA); .moveset([Moves.SPLASH])
game.override.startingLevel(2000); .enemyMoveset(SPLASH_ONLY)
game.override.moveset([moveToUse]); .startingHeldItems([{
game.override.enemyMoveset([oppMoveToUse, oppMoveToUse, oppMoveToUse, oppMoveToUse]);
game.override.startingHeldItems([{
name: "TOXIC_ORB", name: "TOXIC_ORB",
}]); }]);
}); });
it("TOXIC ORB", async () => { it("badly poisons the holder", async () => {
initI18n(); initI18n();
i18next.changeLanguage("en"); i18next.changeLanguage("en");
const moveToUse = Moves.GROWTH; await game.classicMode.startBattle([Species.MIGHTYENA]);
await game.startBattle([
Species.MIGHTYENA,
Species.MIGHTYENA,
]);
expect(game.scene.modifiers[0].type.id).toBe("TOXIC_ORB");
game.move.select(moveToUse); const player = game.scene.getPlayerField()[0];
// will run the 13 phase from enemyCommandPhase to TurnEndPhase game.move.select(Moves.SPLASH);
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase);
await game.phaseInterceptor.to("TurnEndPhase");
// Toxic orb should trigger here // Toxic orb should trigger here
await game.phaseInterceptor.run(MessagePhase); await game.phaseInterceptor.run("MessagePhase");
const message = game.textInterceptor.getLatestMessage(); const message = game.textInterceptor.getLatestMessage();
expect(message).toContain("was badly poisoned by the Toxic Orb"); expect(message).toContain("was badly poisoned by the Toxic Orb");
expect(game.scene.getParty()[0].status!.effect).toBe(StatusEffect.TOXIC); expect(player.status?.effect).toBe(StatusEffect.TOXIC);
// Damage should not have ticked yet. // Damage should not have ticked yet.
expect(game.scene.getParty()[0].status!.turnCount).toBe(0); expect(player.status?.turnCount).toBe(0);
}, 2000); }, TIMEOUT);
}); });