From 91013cf8c425c0ceeabcb2783b1d16f75578ddd5 Mon Sep 17 00:00:00 2001
From: Benjamin Odom <bennybroseph@gmail.com>
Date: Tue, 28 May 2024 14:22:59 -0500
Subject: [PATCH] Candy Icon Display Bugfix (#1507)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes a small visual issue where scrolling through a list of Pokémon would not hide a candy if the Pokémon was not the root species.
---
 src/ui/starter-select-ui-handler.ts | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts
index 7ccb5d11e59..6bc1479f60f 100644
--- a/src/ui/starter-select-ui-handler.ts
+++ b/src/ui/starter-select-ui-handler.ts
@@ -855,7 +855,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
 
     if (!species // No Pokemon exists at that UI index
       || this.scene.candyUpgradeNotification === 0 // Notification setting is 'Off'
-      || species?.getRootSpeciesId(false) !== species?.speciesId) { // Pokemon is not the base evolution and can't use candy
+      || species.speciesId !== species.getRootSpeciesId(false)) { // Pokemon is not the base evolution and can't use candy
       // Set all icons as hidden and exit early
       this.candyUpgradeIcon[index].setVisible(false);
       this.candyUpgradeOverlayIcon[index].setVisible(false);
@@ -1516,9 +1516,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
         this.hiddenAbilityIcons[s].setVisible(slotVisible && !!this.scene.gameData.dexData[speciesId].caughtAttr && !!(this.scene.gameData.starterData[speciesId].abilityAttr & 4));
         this.classicWinIcons[s].setVisible(slotVisible && this.scene.gameData.starterData[speciesId].classicWinCount > 0);
 
-        const species = this.genSpecies[genCursorWithScroll][s];
         // 'Candy Icon' mode
-        if (this.scene.candyUpgradeDisplay === 0 && species?.getRootSpeciesId(false) === species?.speciesId) {
+        if (this.scene.candyUpgradeDisplay === 0) {
 
           if (!starterColors[speciesId]) {
             // Default to white if no colors are found