Fix starter select cycling issue
parent
fcdd7c421e
commit
9a2fa0934f
|
@ -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));
|
(this.starterSelectGenIconContainers[this.genCursor].getAt(this.cursor) as Phaser.GameObjects.Sprite).play(species.getIconKey(female, formIndex));
|
||||||
|
|
||||||
let count: integer;
|
let count: integer;
|
||||||
const calcUnlockedCount = (tree: StarterDexUnlockTree, root?: boolean) => {
|
let values: any[];
|
||||||
if (root)
|
const calcUnlockedCount = (tree: StarterDexUnlockTree, prop: string, root?: boolean) => {
|
||||||
|
if (root) {
|
||||||
count = 0;
|
count = 0;
|
||||||
|
values = [];
|
||||||
|
}
|
||||||
if (!tree.entry) {
|
if (!tree.entry) {
|
||||||
for (let key of tree[tree.key].keys())
|
for (let key of tree[tree.key].keys())
|
||||||
calcUnlockedCount(tree[tree.key].get(key));
|
calcUnlockedCount(tree[tree.key].get(key), prop);
|
||||||
} else if (tree.entry.caught)
|
} else if (tree.entry.caught) {
|
||||||
count++;
|
if (values.indexOf(tree[prop]) === -1) {
|
||||||
|
values.push(tree[prop]);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let tree = this.speciesStarterDexTree;
|
let tree = this.speciesStarterDexTree;
|
||||||
|
|
||||||
calcUnlockedCount(tree, true);
|
calcUnlockedCount(tree, 'shiny', true);
|
||||||
this.canCycleShiny = count > 1;
|
this.canCycleShiny = count > 1;
|
||||||
tree = (tree.shiny as Map<boolean, StarterDexUnlockTree>).get(!!this.shinyCursor);
|
tree = (tree.shiny as Map<boolean, StarterDexUnlockTree>).get(!!this.shinyCursor);
|
||||||
|
|
||||||
if (this.lastSpecies.forms?.length) {
|
if (this.lastSpecies.forms?.length) {
|
||||||
calcUnlockedCount(tree, true);
|
calcUnlockedCount(tree, 'formIndex', true);
|
||||||
this.canCycleForm = count > 1;
|
this.canCycleForm = count > 1;
|
||||||
tree = (tree.formIndex as Map<integer, StarterDexUnlockTree>).get(this.formCursor);
|
tree = (tree.formIndex as Map<integer, StarterDexUnlockTree>).get(this.formCursor);
|
||||||
} else
|
} else
|
||||||
this.canCycleForm = false;
|
this.canCycleForm = false;
|
||||||
|
|
||||||
if (this.lastSpecies.malePercent !== null) {
|
if (this.lastSpecies.malePercent !== null) {
|
||||||
calcUnlockedCount(tree, true);
|
calcUnlockedCount(tree, 'female', true);
|
||||||
this.canCycleGender = count > 1;
|
this.canCycleGender = count > 1;
|
||||||
} else
|
} else
|
||||||
this.canCycleGender = false;
|
this.canCycleGender = false;
|
||||||
|
|
Loading…
Reference in New Issue