isCaught function in Dex now returns the correct result

This commit is contained in:
Wlowscha 2025-04-06 16:57:11 +02:00
parent fdf8c1a695
commit 9bbad183b5
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04

View File

@ -921,16 +921,22 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
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 {
const species = otherSpecies ? otherSpecies : this.species;
if (globalScene.dexForDevs) {
return 255n;
species.getFullUnlocksData();
}
const species = otherSpecies ? otherSpecies : this.species;
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 otherFormIndex The form index of the form to check; defaults to current form
* @returns StarterAttributes for the species
* @returns boolean
*/
isFormCaught(otherSpecies?: PokemonSpecies, otherFormIndex?: number | undefined): boolean {
if (globalScene.dexForDevs) {
@ -954,6 +960,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
}
const isFormCaught = (caughtAttr & globalScene.gameData.getFormAttr(formIndex ?? 0)) > 0n;
console.log(caughtAttr.toString(2), species.getFullUnlocksData().toString(2));
return isFormCaught;
}
@ -2459,6 +2467,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
const isFormCaught = this.isFormCaught();
const isFormSeen = this.isSeen();
console.log("isCaught:", isFormCaught, "isSeen:", isFormSeen);
this.shinyOverlay.setVisible(shiny ?? false); // TODO: is false the correct default?
this.pokemonNumberText.setColor(this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, false));