mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 15:03:24 +02:00
[Beta][Bug][UI/UX] Fix broken candy upgrades (#6322)
* Candy upgrades change permanent starter data again * Updating cost icon and passive bg in starter select after buying pokédex upgrades
This commit is contained in:
parent
01cd11e731
commit
39b2d9865a
@ -1823,9 +1823,13 @@ export class StarterSelectUiHandler extends MessageUiHandler {
|
||||
}
|
||||
} else {
|
||||
let starterContainer: StarterContainer;
|
||||
// The temporary, duplicated starter data to show info
|
||||
const starterData = this.getSpeciesData(this.lastSpecies.speciesId).starterDataEntry;
|
||||
// prepare persistent starter data to store changes
|
||||
// The persistent starter data to apply e.g. candy upgrades
|
||||
const persistentStarterData = globalScene.gameData.starterData[this.lastSpecies.speciesId];
|
||||
// The sanitized starter preferences
|
||||
let starterAttributes = this.starterPreferences[this.lastSpecies.speciesId];
|
||||
// The original starter preferences
|
||||
const originalStarterAttributes = this.originalStarterPreferences[this.lastSpecies.speciesId];
|
||||
|
||||
// this gets the correct pokemon cursor depending on whether you're in the starter screen or the party icons
|
||||
@ -2189,9 +2193,11 @@ export class StarterSelectUiHandler extends MessageUiHandler {
|
||||
label: `×${passiveCost} ${i18next.t("starterSelectUiHandler:unlockPassive")}`,
|
||||
handler: () => {
|
||||
if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= passiveCost) {
|
||||
starterData.passiveAttr |= PassiveAttr.UNLOCKED | PassiveAttr.ENABLED;
|
||||
persistentStarterData.passiveAttr |= PassiveAttr.UNLOCKED | PassiveAttr.ENABLED;
|
||||
starterData.passiveAttr = persistentStarterData.passiveAttr;
|
||||
if (!Overrides.FREE_CANDY_UPGRADE_OVERRIDE) {
|
||||
starterData.candyCount -= passiveCost;
|
||||
persistentStarterData.candyCount -= passiveCost;
|
||||
starterData.candyCount = persistentStarterData.candyCount;
|
||||
}
|
||||
this.pokemonCandyCountText.setText(`×${starterData.candyCount}`);
|
||||
globalScene.gameData.saveSystem().then(success => {
|
||||
@ -2206,9 +2212,7 @@ export class StarterSelectUiHandler extends MessageUiHandler {
|
||||
// update the passive background and icon/animation for available upgrade
|
||||
if (starterContainer) {
|
||||
this.updateCandyUpgradeDisplay(starterContainer);
|
||||
starterContainer.starterPassiveBgs.setVisible(
|
||||
!!globalScene.gameData.starterData[this.lastSpecies.speciesId].passiveAttr,
|
||||
);
|
||||
starterContainer.starterPassiveBgs.setVisible(!!starterData.passiveAttr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -2229,9 +2233,11 @@ export class StarterSelectUiHandler extends MessageUiHandler {
|
||||
label: `×${reductionCost} ${i18next.t("starterSelectUiHandler:reduceCost")}`,
|
||||
handler: () => {
|
||||
if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= reductionCost) {
|
||||
starterData.valueReduction++;
|
||||
persistentStarterData.valueReduction++;
|
||||
starterData.valueReduction = persistentStarterData.valueReduction;
|
||||
if (!Overrides.FREE_CANDY_UPGRADE_OVERRIDE) {
|
||||
starterData.candyCount -= reductionCost;
|
||||
persistentStarterData.candyCount -= reductionCost;
|
||||
starterData.candyCount = persistentStarterData.candyCount;
|
||||
}
|
||||
this.pokemonCandyCountText.setText(`×${starterData.candyCount}`);
|
||||
globalScene.gameData.saveSystem().then(success => {
|
||||
@ -2277,7 +2283,8 @@ export class StarterSelectUiHandler extends MessageUiHandler {
|
||||
return false;
|
||||
}
|
||||
if (!Overrides.FREE_CANDY_UPGRADE_OVERRIDE) {
|
||||
starterData.candyCount -= sameSpeciesEggCost;
|
||||
persistentStarterData.candyCount -= sameSpeciesEggCost;
|
||||
starterData.candyCount = persistentStarterData.candyCount;
|
||||
}
|
||||
this.pokemonCandyCountText.setText(`×${starterData.candyCount}`);
|
||||
|
||||
@ -2329,7 +2336,18 @@ export class StarterSelectUiHandler extends MessageUiHandler {
|
||||
form: starterAttributes.form,
|
||||
female: starterAttributes.female,
|
||||
};
|
||||
ui.setOverlayMode(UiMode.POKEDEX_PAGE, this.lastSpecies, attributes);
|
||||
ui.setOverlayMode(UiMode.POKEDEX_PAGE, this.lastSpecies, attributes, null, null, () => {
|
||||
if (this.lastSpecies) {
|
||||
starterContainer = this.filteredStarterContainers[this.cursor];
|
||||
const persistentStarterData = globalScene.gameData.starterData[this.lastSpecies.speciesId];
|
||||
this.updateCandyUpgradeDisplay(starterContainer);
|
||||
this.updateStarterValueLabel(starterContainer);
|
||||
starterContainer.starterPassiveBgs.setVisible(
|
||||
!!persistentStarterData.passiveAttr && !globalScene.gameMode.hasChallenge(Challenges.FRESH_START),
|
||||
);
|
||||
this.setSpecies(this.lastSpecies);
|
||||
}
|
||||
});
|
||||
});
|
||||
return true;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user