diff --git a/src/data/challenge.ts b/src/data/challenge.ts index 2aad5e75f2d..916f59ab2c2 100644 --- a/src/data/challenge.ts +++ b/src/data/challenge.ts @@ -267,11 +267,18 @@ export class SingleGenerationChallenge extends Challenge { return false; } + /** + * We have special code below for victini because it is classed as a generation 4 pokemon in the code + * despite being a generation 5 pokemon. This is due to UI constraints, the starter select screen has + * no more room for pokemon so victini is put in the gen 4 section instead. This code just overrides the + * normal generation check to correctly treat victini as gen 5. + */ switch (challengeType) { case ChallengeType.STARTER_CHOICE: const species = args[0] as PokemonSpecies; const isValidStarter = args[1] as Utils.BooleanHolder; - if (species.generation !== this.value) { + const starterGeneration = species.speciesId === Species.VICTINI ? 5 : species.generation; + if (starterGeneration !== this.value) { isValidStarter.value = false; return true; } @@ -279,7 +286,9 @@ export class SingleGenerationChallenge extends Challenge { case ChallengeType.POKEMON_IN_BATTLE: const pokemon = args[0] as Pokemon; const isValidPokemon = args[1] as Utils.BooleanHolder; - if (pokemon.isPlayer() && ((pokemon.species.formIndex === 0 ? pokemon.species : getPokemonSpecies(pokemon.species.speciesId)).generation !== this.value || (pokemon.isFusion() && (pokemon.fusionSpecies.formIndex === 0 ? pokemon.fusionSpecies : getPokemonSpecies(pokemon.fusionSpecies.speciesId)).generation !== this.value))) { + const baseGeneration = pokemon.species.speciesId === Species.VICTINI ? 5 : getPokemonSpecies(pokemon.species.speciesId).generation; + const fusionGeneration = pokemon.isFusion() ? pokemon.fusionSpecies.speciesId === Species.VICTINI ? 5 : getPokemonSpecies(pokemon.fusionSpecies.speciesId).generation : 0; + if (pokemon.isPlayer() && (baseGeneration !== this.value || (pokemon.isFusion() && fusionGeneration !== this.value))) { isValidPokemon.value = false; return true; }