From 65440eff3c1ccd8ee9a50c64d8fc9037dfd75bc5 Mon Sep 17 00:00:00 2001 From: Wlowscha <54003515+Wlowscha@users.noreply.github.com> Date: Sun, 2 Mar 2025 01:34:06 +0100 Subject: [PATCH] Moving things around to avoid checking same species twice --- src/ui/starter-select-ui-handler.ts | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/ui/starter-select-ui-handler.ts b/src/ui/starter-select-ui-handler.ts index 065e1a6e4d6..3107a2c1ffc 100644 --- a/src/ui/starter-select-ui-handler.ts +++ b/src/ui/starter-select-ui-handler.ts @@ -1301,16 +1301,20 @@ export default class StarterSelectUiHandler extends MessageUiHandler { } checkValidForChallenge(species: PokemonSpecies, props: DexAttrProps, soft: boolean) { - const isValidForChallenge = new BooleanHolder(true); - Challenge.applyChallenges( - globalScene.gameMode, - Challenge.ChallengeType.STARTER_CHOICE, - species, - isValidForChallenge, - props - ); - const allValidities: boolean[] = []; - if (soft) { + if (!soft) { + const isValidForChallenge = new BooleanHolder(true); + Challenge.applyChallenges( + globalScene.gameMode, + Challenge.ChallengeType.STARTER_CHOICE, + species, + isValidForChallenge, + props + ); + return isValidForChallenge.value; + } else { + // We check the validity of every evolution and battle form separately, + // and require that at least one is valid + const allValidities: boolean[] = []; const speciesToCheck = [ species.speciesId ]; while (speciesToCheck.length) { const checking = speciesToCheck.pop(); @@ -1349,8 +1353,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler { }); } } + return allValidities.filter(v => v).length > 0; } - return isValidForChallenge.value || (soft && allValidities.filter(v => v).length > 0); } processInput(button: Button): boolean {