mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-05-04 15:34:16 +01:00
[UI/UX] Caught battle forms are displayed correctly in Pokédex (#5697)
* isCaught function in Dex now returns the correct result * Removed log messages * Added tests to check caught status of battle forms * Update src/ui/pokedex-page-ui-handler.ts Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com> --------- Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
This commit is contained in:
parent
fd5612e253
commit
cdcc338afd
@ -921,16 +921,22 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
return biomes;
|
return biomes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the caughtAttr of a given species, sanitized.
|
||||||
|
*
|
||||||
|
* @param otherSpecies The species to check; defaults to current species
|
||||||
|
* @returns caught DexAttr for the species
|
||||||
|
*/
|
||||||
isCaught(otherSpecies?: PokemonSpecies): bigint {
|
isCaught(otherSpecies?: PokemonSpecies): bigint {
|
||||||
|
const species = otherSpecies ? otherSpecies : this.species;
|
||||||
|
|
||||||
if (globalScene.dexForDevs) {
|
if (globalScene.dexForDevs) {
|
||||||
return 255n;
|
species.getFullUnlocksData();
|
||||||
}
|
}
|
||||||
|
|
||||||
const species = otherSpecies ? otherSpecies : this.species;
|
|
||||||
const dexEntry = globalScene.gameData.dexData[species.speciesId];
|
const dexEntry = globalScene.gameData.dexData[species.speciesId];
|
||||||
const starterDexEntry = globalScene.gameData.dexData[this.getStarterSpeciesId(species.speciesId)];
|
|
||||||
|
|
||||||
return (dexEntry?.caughtAttr ?? 0n) & (starterDexEntry?.caughtAttr ?? 0n) & species.getFullUnlocksData();
|
return (dexEntry?.caughtAttr ?? 0n) & species.getFullUnlocksData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -939,7 +945,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
*
|
*
|
||||||
* @param otherSpecies The species to check; defaults to current species
|
* @param otherSpecies The species to check; defaults to current species
|
||||||
* @param otherFormIndex The form index of the form to check; defaults to current form
|
* @param otherFormIndex The form index of the form to check; defaults to current form
|
||||||
* @returns StarterAttributes for the species
|
* @returns `true` if the form is caught
|
||||||
*/
|
*/
|
||||||
isFormCaught(otherSpecies?: PokemonSpecies, otherFormIndex?: number | undefined): boolean {
|
isFormCaught(otherSpecies?: PokemonSpecies, otherFormIndex?: number | undefined): boolean {
|
||||||
if (globalScene.dexForDevs) {
|
if (globalScene.dexForDevs) {
|
||||||
@ -954,6 +960,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isFormCaught = (caughtAttr & globalScene.gameData.getFormAttr(formIndex ?? 0)) > 0n;
|
const isFormCaught = (caughtAttr & globalScene.gameData.getFormAttr(formIndex ?? 0)) > 0n;
|
||||||
|
|
||||||
return isFormCaught;
|
return isFormCaught;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1151,7 +1158,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.blockInput = false;
|
this.blockInput = false;
|
||||||
} else {
|
} else {
|
||||||
ui.revertMode().then(() => {
|
ui.revertMode().then(() => {
|
||||||
console.log("exitCallback", this.exitCallback);
|
|
||||||
if (this.exitCallback instanceof Function) {
|
if (this.exitCallback instanceof Function) {
|
||||||
const exitCallback = this.exitCallback;
|
const exitCallback = this.exitCallback;
|
||||||
this.exitCallback = null;
|
this.exitCallback = null;
|
||||||
|
1
test/testUtils/saves/data_pokedex_tests_v2.prsv
Normal file
1
test/testUtils/saves/data_pokedex_tests_v2.prsv
Normal file
File diff suppressed because one or more lines are too long
@ -12,6 +12,8 @@ import { DropDownColumn } from "#app/ui/filter-bar";
|
|||||||
import type PokemonSpecies from "#app/data/pokemon-species";
|
import type PokemonSpecies from "#app/data/pokemon-species";
|
||||||
import { PokemonType } from "#enums/pokemon-type";
|
import { PokemonType } from "#enums/pokemon-type";
|
||||||
import { UiMode } from "#enums/ui-mode";
|
import { UiMode } from "#enums/ui-mode";
|
||||||
|
import PokedexPageUiHandler from "#app/ui/pokedex-page-ui-handler";
|
||||||
|
import type { StarterAttributes } from "#app/system/game-data";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Information for the `data_pokedex_tests.psrv`:
|
Information for the `data_pokedex_tests.psrv`:
|
||||||
@ -80,6 +82,26 @@ describe("UI - Pokedex", () => {
|
|||||||
return handler as PokedexUiHandler;
|
return handler as PokedexUiHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the game to open the pokedex UI.
|
||||||
|
* @returns The handler for the pokedex UI.
|
||||||
|
*/
|
||||||
|
async function runToPokedexPage(
|
||||||
|
species: PokemonSpecies,
|
||||||
|
starterAttributes: StarterAttributes = {},
|
||||||
|
): Promise<PokedexPageUiHandler> {
|
||||||
|
// Open the pokedex UI.
|
||||||
|
await game.runToTitle();
|
||||||
|
|
||||||
|
await game.phaseInterceptor.setOverlayMode(UiMode.POKEDEX_PAGE, species, starterAttributes);
|
||||||
|
|
||||||
|
// Get the handler for the current UI.
|
||||||
|
const handler = game.scene.ui.getHandler();
|
||||||
|
expect(handler).toBeInstanceOf(PokedexPageUiHandler);
|
||||||
|
|
||||||
|
return handler as PokedexPageUiHandler;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute a set of pokemon that have a specific ability in allAbilities
|
* Compute a set of pokemon that have a specific ability in allAbilities
|
||||||
* @param ability - The ability to filter for
|
* @param ability - The ability to filter for
|
||||||
@ -489,4 +511,37 @@ describe("UI - Pokedex", () => {
|
|||||||
expect(selectedPokemon).toEqual(pokedexHandler.lastSpecies.speciesId);
|
expect(selectedPokemon).toEqual(pokedexHandler.lastSpecies.speciesId);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/****************************
|
||||||
|
* Tests for Pokédex Pages *
|
||||||
|
****************************/
|
||||||
|
|
||||||
|
it("should show caught battle form as caught", async () => {
|
||||||
|
await game.importData("./test/testUtils/saves/data_pokedex_tests_v2.prsv");
|
||||||
|
const pageHandler = await runToPokedexPage(getPokemonSpecies(Species.VENUSAUR), { form: 1 });
|
||||||
|
|
||||||
|
// @ts-expect-error - `species` is private
|
||||||
|
expect(pageHandler.species.speciesId).toEqual(Species.VENUSAUR);
|
||||||
|
|
||||||
|
// @ts-expect-error - `formIndex` is private
|
||||||
|
expect(pageHandler.formIndex).toEqual(1);
|
||||||
|
|
||||||
|
expect(pageHandler.isFormCaught()).toEqual(true);
|
||||||
|
expect(pageHandler.isSeen()).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
//TODO: check tint of the sprite
|
||||||
|
it("should show uncaught battle form as seen", async () => {
|
||||||
|
await game.importData("./test/testUtils/saves/data_pokedex_tests_v2.prsv");
|
||||||
|
const pageHandler = await runToPokedexPage(getPokemonSpecies(Species.VENUSAUR), { form: 2 });
|
||||||
|
|
||||||
|
// @ts-expect-error - `species` is private
|
||||||
|
expect(pageHandler.species.speciesId).toEqual(Species.VENUSAUR);
|
||||||
|
|
||||||
|
// @ts-expect-error - `formIndex` is private
|
||||||
|
expect(pageHandler.formIndex).toEqual(2);
|
||||||
|
|
||||||
|
expect(pageHandler.isFormCaught()).toEqual(false);
|
||||||
|
expect(pageHandler.isSeen()).toEqual(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user