Moving things around to avoid checking same species twice

This commit is contained in:
Wlowscha 2025-03-02 01:34:06 +01:00
parent 8a8480b7f1
commit 65440eff3c
No known key found for this signature in database
GPG Key ID: 3C8F1AD330565D04

View File

@ -1301,16 +1301,20 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
} }
checkValidForChallenge(species: PokemonSpecies, props: DexAttrProps, soft: boolean) { checkValidForChallenge(species: PokemonSpecies, props: DexAttrProps, soft: boolean) {
const isValidForChallenge = new BooleanHolder(true); if (!soft) {
Challenge.applyChallenges( const isValidForChallenge = new BooleanHolder(true);
globalScene.gameMode, Challenge.applyChallenges(
Challenge.ChallengeType.STARTER_CHOICE, globalScene.gameMode,
species, Challenge.ChallengeType.STARTER_CHOICE,
isValidForChallenge, species,
props isValidForChallenge,
); props
const allValidities: boolean[] = []; );
if (soft) { 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 ]; const speciesToCheck = [ species.speciesId ];
while (speciesToCheck.length) { while (speciesToCheck.length) {
const checking = speciesToCheck.pop(); 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 { processInput(button: Button): boolean {