mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-10 01:19:29 +02:00
* [feature]Implemented needed parts for discard function from issue #4780: -TryDiscardFunction in battlescene; -Created a party discard mode button; -Updated Transfer button in modifier-select-ui-handler to Manage items; -Created tests for the discard function in test/ui; -Added images for the new discard and transfer buttons to loading-scene; -Created placeholder messages for discard feature in party-ui-handler; Co-authored-by: Tiago Rodrigues <tiago.n.rodrigues@tecnico.ulisboa.pt> * [Fix] Updated icon for dynamic messaging * [Fix] Corrected legacy mode icons and adjusted double-battle button location * [Fix]Adjusted button positioning and mapping after review. Mapping requires debugging. * [Fix] Fixed visible pokeball in legacy mode and key mapping * [Fix] Background fixes,manage menu is the only one affected by changes now * Implement i18n keys * [Fix] implemented most code optimizations and callbacks to the modified locales folder * [Fix] Implemented 3 suggestions * [Fix]improved/corrected test structure Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> * [Fix] added functionality test for the discard button * [Fix] added necessary comment Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * [Fix] Implemented suggested changes in test/discard text prompt * [Fix] Implemented UI suggestions and removed discard text confirmation * [Fix] added missing imports * Fix imports in test file * [Fix] Implemented suggested cursor behavior and reworked test code * [Fix] Corrected failed test * [Fix] atempting to fix the test timeout issue * [Fix] Undoing latest attempt * [Fix] Implemented suggestions to fix broken tests * Reviews * [Fix] replaced icon images * [Fix] Updated jsons to match new icons and removed pokeball icon from legacy mode * Optimized new images * [Fix] Fixed referenced bug and added similar confirmation box to release * [Fix] Updated tests to handle the corfirmation box * [Fix] Added back the accidentally removed changes * [Fix]updated incorrect import path * [fix] add description for the manageItemMode function Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * Update src/ui/party-ui-handler.ts Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> * [Fix] corrected formating issue --------- Co-authored-by: Mikhail Shueb <mikhail.shueb@tecnico.ulisboa.pt> Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> Co-authored-by: Bertie690 <136088738+Bertie690@users.noreply.github.com> Co-authored-by: damocleas <damocleas25@gmail.com> Co-authored-by: Bertie690 <taylormw163@gmail.com> Co-authored-by: Adri1 <adrien.grivel@hotmail.fr>
173 lines
5.8 KiB
TypeScript
173 lines
5.8 KiB
TypeScript
import { BerryType } from "#enums/berry-type";
|
|
import { Button } from "#enums/buttons";
|
|
import { MoveId } from "#enums/move-id";
|
|
import { SpeciesId } from "#enums/species-id";
|
|
import { UiMode } from "#enums/ui-mode";
|
|
import type { Pokemon } from "#field/pokemon";
|
|
import { GameManager } from "#test/test-utils/game-manager";
|
|
import type { ModifierSelectUiHandler } from "#ui/modifier-select-ui-handler";
|
|
import type { PartyUiHandler } from "#ui/party-ui-handler";
|
|
import Phaser from "phaser";
|
|
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
|
|
|
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);
|
|
game.override
|
|
.battleStyle("single")
|
|
.startingLevel(100)
|
|
.startingHeldItems([
|
|
{ name: "BERRY", count: 1, type: BerryType.SITRUS },
|
|
{ name: "BERRY", count: 2, type: BerryType.APICOT },
|
|
{ name: "BERRY", count: 2, type: BerryType.LUM },
|
|
])
|
|
.enemySpecies(SpeciesId.MAGIKARP)
|
|
.enemyMoveset(MoveId.SPLASH);
|
|
|
|
await game.classicMode.startBattle([SpeciesId.RAYQUAZA, SpeciesId.RAYQUAZA, SpeciesId.RAYQUAZA]);
|
|
|
|
game.move.use(MoveId.DRAGON_CLAW);
|
|
|
|
await game.phaseInterceptor.to("SelectModifierPhase");
|
|
});
|
|
|
|
it("manage button exists in the proper screen", async () => {
|
|
let handlerLength: Phaser.GameObjects.GameObject[] | undefined;
|
|
|
|
await new Promise<void>(resolve => {
|
|
//select manage items menu
|
|
game.onNextPrompt("SelectModifierPhase", UiMode.MODIFIER_SELECT, async () => {
|
|
await new Promise(r => setTimeout(r, 100));
|
|
const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler;
|
|
|
|
handler.processInput(Button.DOWN);
|
|
handler.setCursor(1);
|
|
handler.processInput(Button.ACTION);
|
|
});
|
|
|
|
game.onNextPrompt("SelectModifierPhase", UiMode.PARTY, async () => {
|
|
await new Promise(r => setTimeout(r, 100));
|
|
const handler = game.scene.ui.getHandler() as PartyUiHandler;
|
|
|
|
handler.processInput(Button.DOWN);
|
|
handler.processInput(Button.ACTION);
|
|
handlerLength = handler.optionsContainer.list;
|
|
|
|
handler.processInput(Button.CANCEL);
|
|
|
|
resolve();
|
|
});
|
|
});
|
|
|
|
expect(handlerLength).toHaveLength(0); // should select manage button, which has no menu
|
|
});
|
|
|
|
it("manage button doesn't exist in the other screens", async () => {
|
|
let handlerLength: Phaser.GameObjects.GameObject[] | undefined;
|
|
|
|
await new Promise<void>(resolve => {
|
|
game.onNextPrompt("SelectModifierPhase", UiMode.MODIFIER_SELECT, async () => {
|
|
await new Promise(r => setTimeout(r, 100));
|
|
const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler;
|
|
|
|
handler.processInput(Button.DOWN);
|
|
handler.setCursor(2);
|
|
handler.processInput(Button.ACTION);
|
|
});
|
|
|
|
game.onNextPrompt("SelectModifierPhase", UiMode.PARTY, async () => {
|
|
await new Promise(r => setTimeout(r, 100));
|
|
const handler = game.scene.ui.getHandler() as PartyUiHandler;
|
|
|
|
handler.processInput(Button.DOWN);
|
|
handler.processInput(Button.ACTION);
|
|
handlerLength = handler.optionsContainer.list;
|
|
|
|
handler.processInput(Button.CANCEL);
|
|
handler.processInput(Button.CANCEL);
|
|
|
|
resolve();
|
|
});
|
|
});
|
|
|
|
expect(handlerLength).toHaveLength(6); // should select 2nd pokemon (length is 5 options + image)
|
|
});
|
|
|
|
// Test that the manage button actually discards items, needs proofreading
|
|
it("should discard items when button is selected", async () => {
|
|
let pokemon: Pokemon | undefined;
|
|
|
|
await new Promise<void>(resolve => {
|
|
game.onNextPrompt("SelectModifierPhase", UiMode.MODIFIER_SELECT, async () => {
|
|
await new Promise(r => setTimeout(r, 100));
|
|
const handler = game.scene.ui.getHandler() as ModifierSelectUiHandler;
|
|
|
|
handler.processInput(Button.DOWN);
|
|
handler.setCursor(1);
|
|
handler.processInput(Button.ACTION);
|
|
});
|
|
game.onNextPrompt("SelectModifierPhase", UiMode.PARTY, async () => {
|
|
await new Promise(r => setTimeout(r, 100));
|
|
const handler = game.scene.ui.getHandler() as PartyUiHandler;
|
|
|
|
// Enter discard mode and select first party member
|
|
handler.setCursor(7);
|
|
handler.processInput(Button.ACTION);
|
|
handler.setCursor(0);
|
|
handler.processInput(Button.ACTION);
|
|
pokemon = game.field.getPlayerPokemon();
|
|
|
|
resolve();
|
|
});
|
|
});
|
|
|
|
expect(pokemon).toBeDefined();
|
|
if (pokemon) {
|
|
expect(pokemon.getHeldItems()).toHaveLength(3);
|
|
expect(pokemon.getHeldItems().map(h => h.stackCount)).toEqual([1, 2, 2]);
|
|
}
|
|
|
|
await new Promise<void>(resolve => {
|
|
game.onNextPrompt("SelectModifierPhase", UiMode.PARTY, async () => {
|
|
await new Promise(r => setTimeout(r, 100));
|
|
const handler = game.scene.ui.getHandler() as PartyUiHandler;
|
|
handler.processInput(Button.ACTION);
|
|
resolve();
|
|
});
|
|
});
|
|
|
|
await new Promise<void>(resolve => {
|
|
game.onNextPrompt("SelectModifierPhase", UiMode.PARTY, async () => {
|
|
await new Promise(r => setTimeout(r, 100));
|
|
const handler = game.scene.ui.getHandler() as PartyUiHandler;
|
|
handler.processInput(Button.ACTION);
|
|
|
|
pokemon = game.field.getPlayerPokemon();
|
|
|
|
handler.processInput(Button.CANCEL);
|
|
resolve();
|
|
});
|
|
});
|
|
|
|
expect(pokemon).toBeDefined();
|
|
if (pokemon) {
|
|
// Sitrus berry was discarded, leaving 2 stacks of 2 berries behind
|
|
expect(pokemon.getHeldItems()).toHaveLength(2);
|
|
expect(pokemon.getHeldItems().map(h => h.stackCount)).toEqual([2, 2]);
|
|
}
|
|
});
|
|
});
|