mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-28 11:12:24 +02:00
Cleaned up "last" from this.species; turning pages now preserves memories of unlocks
This commit is contained in:
parent
060619e13a
commit
8174e1284a
@ -196,8 +196,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
private statsMode: boolean;
|
private statsMode: boolean;
|
||||||
|
|
||||||
private allSpecies: PokemonSpecies[] = [];
|
private allSpecies: PokemonSpecies[] = [];
|
||||||
private lastSpecies: PokemonSpecies;
|
private species: PokemonSpecies;
|
||||||
private lastFormIndex: number;
|
private formIndex: number;
|
||||||
private speciesLoaded: Map<Species, boolean> = new Map<Species, boolean>();
|
private speciesLoaded: Map<Species, boolean> = new Map<Species, boolean>();
|
||||||
private levelMoves: LevelMoves;
|
private levelMoves: LevelMoves;
|
||||||
private eggMoves: Moves[] = [];
|
private eggMoves: Moves[] = [];
|
||||||
@ -234,6 +234,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
private filterInstructionRowY = 0;
|
private filterInstructionRowY = 0;
|
||||||
|
|
||||||
private starterAttributes: StarterAttributes;
|
private starterAttributes: StarterAttributes;
|
||||||
|
private savedStarterAttributes: StarterAttributes;
|
||||||
|
|
||||||
protected blockInput: boolean = false;
|
protected blockInput: boolean = false;
|
||||||
protected blockInputOverlay: boolean = false;
|
protected blockInputOverlay: boolean = false;
|
||||||
@ -551,9 +552,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
if (args.length >= 1 && args[0] === "refresh") {
|
if (args.length >= 1 && args[0] === "refresh") {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
this.lastSpecies = args[0];
|
this.species = args[0];
|
||||||
this.lastFormIndex = args[1] ?? 0;
|
this.formIndex = args[1] ?? 0;
|
||||||
this.starterAttributes = args[2] ?? { shiny:false, female:true, variant:0, form:0 };
|
this.savedStarterAttributes = args[2] ?? { shiny:false, female:true, variant:0, form:0 };
|
||||||
this.starterSetup();
|
this.starterSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,7 +574,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
this.setCursor(0);
|
this.setCursor(0);
|
||||||
|
|
||||||
this.setSpecies(this.lastSpecies);
|
this.setSpecies(this.species);
|
||||||
this.updateInstructions();
|
this.updateInstructions();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -586,8 +587,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.prevolutions = [];
|
this.prevolutions = [];
|
||||||
this.battleForms = [];
|
this.battleForms = [];
|
||||||
|
|
||||||
const species = this.lastSpecies;
|
const species = this.species;
|
||||||
const formIndex = this.lastFormIndex ?? 0;
|
const formIndex = this.formIndex ?? 0;
|
||||||
|
|
||||||
const allEvolutions = pokemonEvolutions.hasOwnProperty(species.speciesId) ? pokemonEvolutions[species.speciesId] : [];
|
const allEvolutions = pokemonEvolutions.hasOwnProperty(species.speciesId) ? pokemonEvolutions[species.speciesId] : [];
|
||||||
|
|
||||||
@ -644,9 +645,9 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.biomes = this.sanitizeBiomes(allBiomes, species.speciesId);
|
this.biomes = this.sanitizeBiomes(allBiomes, species.speciesId);
|
||||||
|
|
||||||
const allFormChanges = pokemonFormChanges.hasOwnProperty(species.speciesId) ? pokemonFormChanges[species.speciesId] : [];
|
const allFormChanges = pokemonFormChanges.hasOwnProperty(species.speciesId) ? pokemonFormChanges[species.speciesId] : [];
|
||||||
this.battleForms = allFormChanges.filter(f => (f.preFormKey === this.lastSpecies.forms[this.lastFormIndex].formKey));
|
this.battleForms = allFormChanges.filter(f => (f.preFormKey === this.species.forms[this.formIndex].formKey));
|
||||||
|
|
||||||
const preSpecies = pokemonPrevolutions.hasOwnProperty(this.lastSpecies.speciesId) ? allSpecies.find(sp => sp.speciesId === pokemonPrevolutions[this.lastSpecies.speciesId]) : null;
|
const preSpecies = pokemonPrevolutions.hasOwnProperty(this.species.speciesId) ? allSpecies.find(sp => sp.speciesId === pokemonPrevolutions[this.species.speciesId]) : null;
|
||||||
if (preSpecies) {
|
if (preSpecies) {
|
||||||
const preEvolutions = pokemonEvolutions.hasOwnProperty(preSpecies.speciesId) ? pokemonEvolutions[preSpecies.speciesId] : [];
|
const preEvolutions = pokemonEvolutions.hasOwnProperty(preSpecies.speciesId) ? pokemonEvolutions[preSpecies.speciesId] : [];
|
||||||
this.prevolutions = preEvolutions.filter(
|
this.prevolutions = preEvolutions.filter(
|
||||||
@ -669,7 +670,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
return this.lastFormIndex === formIndex;
|
return this.formIndex === formIndex;
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (speciesId === Species.ROTOM) {
|
} else if (speciesId === Species.ROTOM) {
|
||||||
@ -690,7 +691,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
return this.lastFormIndex === formIndex;
|
return this.formIndex === formIndex;
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (speciesId === Species.LYCANROC) {
|
} else if (speciesId === Species.LYCANROC) {
|
||||||
@ -708,7 +709,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
return this.lastFormIndex === formIndex;
|
return this.formIndex === formIndex;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,8 +725,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
* @returns StarterAttributes for the species
|
* @returns StarterAttributes for the species
|
||||||
*/
|
*/
|
||||||
initStarterPrefs(): StarterAttributes {
|
initStarterPrefs(): StarterAttributes {
|
||||||
const starterAttributes = this.starterAttributes;
|
const starterAttributes : StarterAttributes | null = this.species ? { ...this.savedStarterAttributes } : null;
|
||||||
const dexEntry = globalScene.gameData.dexData[this.lastSpecies.speciesId];
|
const dexEntry = globalScene.gameData.dexData[this.species.speciesId];
|
||||||
|
|
||||||
// no preferences or Pokemon wasn't caught, return empty attribute
|
// no preferences or Pokemon wasn't caught, return empty attribute
|
||||||
if (!starterAttributes || !dexEntry.caughtAttr) {
|
if (!starterAttributes || !dexEntry.caughtAttr) {
|
||||||
@ -751,9 +752,17 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
hasShiny && caughtAttr & DexAttr.VARIANT_2,
|
hasShiny && caughtAttr & DexAttr.VARIANT_2,
|
||||||
hasShiny && caughtAttr & DexAttr.VARIANT_3
|
hasShiny && caughtAttr & DexAttr.VARIANT_3
|
||||||
];
|
];
|
||||||
if (isNaN(starterAttributes.variant) || starterAttributes.variant < 0 || !unlockedVariants[starterAttributes.variant]) {
|
if (isNaN(starterAttributes.variant) || starterAttributes.variant < 0) {
|
||||||
// variant value is invalid or requested variant wasn't unlocked, purging setting
|
|
||||||
starterAttributes.variant = 0;
|
starterAttributes.variant = 0;
|
||||||
|
} else if (!unlockedVariants[starterAttributes.variant]) {
|
||||||
|
let highestValidIndex = -1;
|
||||||
|
for (let i = 0; i <= starterAttributes.variant && i < unlockedVariants.length; i++) {
|
||||||
|
if (unlockedVariants[i] !== 0n) {
|
||||||
|
highestValidIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Set to the highest valid index found or default to 0
|
||||||
|
starterAttributes.variant = highestValidIndex !== -1 ? highestValidIndex : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,7 +774,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const selectedForm = starterAttributes.form;
|
const selectedForm = starterAttributes.form;
|
||||||
if (selectedForm !== undefined && (this.lastSpecies.forms[selectedForm]?.isStarterSelectable && !(caughtAttr & globalScene.gameData.getFormAttr(selectedForm)))) {
|
if (selectedForm !== undefined && (this.species.forms[selectedForm]?.isStarterSelectable && !(caughtAttr & globalScene.gameData.getFormAttr(selectedForm)))) {
|
||||||
// requested form wasn't unlocked and is selectable as a starter
|
// requested form wasn't unlocked and is selectable as a starter
|
||||||
delete starterAttributes.form;
|
delete starterAttributes.form;
|
||||||
}
|
}
|
||||||
@ -886,7 +895,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(this.lastSpecies.speciesId)];
|
const starterData = globalScene.gameData.starterData[this.getStarterSpeciesId(this.species.speciesId)];
|
||||||
// prepare persistent starter data to store changes
|
// prepare persistent starter data to store changes
|
||||||
const starterAttributes = this.starterAttributes;
|
const starterAttributes = this.starterAttributes;
|
||||||
|
|
||||||
@ -1281,7 +1290,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
handler: () => false
|
handler: () => false
|
||||||
});
|
});
|
||||||
this.prevolutions.map(pre => {
|
this.prevolutions.map(pre => {
|
||||||
const preSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[this.lastSpecies.speciesId]);
|
const preSpecies = allSpecies.find(species => species.speciesId === pokemonPrevolutions[this.species.speciesId]);
|
||||||
|
|
||||||
let conditionText:string = "";
|
let conditionText:string = "";
|
||||||
if (pre.condition) {
|
if (pre.condition) {
|
||||||
@ -1297,18 +1306,19 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
options.push({
|
options.push({
|
||||||
label: pre.preFormKey ?
|
label: pre.preFormKey ?
|
||||||
this.getFormString(pre.preFormKey, preSpecies ?? this.lastSpecies, true) :
|
this.getFormString(pre.preFormKey, preSpecies ?? this.species, true) :
|
||||||
this.getRegionName(preSpecies ?? this.lastSpecies),
|
this.getRegionName(preSpecies ?? this.species),
|
||||||
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
|
||||||
const newFormKey = pre.evoFormKey ? pre.evoFormKey : (this.lastSpecies.forms.length > 0 ? this.lastSpecies.forms[this.lastFormIndex].formKey : "");
|
const newFormKey = pre.evoFormKey ? pre.evoFormKey : (this.species.forms.length > 0 ? this.species.forms[this.formIndex].formKey : "");
|
||||||
const matchingForm = newSpecies?.forms.find(form => form.formKey === newFormKey);
|
const matchingForm = newSpecies?.forms.find(form => form.formKey === newFormKey);
|
||||||
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
||||||
this.starterAttributes.form = newFormIndex;
|
this.starterAttributes.form = newFormIndex;
|
||||||
|
this.savedStarterAttributes.form = newFormIndex;
|
||||||
this.moveInfoOverlay.clear();
|
this.moveInfoOverlay.clear();
|
||||||
this.clearText();
|
this.clearText();
|
||||||
ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.starterAttributes);
|
ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
onHover: () => this.showText(conditionText)
|
onHover: () => this.showText(conditionText)
|
||||||
@ -1342,19 +1352,20 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
options.push({
|
options.push({
|
||||||
label: evo.evoFormKey ?
|
label: evo.evoFormKey ?
|
||||||
this.getFormString(evo.evoFormKey, evoSpecies ?? this.lastSpecies, true) :
|
this.getFormString(evo.evoFormKey, evoSpecies ?? this.species, true) :
|
||||||
this.getRegionName(evoSpecies ?? this.lastSpecies),
|
this.getRegionName(evoSpecies ?? this.species),
|
||||||
style: isCaughtEvo ? TextStyle.WINDOW : TextStyle.SHADOW_TEXT,
|
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
|
||||||
const newFormKey = evo.evoFormKey ? evo.evoFormKey : (this.lastSpecies.forms.length > 0 ? this.lastSpecies.forms[this.lastFormIndex].formKey : "");
|
const newFormKey = evo.evoFormKey ? evo.evoFormKey : (this.species.forms.length > 0 ? this.species.forms[this.formIndex].formKey : "");
|
||||||
const matchingForm = newSpecies?.forms.find(form => form.formKey === newFormKey);
|
const matchingForm = newSpecies?.forms.find(form => form.formKey === newFormKey);
|
||||||
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
||||||
this.starterAttributes.form = newFormIndex;
|
this.starterAttributes.form = newFormIndex;
|
||||||
|
this.savedStarterAttributes.form = newFormIndex;
|
||||||
this.moveInfoOverlay.clear();
|
this.moveInfoOverlay.clear();
|
||||||
this.clearText();
|
this.clearText();
|
||||||
ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.starterAttributes);
|
ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
onHover: () => this.showText(conditionText)
|
onHover: () => this.showText(conditionText)
|
||||||
@ -1380,19 +1391,20 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
} else {
|
} else {
|
||||||
conditionText = "";
|
conditionText = "";
|
||||||
}
|
}
|
||||||
let label: string = this.getFormString(bf.formKey, this.lastSpecies);
|
let label: string = this.getFormString(bf.formKey, this.species);
|
||||||
if (label === "") {
|
if (label === "") {
|
||||||
label = this.lastSpecies.name;
|
label = this.species.name;
|
||||||
}
|
}
|
||||||
options.push({
|
options.push({
|
||||||
label: label,
|
label: label,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
const newSpecies = this.lastSpecies;
|
const newSpecies = this.species;
|
||||||
const newFormIndex = this.lastSpecies.forms.find(f => f.formKey === bf.formKey)?.formIndex;
|
const newFormIndex = this.species.forms.find(f => f.formKey === bf.formKey)?.formIndex;
|
||||||
this.starterAttributes.form = newFormIndex;
|
this.starterAttributes.form = newFormIndex;
|
||||||
|
this.savedStarterAttributes.form = newFormIndex;
|
||||||
this.moveInfoOverlay.clear();
|
this.moveInfoOverlay.clear();
|
||||||
this.clearText();
|
this.clearText();
|
||||||
ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.starterAttributes);
|
ui.setMode(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
onHover: () => this.showText(conditionText)
|
onHover: () => this.showText(conditionText)
|
||||||
@ -1474,16 +1486,17 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const props = globalScene.gameData.getSpeciesDexAttrProps(this.lastSpecies, this.getCurrentDexProps(this.lastSpecies.speciesId));
|
const props = globalScene.gameData.getSpeciesDexAttrProps(this.species, this.getCurrentDexProps(this.species.speciesId));
|
||||||
switch (button) {
|
switch (button) {
|
||||||
case Button.CYCLE_SHINY:
|
case Button.CYCLE_SHINY:
|
||||||
if (this.canCycleShiny) {
|
if (this.canCycleShiny) {
|
||||||
starterAttributes.shiny = starterAttributes.shiny !== undefined ? !starterAttributes.shiny : false;
|
starterAttributes.shiny = starterAttributes.shiny !== undefined ? !starterAttributes.shiny : false;
|
||||||
|
this.savedStarterAttributes.shiny = starterAttributes.shiny;
|
||||||
|
|
||||||
if (starterAttributes.shiny) {
|
if (starterAttributes.shiny) {
|
||||||
// Change to shiny, we need to get the proper default variant
|
// Change to shiny, we need to get the proper default variant
|
||||||
const newVariant = starterAttributes.variant ? starterAttributes.variant as Variant : 0;
|
const newVariant = starterAttributes.variant ? starterAttributes.variant as Variant : 0;
|
||||||
this.setSpeciesDetails(this.lastSpecies, { shiny: true, variant: newVariant });
|
this.setSpeciesDetails(this.species, { shiny: true, variant: newVariant });
|
||||||
|
|
||||||
globalScene.playSound("se/sparkle");
|
globalScene.playSound("se/sparkle");
|
||||||
// Set the variant label to the shiny tint
|
// Set the variant label to the shiny tint
|
||||||
@ -1492,7 +1505,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.pokemonShinyIcon.setTint(tint);
|
this.pokemonShinyIcon.setTint(tint);
|
||||||
this.pokemonShinyIcon.setVisible(true);
|
this.pokemonShinyIcon.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
this.setSpeciesDetails(this.lastSpecies, { shiny: false, variant: 0 });
|
this.setSpeciesDetails(this.species, { shiny: false, variant: 0 });
|
||||||
this.pokemonShinyIcon.setVisible(false);
|
this.pokemonShinyIcon.setVisible(false);
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@ -1518,7 +1531,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
} while (newVariant !== props.variant);
|
} while (newVariant !== props.variant);
|
||||||
starterAttributes.variant = newVariant; // store the selected variant
|
starterAttributes.variant = newVariant; // store the selected variant
|
||||||
this.setSpeciesDetails(this.lastSpecies, { variant: newVariant as Variant });
|
this.savedStarterAttributes.variant = starterAttributes.variant;
|
||||||
|
this.setSpeciesDetails(this.species, { variant: newVariant as Variant });
|
||||||
// Cycle tint based on current sprite tint
|
// Cycle tint based on current sprite tint
|
||||||
const tint = getVariantTint(newVariant as Variant);
|
const tint = getVariantTint(newVariant as Variant);
|
||||||
this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant as Variant));
|
this.pokemonShinyIcon.setFrame(getVariantIcon(newVariant as Variant));
|
||||||
@ -1528,8 +1542,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
break;
|
break;
|
||||||
case Button.CYCLE_FORM:
|
case Button.CYCLE_FORM:
|
||||||
if (this.canCycleForm) {
|
if (this.canCycleForm) {
|
||||||
const formCount = this.lastSpecies.forms.length;
|
const formCount = this.species.forms.length;
|
||||||
let newFormIndex = this.lastFormIndex;
|
let newFormIndex = this.formIndex;
|
||||||
do {
|
do {
|
||||||
newFormIndex = (newFormIndex + 1) % formCount;
|
newFormIndex = (newFormIndex + 1) % formCount;
|
||||||
if (this.speciesStarterDexEntry!.caughtAttr! & globalScene.gameData.getFormAttr(newFormIndex)) { // TODO: are those bangs correct?
|
if (this.speciesStarterDexEntry!.caughtAttr! & globalScene.gameData.getFormAttr(newFormIndex)) { // TODO: are those bangs correct?
|
||||||
@ -1538,16 +1552,18 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
} while (newFormIndex !== props.formIndex);
|
} while (newFormIndex !== props.formIndex);
|
||||||
// TODO: Is this still needed?
|
// TODO: Is this still needed?
|
||||||
starterAttributes.form = newFormIndex; // store the selected form
|
starterAttributes.form = newFormIndex; // store the selected form
|
||||||
this.lastFormIndex = newFormIndex;
|
this.savedStarterAttributes.form = starterAttributes.form;
|
||||||
|
this.formIndex = newFormIndex;
|
||||||
this.starterSetup();
|
this.starterSetup();
|
||||||
this.setSpeciesDetails(this.lastSpecies, { formIndex: newFormIndex });
|
this.setSpeciesDetails(this.species, { formIndex: newFormIndex });
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Button.CYCLE_GENDER:
|
case Button.CYCLE_GENDER:
|
||||||
if (this.canCycleGender) {
|
if (this.canCycleGender) {
|
||||||
starterAttributes.female = !props.female;
|
starterAttributes.female = !props.female;
|
||||||
this.setSpeciesDetails(this.lastSpecies, { female: !props.female });
|
this.savedStarterAttributes.female = starterAttributes.female;
|
||||||
|
this.setSpeciesDetails(this.species, { female: !props.female });
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1561,11 +1577,11 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
const passiveAttr = starterData.passiveAttr;
|
const passiveAttr = starterData.passiveAttr;
|
||||||
const candyCount = starterData.candyCount;
|
const candyCount = starterData.candyCount;
|
||||||
|
|
||||||
if (!pokemonPrevolutions.hasOwnProperty(this.lastSpecies.speciesId)) {
|
if (!pokemonPrevolutions.hasOwnProperty(this.species.speciesId)) {
|
||||||
if (!(passiveAttr & PassiveAttr.UNLOCKED)) {
|
if (!(passiveAttr & PassiveAttr.UNLOCKED)) {
|
||||||
const passiveCost = getPassiveCandyCount(speciesStarterCosts[this.getStarterSpeciesId(this.lastSpecies.speciesId)]);
|
const passiveCost = getPassiveCandyCount(speciesStarterCosts[this.getStarterSpeciesId(this.species.speciesId)]);
|
||||||
options.push({
|
options.push({
|
||||||
label: `x${passiveCost} ${i18next.t("pokedexUiHandler:unlockPassive")} (${allAbilities[starterPassiveAbilities[this.getStarterSpeciesId(this.lastSpecies.speciesId)]].name})`,
|
label: `x${passiveCost} ${i18next.t("pokedexUiHandler:unlockPassive")} (${allAbilities[starterPassiveAbilities[this.getStarterSpeciesId(this.species.speciesId)]].name})`,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= passiveCost) {
|
if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= passiveCost) {
|
||||||
starterData.passiveAttr |= PassiveAttr.UNLOCKED | PassiveAttr.ENABLED;
|
starterData.passiveAttr |= PassiveAttr.UNLOCKED | PassiveAttr.ENABLED;
|
||||||
@ -1579,7 +1595,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
ui.setMode(Mode.POKEDEX_PAGE, "refresh");
|
ui.setMode(Mode.POKEDEX_PAGE, "refresh");
|
||||||
this.setSpeciesDetails(this.lastSpecies);
|
this.setSpeciesDetails(this.species);
|
||||||
globalScene.playSound("se/buy");
|
globalScene.playSound("se/buy");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1587,14 +1603,14 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
item: "candy",
|
item: "candy",
|
||||||
itemArgs: starterColors[this.getStarterSpeciesId(this.lastSpecies.speciesId)]
|
itemArgs: starterColors[this.getStarterSpeciesId(this.species.speciesId)]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce cost option
|
// Reduce cost option
|
||||||
const valueReduction = starterData.valueReduction;
|
const valueReduction = starterData.valueReduction;
|
||||||
if (valueReduction < valueReductionMax) {
|
if (valueReduction < valueReductionMax) {
|
||||||
const reductionCost = getValueReductionCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(this.lastSpecies.speciesId)])[valueReduction];
|
const reductionCost = getValueReductionCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(this.species.speciesId)])[valueReduction];
|
||||||
options.push({
|
options.push({
|
||||||
label: `x${reductionCost} ${i18next.t("pokedexUiHandler:reduceCost")}`,
|
label: `x${reductionCost} ${i18next.t("pokedexUiHandler:reduceCost")}`,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
@ -1617,12 +1633,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
item: "candy",
|
item: "candy",
|
||||||
itemArgs: starterColors[this.getStarterSpeciesId(this.lastSpecies.speciesId)]
|
itemArgs: starterColors[this.getStarterSpeciesId(this.species.speciesId)]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same species egg menu option.
|
// Same species egg menu option.
|
||||||
const sameSpeciesEggCost = getSameSpeciesEggCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(this.lastSpecies.speciesId)]);
|
const sameSpeciesEggCost = getSameSpeciesEggCandyCounts(speciesStarterCosts[this.getStarterSpeciesId(this.species.speciesId)]);
|
||||||
options.push({
|
options.push({
|
||||||
label: `x${sameSpeciesEggCost} ${i18next.t("pokedexUiHandler:sameSpeciesEgg")}`,
|
label: `x${sameSpeciesEggCost} ${i18next.t("pokedexUiHandler:sameSpeciesEgg")}`,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
@ -1637,7 +1653,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
this.pokemonCandyCountText.setText(`x${starterData.candyCount}`);
|
this.pokemonCandyCountText.setText(`x${starterData.candyCount}`);
|
||||||
|
|
||||||
const egg = new Egg({ scene: globalScene, species: this.lastSpecies.speciesId, sourceType: EggSourceType.SAME_SPECIES_EGG });
|
const egg = new Egg({ scene: globalScene, species: this.species.speciesId, sourceType: EggSourceType.SAME_SPECIES_EGG });
|
||||||
egg.addEggToGameData();
|
egg.addEggToGameData();
|
||||||
|
|
||||||
globalScene.gameData.saveSystem().then(success => {
|
globalScene.gameData.saveSystem().then(success => {
|
||||||
@ -1653,7 +1669,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
item: "candy",
|
item: "candy",
|
||||||
itemArgs: starterColors[this.getStarterSpeciesId(this.lastSpecies.speciesId)]
|
itemArgs: starterColors[this.getStarterSpeciesId(this.species.speciesId)]
|
||||||
});
|
});
|
||||||
options.push({
|
options.push({
|
||||||
label: i18next.t("menu:cancel"),
|
label: i18next.t("menu:cancel"),
|
||||||
@ -1689,31 +1705,33 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
case Button.LEFT:
|
case Button.LEFT:
|
||||||
this.blockInput = true;
|
this.blockInput = true;
|
||||||
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
||||||
const index = allSpecies.findIndex(species => species.speciesId === this.lastSpecies.speciesId);
|
const index = allSpecies.findIndex(species => species.speciesId === this.species.speciesId);
|
||||||
const newIndex = index <= 0 ? allSpecies.length - 1 : index - 1;
|
const newIndex = index <= 0 ? allSpecies.length - 1 : index - 1;
|
||||||
const newSpecies = allSpecies[newIndex];
|
const newSpecies = allSpecies[newIndex];
|
||||||
// Attempts to find the formIndex of the evolved species
|
// Attempts to find the formIndex of the evolved species
|
||||||
const matchingForm = newSpecies?.forms.find(form => form.formKey === this.lastSpecies?.forms[this.lastFormIndex]?.formKey);
|
const matchingForm = newSpecies?.forms.find(form => form.formKey === this.species?.forms[this.formIndex]?.formKey);
|
||||||
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
||||||
this.starterAttributes.form = newFormIndex;
|
this.starterAttributes.form = newFormIndex;
|
||||||
|
this.savedStarterAttributes.form = newFormIndex;
|
||||||
this.moveInfoOverlay.clear();
|
this.moveInfoOverlay.clear();
|
||||||
this.clearText();
|
this.clearText();
|
||||||
ui.setModeForceTransition(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.starterAttributes);
|
ui.setModeForceTransition(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes);
|
||||||
});
|
});
|
||||||
this.blockInput = false;
|
this.blockInput = false;
|
||||||
break;
|
break;
|
||||||
case Button.RIGHT:
|
case Button.RIGHT:
|
||||||
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
ui.setModeWithoutClear(Mode.OPTION_SELECT).then(() => {
|
||||||
const index = allSpecies.findIndex(species => species.speciesId === this.lastSpecies.speciesId);
|
const index = allSpecies.findIndex(species => species.speciesId === this.species.speciesId);
|
||||||
const newIndex = index >= allSpecies.length - 1 ? 0 : index + 1;
|
const newIndex = index >= allSpecies.length - 1 ? 0 : index + 1;
|
||||||
const newSpecies = allSpecies[newIndex];
|
const newSpecies = allSpecies[newIndex];
|
||||||
// Attempts to find the formIndex of the evolved species
|
// Attempts to find the formIndex of the evolved species
|
||||||
const matchingForm = newSpecies?.forms.find(form => form.formKey === this.lastSpecies?.forms[this.lastFormIndex]?.formKey);
|
const matchingForm = newSpecies?.forms.find(form => form.formKey === this.species?.forms[this.formIndex]?.formKey);
|
||||||
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
const newFormIndex = matchingForm ? matchingForm.formIndex : 0;
|
||||||
this.starterAttributes.form = newFormIndex;
|
this.starterAttributes.form = newFormIndex;
|
||||||
|
this.savedStarterAttributes.form = newFormIndex;
|
||||||
this.moveInfoOverlay.clear();
|
this.moveInfoOverlay.clear();
|
||||||
this.clearText();
|
this.clearText();
|
||||||
ui.setModeForceTransition(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.starterAttributes);
|
ui.setModeForceTransition(Mode.POKEDEX_PAGE, newSpecies, newFormIndex, this.savedStarterAttributes);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1787,7 +1805,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.speciesStarterDexEntry?.caughtAttr) {
|
if (this.speciesStarterDexEntry?.caughtAttr) {
|
||||||
if (!pokemonPrevolutions.hasOwnProperty(this.lastSpecies.speciesId)) {
|
if (!pokemonPrevolutions.hasOwnProperty(this.species.speciesId)) {
|
||||||
this.updateButtonIcon(SettingKeyboard.Button_Stats, gamepadType, this.candyUpgradeIconElement, this.candyUpgradeLabel);
|
this.updateButtonIcon(SettingKeyboard.Button_Stats, gamepadType, this.candyUpgradeIconElement, this.candyUpgradeLabel);
|
||||||
}
|
}
|
||||||
if (this.canCycleShiny) {
|
if (this.canCycleShiny) {
|
||||||
@ -1857,13 +1875,12 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
|
|
||||||
setSpecies(species: PokemonSpecies | null) {
|
setSpecies(species: PokemonSpecies | null) {
|
||||||
this.speciesStarterDexEntry = species ? globalScene.gameData.dexData[species.speciesId] : null;
|
this.speciesStarterDexEntry = species ? globalScene.gameData.dexData[species.speciesId] : null;
|
||||||
|
const starterAttributes : StarterAttributes | null = species ? { ...this.starterAttributes } : null;
|
||||||
|
|
||||||
if (!species && globalScene.ui.getTooltip().visible) {
|
if (!species && globalScene.ui.getTooltip().visible) {
|
||||||
globalScene.ui.hideTooltip();
|
globalScene.ui.hideTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
const starterAttributes : StarterAttributes | null = species ? { ...this.starterAttributes } : null;
|
|
||||||
|
|
||||||
if (this.statsMode) {
|
if (this.statsMode) {
|
||||||
if (this.speciesStarterDexEntry?.caughtAttr) {
|
if (this.speciesStarterDexEntry?.caughtAttr) {
|
||||||
this.statsContainer.setVisible(true);
|
this.statsContainer.setVisible(true);
|
||||||
@ -1875,7 +1892,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastSpecies = species!; // TODO: is this bang correct?
|
this.species = species!; // TODO: is this bang correct?
|
||||||
|
|
||||||
if (species && (this.speciesStarterDexEntry?.seenAttr || this.speciesStarterDexEntry?.caughtAttr)) {
|
if (species && (this.speciesStarterDexEntry?.seenAttr || this.speciesStarterDexEntry?.caughtAttr)) {
|
||||||
this.pokemonNumberText.setText(padInt(species.speciesId, 4));
|
this.pokemonNumberText.setText(padInt(species.speciesId, 4));
|
||||||
@ -1946,7 +1963,7 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
this.pokemonHatchedIcon.setVisible(true);
|
this.pokemonHatchedIcon.setVisible(true);
|
||||||
this.pokemonHatchedCountText.setVisible(true);
|
this.pokemonHatchedCountText.setVisible(true);
|
||||||
|
|
||||||
const { currentFriendship, friendshipCap } = this.getFriendship(this.lastSpecies.speciesId);
|
const { currentFriendship, friendshipCap } = this.getFriendship(this.species.speciesId);
|
||||||
const candyCropY = 16 - (16 * (currentFriendship / friendshipCap));
|
const candyCropY = 16 - (16 * (currentFriendship / friendshipCap));
|
||||||
this.pokemonCandyDarknessOverlay.setCrop(0, 0, 16, candyCropY);
|
this.pokemonCandyDarknessOverlay.setCrop(0, 0, 16, candyCropY);
|
||||||
|
|
||||||
@ -2043,8 +2060,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
|| !isNullOrUndefined(formIndex) || !isNullOrUndefined(shiny) || !isNullOrUndefined(variant);
|
|| !isNullOrUndefined(formIndex) || !isNullOrUndefined(shiny) || !isNullOrUndefined(variant);
|
||||||
|
|
||||||
if (this.activeTooltip === "CANDY") {
|
if (this.activeTooltip === "CANDY") {
|
||||||
if (this.lastSpecies && this.pokemonCandyContainer.visible) {
|
if (this.species && this.pokemonCandyContainer.visible) {
|
||||||
const { currentFriendship, friendshipCap } = this.getFriendship(this.lastSpecies.speciesId);
|
const { currentFriendship, friendshipCap } = this.getFriendship(this.species.speciesId);
|
||||||
globalScene.ui.editTooltip("", `${currentFriendship}/${friendshipCap}`);
|
globalScene.ui.editTooltip("", `${currentFriendship}/${friendshipCap}`);
|
||||||
} else {
|
} else {
|
||||||
globalScene.ui.hideTooltip();
|
globalScene.ui.hideTooltip();
|
||||||
@ -2163,8 +2180,8 @@ export default class PokedexPageUiHandler extends MessageUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dexEntry.caughtAttr) {
|
if (dexEntry.caughtAttr) {
|
||||||
this.lastSpecies.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => {
|
this.species.loadAssets(female!, formIndex, shiny, variant as Variant, true).then(() => {
|
||||||
const crier = (this.lastSpecies.forms && this.lastSpecies.forms.length > 0) ? this.lastSpecies.forms[formIndex ?? this.lastFormIndex] : this.lastSpecies;
|
const crier = (this.species.forms && this.species.forms.length > 0) ? this.species.forms[formIndex ?? this.formIndex] : this.species;
|
||||||
crier.cry();
|
crier.cry();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user