From 9a2fa0934f993028867ab122864b453c5b85ec73 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Tue, 18 Apr 2023 09:34:02 -0400 Subject: [PATCH] Fix starter select cycling issue --- src/ui/starter-select-ui-handler.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 84350df49..25e88cdf4 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -471,31 +471,38 @@ export default class StarterSelectUiHandler extends MessageUiHandler { (this.starterSelectGenIconContainers[this.genCursor].getAt(this.cursor) as Phaser.GameObjects.Sprite).play(species.getIconKey(female, formIndex)); let count: integer; - const calcUnlockedCount = (tree: StarterDexUnlockTree, root?: boolean) => { - if (root) + let values: any[]; + const calcUnlockedCount = (tree: StarterDexUnlockTree, prop: string, root?: boolean) => { + if (root) { count = 0; + values = []; + } if (!tree.entry) { for (let key of tree[tree.key].keys()) - calcUnlockedCount(tree[tree.key].get(key)); - } else if (tree.entry.caught) - count++; + calcUnlockedCount(tree[tree.key].get(key), prop); + } else if (tree.entry.caught) { + if (values.indexOf(tree[prop]) === -1) { + values.push(tree[prop]); + count++; + } + } }; let tree = this.speciesStarterDexTree; - calcUnlockedCount(tree, true); + calcUnlockedCount(tree, 'shiny', true); this.canCycleShiny = count > 1; tree = (tree.shiny as Map).get(!!this.shinyCursor); if (this.lastSpecies.forms?.length) { - calcUnlockedCount(tree, true); + calcUnlockedCount(tree, 'formIndex', true); this.canCycleForm = count > 1; tree = (tree.formIndex as Map).get(this.formCursor); } else this.canCycleForm = false; if (this.lastSpecies.malePercent !== null) { - calcUnlockedCount(tree, true); + calcUnlockedCount(tree, 'female', true); this.canCycleGender = count > 1; } else this.canCycleGender = false;