2024-09-02 22:12:34 -04:00
|
|
|
import { TurnEndPhase } from "#app/phases/turn-end-phase";
|
|
|
|
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-09-02 22:12:34 -04:00
|
|
|
import Phase from "phaser";
|
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
import { BattleEndPhase } from "#app/phases/battle-end-phase";
|
|
|
|
import { TempCritBoosterModifier } from "#app/modifier/modifier";
|
|
|
|
import { Mode } from "#app/ui/ui";
|
2025-01-12 15:33:05 -08:00
|
|
|
import type ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
|
2024-09-02 22:12:34 -04:00
|
|
|
import { Button } from "#app/enums/buttons";
|
|
|
|
import { CommandPhase } from "#app/phases/command-phase";
|
|
|
|
import { NewBattlePhase } from "#app/phases/new-battle-phase";
|
|
|
|
import { TurnInitPhase } from "#app/phases/turn-init-phase";
|
2024-09-04 09:07:56 +08:00
|
|
|
import { ShopCursorTarget } from "#app/enums/shop-cursor-target";
|
2024-09-02 22:12:34 -04:00
|
|
|
|
|
|
|
describe("Items - Dire Hit", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phase.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
game = new GameManager(phaserGame);
|
|
|
|
|
|
|
|
game.override
|
|
|
|
.enemySpecies(Species.MAGIKARP)
|
2024-09-09 09:55:11 -07:00
|
|
|
.enemyMoveset(Moves.SPLASH)
|
2024-09-02 22:12:34 -04:00
|
|
|
.moveset([ Moves.POUND ])
|
|
|
|
.startingHeldItems([{ name: "DIRE_HIT" }])
|
|
|
|
.battleType("single")
|
|
|
|
.disableCrits();
|
|
|
|
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
it("should raise CRIT stage by 1", async () => {
|
|
|
|
await game.startBattle([
|
|
|
|
Species.GASTLY
|
|
|
|
]);
|
|
|
|
|
|
|
|
const enemyPokemon = game.scene.getEnemyPokemon()!;
|
|
|
|
|
|
|
|
vi.spyOn(enemyPokemon, "getCritStage");
|
|
|
|
|
|
|
|
game.move.select(Moves.POUND);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(TurnEndPhase);
|
|
|
|
|
|
|
|
expect(enemyPokemon.getCritStage).toHaveReturnedWith(1);
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
it("should renew how many battles are left of existing DIRE_HIT when picking up new DIRE_HIT", async() => {
|
|
|
|
game.override.itemRewards([{ name: "DIRE_HIT" }]);
|
|
|
|
|
|
|
|
await game.startBattle([
|
|
|
|
Species.PIKACHU
|
|
|
|
]);
|
|
|
|
|
|
|
|
game.move.select(Moves.SPLASH);
|
|
|
|
|
|
|
|
await game.doKillOpponents();
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(BattleEndPhase);
|
|
|
|
|
|
|
|
const modifier = game.scene.findModifier(m => m instanceof TempCritBoosterModifier) as TempCritBoosterModifier;
|
2024-09-06 22:54:54 -04:00
|
|
|
expect(modifier.getBattleCount()).toBe(4);
|
2024-09-02 22:12:34 -04:00
|
|
|
|
|
|
|
// Forced DIRE_HIT to spawn in the first slot with override
|
|
|
|
game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => {
|
|
|
|
const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler;
|
|
|
|
// Traverse to first modifier slot
|
2024-09-04 09:07:56 +08:00
|
|
|
handler.setCursor(0);
|
|
|
|
handler.setRowCursor(ShopCursorTarget.REWARDS);
|
2024-09-02 22:12:34 -04:00
|
|
|
handler.processInput(Button.ACTION);
|
|
|
|
}, () => game.isCurrentPhase(CommandPhase) || game.isCurrentPhase(NewBattlePhase), true);
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(TurnInitPhase);
|
|
|
|
|
|
|
|
// Making sure only one booster is in the modifier list even after picking up another
|
|
|
|
let count = 0;
|
|
|
|
for (const m of game.scene.modifiers) {
|
|
|
|
if (m instanceof TempCritBoosterModifier) {
|
|
|
|
count++;
|
2024-09-06 22:54:54 -04:00
|
|
|
expect((m as TempCritBoosterModifier).getBattleCount()).toBe(5);
|
2024-09-02 22:12:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
expect(count).toBe(1);
|
|
|
|
}, 20000);
|
|
|
|
});
|