diff --git a/src/data/egg.ts b/src/data/egg.ts index b8ed28c892a..bf4d6577dd7 100644 --- a/src/data/egg.ts +++ b/src/data/egg.ts @@ -166,12 +166,12 @@ export class Egg { if (eggOptions.species) { this._tier = this.getEggTierFromSpeciesStarterValue(); this._hatchWaves = eggOptions.hatchWaves ?? this.getEggTierDefaultHatchWaves(); - // If species has no variant, set variantTier to common. This needs to - // be done because species with no variants get filtered at rollSpecies but since the - // species is set the check never happens - if (!getPokemonSpecies(this.species).hasVariants()) { - this._variantTier = VariantTier.COMMON; - } + } + // If species has no variant, set variantTier to common. This needs to + // be done because species with no variants get filtered at rollSpecies but if the + // species is set via options or the legendary gacha pokemon gets choosen the check never happens + if (this._species && !getPokemonSpecies(this._species).hasVariants()) { + this._variantTier = VariantTier.COMMON; } // Needs this._tier so it needs to be generated afer the tier override if bought from same species this._eggMoveIndex = eggOptions.eggMoveIndex ?? this.rollEggMoveIndex(); diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index d011454e03c..e23b22f1bce 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -853,7 +853,14 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali } hasVariants() { - return variantData.hasOwnProperty(this.speciesId); + let variantDataIndex: string | number = this.speciesId; + if (this.forms.length > 0) { + const formKey = this.forms[this.formIndex]?.formKey; + if (formKey) { + variantDataIndex = `${variantDataIndex}-${formKey}`; + } + } + return variantData.hasOwnProperty(variantDataIndex) || variantData.hasOwnProperty(this.speciesId); } getFormSpriteKey(formIndex?: integer) { diff --git a/src/test/eggs/egg.test.ts b/src/test/eggs/egg.test.ts index a098620f5eb..91d1153edfc 100644 --- a/src/test/eggs/egg.test.ts +++ b/src/test/eggs/egg.test.ts @@ -303,4 +303,11 @@ describe("Egg Generation Tests", () => { expect(result1).toBe(expectedTier1); expect(result2).toBe(expectedTier2); }); + + it("should generate an epic shiny from pokemon with a different form", () => { + const scene = game.scene; + const egg = new Egg({scene, isShiny: true, variantTier: VariantTier.EPIC, species: Species.MIRAIDON}); + + expect(egg.variantTier).toBe(VariantTier.EPIC); + }); });