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

View File

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