[BUG] Fixes bug that prevents pokemon with froms from hatching as rare/epic shiny variant and preventing illegal variants from legendary gacha (#2940)
* Changed PokemonSpecies hasVariants function to also include for pokemon with differend forms * Added check to prevent illegal shiny variants from happening if the egg rolls the gacha legendary and has no variants * Simplified variant check. Fixed spelling on unit test * Bugfix for legacy eggs * Removed formIndex variable * Changed unit test * Added new line to unit test function Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> --------- Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com>
This commit is contained in:
parent
233c926721
commit
7fac3269e1
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue