Handling uncaught pokemon

This commit is contained in:
Wlowscha 2025-01-09 23:53:07 +01:00
parent 215f9e8141
commit 726b975f11
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04
2 changed files with 536 additions and 493 deletions

View File

@ -286,7 +286,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonGenderText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonGenderText);
this.pokemonUncaughtText = addTextObject(this.scene, 6, 127, i18next.t("pokedexUiHandler:uncaught"), TextStyle.SUMMARY_ALT, { fontSize: "56px" });
this.pokemonUncaughtText = addTextObject(this.scene, 6, 127, i18next.t("pokedexUiHandler:uncaught"), TextStyle.WINDOW, { fontSize: "56px" });
this.pokemonUncaughtText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonUncaughtText);
@ -927,6 +927,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
case MenuOptions.BASE_STATS:
if (!this.speciesStarterDexEntry?.caughtAttr) {
error = true;
} else {
this.blockInput = true;
ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => {
@ -939,12 +943,17 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
return true;
});
});
success = true;
});
}
break;
case MenuOptions.LEVEL_MOVES:
if (!this.speciesStarterDexEntry?.caughtAttr) {
error = true;
} else {
this.blockInput = true;
ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => {
@ -985,10 +994,16 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
});
});
success = true;
}
break;
case MenuOptions.EGG_MOVES:
if (!this.speciesStarterDexEntry?.caughtAttr) {
error = true;
} else {
this.blockInput = true;
ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => {
@ -1051,10 +1066,14 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
});
});
success = true;
}
break;
case MenuOptions.TM_MOVES:
if (!this.speciesStarterDexEntry?.caughtAttr) {
error = true;
} else {
this.blockInput = true;
ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => {
@ -1095,10 +1114,15 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
});
});
success = true;
}
break;
case MenuOptions.ABILITIES:
if (!this.speciesStarterDexEntry?.caughtAttr) {
error = true;
} else {
this.blockInput = true;
ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => {
@ -1182,10 +1206,14 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
});
});
success = true;
}
break;
case MenuOptions.BIOMES:
if (!(this.speciesStarterDexEntry?.caughtAttr || this.speciesStarterDexEntry?.seenAttr)) {
error = true;
} else {
this.blockInput = true;
ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => {
@ -1250,10 +1278,15 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
});
});
success = true;
}
break;
case MenuOptions.EVOLUTIONS:
if (!this.speciesStarterDexEntry?.caughtAttr) {
error = true;
} else {
this.blockInput = true;
ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => {
@ -1274,6 +1307,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
if (this.prevolutions?.length > 0) {
options.push({
label: i18next.t("pokedexUiHandler:prevolutions"),
style: TextStyle.MONEY_WINDOW,
skip: true,
handler: () => false
});
@ -1283,7 +1317,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
label: pre.preFormKey ?
this.getFormString(pre.preFormKey, preSpecies ?? this.lastSpecies, true) :
this.getRegionName(preSpecies ?? this.lastSpecies),
style: TextStyle.MONEY_WINDOW,
handler: () => {
const newSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[pre.speciesId]);
// Attempts to find the formIndex of the evolved species
@ -1318,16 +1351,19 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
if (this.evolutions.length > 0) {
options.push({
label: i18next.t("pokedexUiHandler:evolutions"),
style: TextStyle.MONEY_WINDOW,
skip: true,
handler: () => false
});
this.evolutions.map(evo => {
const evoSpecies = allSpecies.find(species => species.speciesId === evo.speciesId);
const evoSpeciesStarterDexEntry = evoSpecies ? this.scene.gameData.dexData[evoSpecies.speciesId] : null;
const isCaughtEvo = evoSpeciesStarterDexEntry?.caughtAttr ? true : false;
options.push({
label: evo.evoFormKey ?
this.getFormString(evo.evoFormKey, evoSpecies ?? this.lastSpecies, true) :
this.getRegionName(evoSpecies ?? this.lastSpecies),
style: TextStyle.MONEY_WINDOW,
style: isCaughtEvo ? TextStyle.WINDOW : TextStyle.SHADOW_TEXT,
handler: () => {
const newSpecies = allSpecies.find(species => species.speciesId === evo.speciesId);
// Attempts to find the formIndex of the evolved species
@ -1363,6 +1399,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
if (this.battleForms.length > 0) {
options.push({
label: i18next.t("pokedexUiHandler:forms"),
style: TextStyle.MONEY_WINDOW,
skip: true,
handler: () => false
});
@ -1373,7 +1410,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
}
options.push({
label: label,
style: TextStyle.MONEY_WINDOW,
handler: () => {
const newSpecies = this.lastSpecies;
const newFormIndex = bf.formIndex;
@ -1409,15 +1445,25 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
});
});
success = true;
}
break;
case MenuOptions.TOGGLE_IVS:
if (!this.speciesStarterDexEntry?.caughtAttr) {
error = true;
} else {
this.toggleStatsMode();
ui.setMode(Mode.POKEDEX_PAGE, "refresh");
success = true;
}
break;
case MenuOptions.NATURES:
if (!this.speciesStarterDexEntry?.caughtAttr) {
error = true;
} else {
this.blockInput = true;
ui.setMode(Mode.POKEDEX_PAGE, "refresh").then(() => {
ui.showText(i18next.t("pokedexUiHandler:showNature"), null, () => {
@ -1446,11 +1492,10 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
});
});
success = true;
}
break;
}
return true;
} else {
const props = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId));
switch (button) {
@ -1672,6 +1717,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
}
}
console.log(success, error);
if (success) {
ui.playSelect();
} else if (error) {
@ -1787,7 +1833,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.cursorObj.setPositionRelative(this.menuBg, 7, 6 + (18 + this.cursor * 96) * this.scale);
const ui = this.getUi();
if (this.speciesStarterDexEntry?.caughtAttr || (this.speciesStarterDexEntry?.seenAttr && cursor === 5)) {
ui.showText(this.menuDescriptions[cursor]);
} else {
ui.showText("");
}
return ret;
}
@ -1956,7 +2006,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonSprite.setTint(0x808080);
}
} else {
this.pokemonNumberText.setText(padInt(0, 4));
this.pokemonNumberText.setText(species ? padInt(species.speciesId, 4) : "");
this.pokemonNameText.setText(species ? "???" : "");
this.pokemonGrowthRateText.setText("");
this.pokemonGrowthRateLabelText.setVisible(false);
@ -1976,13 +2026,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
female: false,
variant: 0,
});
this.pokemonSprite.clearTint();
this.pokemonSprite.setTint(0x000000);
}
}
setSpeciesDetails(species: PokemonSpecies, options: SpeciesDetails = {}): void {
let { shiny, formIndex, female, variant } = options;
const forSeen: boolean = options.forSeen ?? false;
const oldProps = species ? this.starterAttributes : null;
// We will only update the sprite if there is a change to form, shiny/variant
@ -2056,7 +2105,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.pokemonNumberText.setColor(this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, false));
this.pokemonNumberText.setShadowColor(this.getTextColor(shiny ? TextStyle.SUMMARY_GOLD : TextStyle.SUMMARY, true));
if (forSeen ? this.speciesStarterDexEntry?.seenAttr : this.speciesStarterDexEntry?.caughtAttr) {
const assetLoadCancelled = new BooleanHolder(false);
this.assetLoadCancelled = assetLoadCancelled;
@ -2101,7 +2149,6 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
this.canCycleForm = species.forms.filter(f => f.isStarterSelectable || !pokemonFormChanges[species.speciesId]?.find(fc => fc.formKey))
.map((_, f) => dexEntry.caughtAttr & this.scene.gameData.getFormAttr(f)).filter(f => f).length > 1;
}
if (dexEntry.caughtAttr && species.malePercent !== null) {
const gender = !female ? Gender.MALE : Gender.FEMALE;

View File

@ -1604,8 +1604,6 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.scene.ui.hideTooltip();
}
const starterAttributes : StarterAttributes | null = species ? { ...this.starterPreferences[species.speciesId] } : null;
if (this.lastSpecies) {
const dexAttr = this.getCurrentDexProps(this.lastSpecies.speciesId);
const props = this.getSanitizedProps(this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, dexAttr));
@ -1625,12 +1623,7 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.pokemonNumberText.setText(i18next.t("pokedexUiHandler:pokemonNumber") + padInt(species.speciesId, 4));
if (starterAttributes?.nickname) {
const name = decodeURIComponent(escape(atob(starterAttributes.nickname)));
this.pokemonNameText.setText(name);
} else {
this.pokemonNameText.setText(species.name);
}
if (this.speciesStarterDexEntry?.caughtAttr) {
@ -1654,9 +1647,12 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.setSpeciesDetails(species, {});
this.pokemonSprite.clearTint();
this.type1Icon.clearTint();
this.type2Icon.clearTint();
} else {
this.type1Icon.setVisible(false);
this.type2Icon.setVisible(false);
this.type1Icon.setVisible(true);
this.type2Icon.setVisible(true);
this.setSpeciesDetails(species, {
forSeen: true
@ -1664,11 +1660,14 @@ export default class PokedexUiHandler extends MessageUiHandler {
this.pokemonSprite.setTint(0x808080);
}
} else {
this.pokemonNumberText.setText("");
this.pokemonNumberText.setText(species ? i18next.t("pokedexUiHandler:pokemonNumber") + padInt(species.speciesId, 4) : "");
this.pokemonNameText.setText(species ? "???" : "");
this.type1Icon.setVisible(false);
this.type2Icon.setVisible(false);
this.pokemonSprite.clearTint();
if (species) {
this.pokemonSprite.setTint(0x000000);
this.setSpeciesDetails(species, {});
}
}
}
@ -1718,8 +1717,6 @@ export default class PokedexUiHandler extends MessageUiHandler {
}
}
if (forSeen ? this.speciesStarterDexEntry?.seenAttr : this.speciesStarterDexEntry?.caughtAttr) {
const assetLoadCancelled = new BooleanHolder(false);
this.assetLoadCancelled = assetLoadCancelled;
@ -1740,9 +1737,8 @@ export default class PokedexUiHandler extends MessageUiHandler {
} else {
this.pokemonSprite.setVisible(!(this.filterMode || this.filterTextMode));
}
}
if (dexEntry.caughtAttr) {
if (dexEntry.caughtAttr || forSeen) {
const speciesForm = getPokemonSpeciesForm(species.speciesId, 0); // TODO: always selecting the first form