2024-07-25 16:43:48 -07:00
|
|
|
import { StatusEffect } from "#app/data/status-effect";
|
2024-08-22 06:49:33 -07:00
|
|
|
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
|
|
|
|
import { MessagePhase } from "#app/phases/message-phase";
|
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
2024-10-09 13:01:49 -07:00
|
|
|
import i18next from "#app/plugins/i18n";
|
2024-06-13 18:44:23 -04:00
|
|
|
import { Abilities } from "#enums/abilities";
|
|
|
|
import { Moves } from "#enums/moves";
|
|
|
|
import { Species } from "#enums/species";
|
2024-08-22 06:49:33 -07:00
|
|
|
import GameManager from "#test/utils/gameManager";
|
2024-07-25 16:43:48 -07:00
|
|
|
import Phaser from "phaser";
|
2024-10-09 13:01:49 -07:00
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
2024-06-08 00:33:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
describe("Items - Toxic orb", () => {
|
|
|
|
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.GROWTH;
|
|
|
|
const oppMoveToUse = 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.RATTATA);
|
2024-07-25 15:35:20 -07:00
|
|
|
game.override.ability(Abilities.INSOMNIA);
|
2024-07-25 15:05:32 -07:00
|
|
|
game.override.enemyAbility(Abilities.INSOMNIA);
|
2024-07-25 15:29:19 -07:00
|
|
|
game.override.startingLevel(2000);
|
2024-10-04 13:08:31 +08:00
|
|
|
game.override.moveset([ moveToUse ]);
|
|
|
|
game.override.enemyMoveset([ oppMoveToUse, oppMoveToUse, oppMoveToUse, oppMoveToUse ]);
|
2024-07-25 16:43:48 -07:00
|
|
|
game.override.startingHeldItems([{
|
2024-06-08 00:33:45 +02:00
|
|
|
name: "TOXIC_ORB",
|
|
|
|
}]);
|
2024-10-09 13:01:49 -07:00
|
|
|
|
|
|
|
vi.spyOn(i18next, "t");
|
2024-06-08 00:33:45 +02:00
|
|
|
});
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
it("TOXIC ORB", async () => {
|
2024-06-08 00:33:45 +02:00
|
|
|
const moveToUse = Moves.GROWTH;
|
|
|
|
await game.startBattle([
|
|
|
|
Species.MIGHTYENA,
|
|
|
|
Species.MIGHTYENA,
|
|
|
|
]);
|
|
|
|
expect(game.scene.modifiers[0].type.id).toBe("TOXIC_ORB");
|
|
|
|
|
2024-08-22 06:49:33 -07:00
|
|
|
game.move.select(moveToUse);
|
2024-06-08 00:33:45 +02:00
|
|
|
|
|
|
|
// will run the 13 phase from enemyCommandPhase to TurnEndPhase
|
|
|
|
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase);
|
|
|
|
// Toxic orb should trigger here
|
|
|
|
await game.phaseInterceptor.run(MessagePhase);
|
2024-10-09 13:01:49 -07:00
|
|
|
expect(i18next.t).toHaveBeenCalledWith("statusEffect:toxic.obtainSource", expect.anything());
|
|
|
|
|
2024-06-08 00:33:45 +02:00
|
|
|
await game.phaseInterceptor.run(MessagePhase);
|
2024-10-09 13:01:49 -07:00
|
|
|
expect(i18next.t).toHaveBeenCalledWith("statusEffect:toxic.activation", expect.anything());
|
2024-08-07 09:23:12 -07:00
|
|
|
expect(game.scene.getParty()[0].status!.effect).toBe(StatusEffect.TOXIC);
|
2024-06-08 00:33:45 +02:00
|
|
|
}, 20000);
|
|
|
|
});
|