2024-07-05 12:50:19 -05:00
|
|
|
import { BerryType } from "#app/enums/berry-type";
|
2024-07-25 16:43:48 -07:00
|
|
|
import { Button } from "#app/enums/buttons";
|
2024-07-05 12:50:19 -05:00
|
|
|
import { Moves } from "#app/enums/moves";
|
|
|
|
import { Species } from "#app/enums/species";
|
2024-08-06 07:06:25 -07:00
|
|
|
import { BattleEndPhase, SelectModifierPhase } from "#app/phases";
|
|
|
|
import GameManager from "#test/utils/gameManager";
|
2024-07-05 12:50:19 -05:00
|
|
|
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
|
|
|
|
import PartyUiHandler, { PartyUiMode } from "#app/ui/party-ui-handler";
|
|
|
|
import { Mode } from "#app/ui/ui";
|
|
|
|
import Phaser from "phaser";
|
|
|
|
import BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
|
2024-07-25 16:43:48 -07:00
|
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
2024-08-06 07:06:25 -07:00
|
|
|
import { getMovePosition } from "#test/utils/gameManagerUtils";
|
2024-07-05 12:50:19 -05:00
|
|
|
|
|
|
|
|
|
|
|
describe("UI - Transfer Items", () => {
|
|
|
|
let phaserGame: Phaser.Game;
|
|
|
|
let game: GameManager;
|
|
|
|
|
|
|
|
beforeAll(() => {
|
|
|
|
phaserGame = new Phaser.Game({
|
|
|
|
type: Phaser.HEADLESS,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
game.phaseInterceptor.restoreOg();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
game = new GameManager(phaserGame);
|
2024-07-25 14:48:48 -07:00
|
|
|
game.override.battleType("single");
|
2024-07-25 15:29:19 -07:00
|
|
|
game.override.startingLevel(100);
|
2024-07-25 14:25:31 -07:00
|
|
|
game.override.startingWave(1);
|
2024-07-25 16:43:48 -07:00
|
|
|
game.override.startingHeldItems([
|
2024-07-05 12:50:19 -05:00
|
|
|
{ name: "BERRY", count: 1, type: BerryType.SITRUS },
|
|
|
|
{ name: "BERRY", count: 2, type: BerryType.APICOT },
|
|
|
|
{ name: "BERRY", count: 2, type: BerryType.LUM },
|
|
|
|
]);
|
2024-07-25 15:51:05 -07:00
|
|
|
game.override.moveset([Moves.DRAGON_CLAW]);
|
2024-07-25 14:57:47 -07:00
|
|
|
game.override.enemySpecies(Species.MAGIKARP);
|
2024-07-25 15:18:14 -07:00
|
|
|
game.override.enemyMoveset([Moves.SPLASH]);
|
2024-07-05 12:50:19 -05:00
|
|
|
|
|
|
|
await game.startBattle([Species.RAYQUAZA, Species.RAYQUAZA, Species.RAYQUAZA]);
|
|
|
|
|
|
|
|
game.doAttack(getMovePosition(game.scene, 0, Moves.DRAGON_CLAW));
|
|
|
|
|
|
|
|
game.onNextPrompt("SelectModifierPhase", Mode.MODIFIER_SELECT, () => {
|
|
|
|
expect(game.scene.ui.getHandler()).toBeInstanceOf(ModifierSelectUiHandler);
|
|
|
|
|
|
|
|
const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler;
|
|
|
|
handler.setCursor(1);
|
|
|
|
handler.processInput(Button.ACTION);
|
|
|
|
|
|
|
|
game.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER);
|
|
|
|
});
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(BattleEndPhase);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("check red tint for held item limit in transfer menu", async () => {
|
|
|
|
game.onNextPrompt("SelectModifierPhase", Mode.PARTY, () => {
|
|
|
|
expect(game.scene.ui.getHandler()).toBeInstanceOf(PartyUiHandler);
|
|
|
|
|
|
|
|
const handler = game.scene.ui.getHandler() as PartyUiHandler;
|
|
|
|
handler.processInput(Button.ACTION);
|
|
|
|
|
|
|
|
expect(handler.optionsContainer.list.some((option) => (option as BBCodeText).text?.includes("Sitrus Berry"))).toBe(true);
|
|
|
|
expect(handler.optionsContainer.list.some((option) => (option as BBCodeText).text?.includes("Apicot Berry (2)"))).toBe(true);
|
|
|
|
expect(handler.optionsContainer.list.some((option) => RegExp(/Lum Berry\[color.*(2)/).exec((option as BBCodeText).text))).toBe(true);
|
|
|
|
|
|
|
|
game.phaseInterceptor.unlock();
|
|
|
|
});
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(SelectModifierPhase);
|
|
|
|
}, 20000);
|
|
|
|
|
|
|
|
it("check transfer option for pokemon to transfer to", async () => {
|
|
|
|
game.onNextPrompt("SelectModifierPhase", Mode.PARTY, () => {
|
|
|
|
expect(game.scene.ui.getHandler()).toBeInstanceOf(PartyUiHandler);
|
|
|
|
|
|
|
|
const handler = game.scene.ui.getHandler() as PartyUiHandler;
|
|
|
|
handler.processInput(Button.ACTION); // select Pokemon
|
|
|
|
handler.processInput(Button.ACTION); // select held item (Sitrus Berry)
|
|
|
|
|
|
|
|
handler.setCursor(1); // move to other Pokemon
|
|
|
|
handler.processInput(Button.ACTION); // select Pokemon
|
|
|
|
|
|
|
|
expect(handler.optionsContainer.list.some((option) => (option as BBCodeText).text?.includes("Transfer"))).toBe(true);
|
|
|
|
game.phaseInterceptor.unlock();
|
|
|
|
});
|
|
|
|
|
|
|
|
await game.phaseInterceptor.to(SelectModifierPhase);
|
|
|
|
}, 20000);
|
|
|
|
});
|