From f0a826b8f4fcd0e3c01b85734d468a19dd3e639b Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Sun, 9 Jun 2024 11:06:36 +1000 Subject: [PATCH] [Bug] Fix Victini's generation for challenges. (#1973) * Make victini count as gen 5 challenge instead of 4 * Add comment --- src/data/challenge.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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; }