From 3e9fbeb4d6fbdc87ab391b724b551eb9b13c4905 Mon Sep 17 00:00:00 2001 From: sirzento Date: Sat, 22 Jun 2024 12:40:10 +0200 Subject: [PATCH] Hotfix: Override varaint tier if species was given. Fixed that some common egg where displayed as manaphy egg and wrong manaphy egg counter (#2505) * Hotfix: Override varaint tier if species was given. Fixed that some common egg where displayed as manaphy egg. * Fixes wrong manaphy egg pulled stat count --- src/data/egg.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/data/egg.ts b/src/data/egg.ts index dda21f259a2..e8c7dadcc0e 100644 --- a/src/data/egg.ts +++ b/src/data/egg.ts @@ -141,12 +141,17 @@ export class Egg { //if (eggOptions.tier && eggOptions.species) throw Error("Error egg can't have species and tier as option. only choose one of them.") this._tier = eggOptions.tier ?? (Overrides.EGG_TIER_OVERRIDE ?? this.rollEggTier()); + // If egg was pulled, check if egg pity needs to override the egg tier if (eggOptions.pulled) { this.checkForPityTierOverrides(eggOptions.scene); - this.increasePullStatistic(eggOptions.scene); } this._id = eggOptions.id ?? Utils.randInt(EGG_SEED, EGG_SEED * this._tier); + + // Increase pull statistics AFTER the ID was generated beacuse it will be used to check for mahnaphy egg + if (eggOptions.pulled) { + this.increasePullStatistic(eggOptions.scene); + } this._sourceType = eggOptions.sourceType ?? undefined; this._hatchWaves = eggOptions.hatchWaves ?? this.getEggTierDefaultHatchWaves(); this._timestamp = eggOptions.timestamp ?? new Date().getTime(); @@ -163,6 +168,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 (eggOptions.pulled) { this.addEggToGameData(eggOptions.scene); @@ -175,7 +186,7 @@ export class Egg { public isManaphyEgg(): boolean { return (this._species === Species.PHIONE || this._species === Species.MANAPHY) || - this._tier === EggTier.COMMON && !(this._id % 204); + this._tier === EggTier.COMMON && !(this._id % 204) && !this._species; } public getKey(): string {