[UI] fix candy upgrade icon not updating after purchasing eggs (#4153)

This commit is contained in:
MokaStitcher 2024-09-10 20:00:50 +02:00 committed by GitHub
parent 150ab3d1b2
commit d1b058fe3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 31 additions and 22 deletions

View File

@ -1220,6 +1220,19 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
}
}
/**
* Update the display of candy upgrade icons or animations for the given StarterContainer
* @param starterContainer the container for the Pokemon to update
*/
updateCandyUpgradeDisplay(starterContainer: StarterContainer) {
if (this.isUpgradeIconEnabled() ) {
this.setUpgradeIcon(starterContainer);
}
if (this.isUpgradeAnimationEnabled()) {
this.setUpgradeAnimation(starterContainer.icon, this.lastSpecies, true);
}
}
/**
* Processes an {@linkcode CandyUpgradeNotificationChangedEvent} sent when the corresponding setting changes
* @param event {@linkcode Event} sent by the callback
@ -1624,7 +1637,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
}
});
}
const candyCount = starterData.candyCount;
const passiveAttr = starterData.passiveAttr;
if (passiveAttr & PassiveAttr.UNLOCKED) { // this is for enabling and disabling the passive
if (!(passiveAttr & PassiveAttr.ENABLED)) {
@ -1705,8 +1718,13 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
return true;
}
});
const showUseCandies = () => { // this lets you use your candies
// Purchases with Candy
const candyCount = starterData.candyCount;
const showUseCandies = () => {
const options: any[] = []; // TODO: add proper type
// Unlock passive option
if (!(passiveAttr & PassiveAttr.UNLOCKED)) {
const passiveCost = getPassiveCandyCount(speciesStarters[this.lastSpecies.speciesId]);
options.push({
@ -1727,16 +1745,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.setSpeciesDetails(this.lastSpecies);
this.scene.playSound("se/buy");
// if starterContainer exists, update the passive background
// update the passive background and icon/animation for available upgrade
if (starterContainer) {
// Update the candy upgrade display
if (this.isUpgradeIconEnabled() ) {
this.setUpgradeIcon(starterContainer);
}
if (this.isUpgradeAnimationEnabled()) {
this.setUpgradeAnimation(starterContainer.icon, this.lastSpecies, true);
}
this.updateCandyUpgradeDisplay(starterContainer);
starterContainer.starterPassiveBgs.setVisible(!!this.scene.gameData.starterData[this.lastSpecies.speciesId].passiveAttr);
}
return true;
@ -1747,6 +1758,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
itemArgs: starterColors[this.lastSpecies.speciesId]
});
}
// Reduce cost option
const valueReduction = starterData.valueReduction;
if (valueReduction < valueReductionMax) {
const reductionCost = getValueReductionCandyCounts(speciesStarters[this.lastSpecies.speciesId])[valueReduction];
@ -1768,19 +1781,10 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
ui.setMode(Mode.STARTER_SELECT);
this.scene.playSound("se/buy");
// if starterContainer exists, update the value reduction background
// update the value label and icon/animation for available upgrade
if (starterContainer) {
this.updateStarterValueLabel(starterContainer);
// If the notification setting is set to 'On', update the candy upgrade display
if (this.scene.candyUpgradeNotification === 2) {
if (this.isUpgradeIconEnabled() ) {
this.setUpgradeIcon(starterContainer);
}
if (this.isUpgradeAnimationEnabled()) {
this.setUpgradeAnimation(starterContainer.icon, this.lastSpecies, true);
}
}
this.updateCandyUpgradeDisplay(starterContainer);
}
return true;
}
@ -1813,6 +1817,11 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
ui.setMode(Mode.STARTER_SELECT);
this.scene.playSound("se/buy");
// update the icon/animation for available upgrade
if (starterContainer) {
this.updateCandyUpgradeDisplay(starterContainer);
}
return true;
}
return false;