From dfb42e44a695040c2a7ae9b76e8564572ed89c0d Mon Sep 17 00:00:00 2001 From: PigeonBar <56974298+PigeonBar@users.noreply.github.com> Date: Sun, 27 Oct 2024 00:04:57 -0400 Subject: [PATCH] [Hotfix] Fix Eternatus egg tier (#4734) --- package-lock.json | 4 ++-- package.json | 2 +- src/data/balance/species-egg-tiers.ts | 2 +- src/data/egg.ts | 10 ++++++--- src/test/eggs/egg.test.ts | 30 ++++++++++++++++++++++++++- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index bbe52272f92..0c36f9cfee9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pokemon-rogue-battle", - "version": "1.1.1", + "version": "1.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pokemon-rogue-battle", - "version": "1.1.1", + "version": "1.1.2", "hasInstallScript": true, "dependencies": { "@material/material-color-utilities": "^0.2.7", diff --git a/package.json b/package.json index 4666ffb7587..aef6e7b2ba0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pokemon-rogue-battle", "private": true, - "version": "1.1.1", + "version": "1.1.2", "type": "module", "scripts": { "start": "vite", diff --git a/src/data/balance/species-egg-tiers.ts b/src/data/balance/species-egg-tiers.ts index cd266dfcf54..27baa18151a 100644 --- a/src/data/balance/species-egg-tiers.ts +++ b/src/data/balance/species-egg-tiers.ts @@ -497,7 +497,7 @@ export const speciesEggTiers = { [Species.DREEPY]: EggTier.RARE, [Species.ZACIAN]: EggTier.LEGENDARY, [Species.ZAMAZENTA]: EggTier.LEGENDARY, - [Species.ETERNATUS]: EggTier.COMMON, + [Species.ETERNATUS]: EggTier.LEGENDARY, [Species.KUBFU]: EggTier.EPIC, [Species.ZARUDE]: EggTier.EPIC, [Species.REGIELEKI]: EggTier.EPIC, diff --git a/src/data/egg.ts b/src/data/egg.ts index 0f88c53b748..f7d109dfa62 100644 --- a/src/data/egg.ts +++ b/src/data/egg.ts @@ -544,11 +544,15 @@ export class Egg { //// } -export function getLegendaryGachaSpeciesForTimestamp(scene: BattleScene, timestamp: number): Species { - const legendarySpecies = Object.entries(speciesEggTiers) +export function getValidLegendaryGachaSpecies() : Species[] { + return Object.entries(speciesEggTiers) .filter(s => s[1] === EggTier.LEGENDARY) .map(s => parseInt(s[0])) - .filter(s => getPokemonSpecies(s).isObtainable()); + .filter(s => getPokemonSpecies(s).isObtainable() && s !== Species.ETERNATUS); +} + +export function getLegendaryGachaSpeciesForTimestamp(scene: BattleScene, timestamp: number): Species { + const legendarySpecies = getValidLegendaryGachaSpecies(); let ret: Species; diff --git a/src/test/eggs/egg.test.ts b/src/test/eggs/egg.test.ts index 6f57af63e6b..aebb196ff5e 100644 --- a/src/test/eggs/egg.test.ts +++ b/src/test/eggs/egg.test.ts @@ -1,4 +1,7 @@ -import { Egg, getLegendaryGachaSpeciesForTimestamp } from "#app/data/egg"; +import { speciesEggTiers } from "#app/data/balance/species-egg-tiers"; +import { speciesStarterCosts } from "#app/data/balance/starters"; +import { Egg, getLegendaryGachaSpeciesForTimestamp, getValidLegendaryGachaSpecies } from "#app/data/egg"; +import { allSpecies } from "#app/data/pokemon-species"; import { EggSourceType } from "#app/enums/egg-source-types"; import { EggTier } from "#app/enums/egg-type"; import { VariantTier } from "#app/enums/variant-tier"; @@ -64,6 +67,12 @@ describe("Egg Generation Tests", () => { expect(gachaSpeciesCount).toBeGreaterThan(0.4 * EGG_HATCH_COUNT); expect(gachaSpeciesCount).toBeLessThan(0.6 * EGG_HATCH_COUNT); }); + it("should never be allowed to generate Eternatus via the legendary gacha", () => { + const validLegendaryGachaSpecies = getValidLegendaryGachaSpecies(); + expect(validLegendaryGachaSpecies.every(s => speciesEggTiers[s] === EggTier.LEGENDARY)).toBe(true); + expect(validLegendaryGachaSpecies.every(s => allSpecies[s].isObtainable())).toBe(true); + expect(validLegendaryGachaSpecies.includes(Species.ETERNATUS)).toBe(false); + }); it("should hatch an Arceus. Set from species", () => { const scene = game.scene; const expectedSpecies = Species.ARCEUS; @@ -376,4 +385,23 @@ describe("Egg Generation Tests", () => { expect(diffShiny).toBe(true); expect(diffAbility).toBe(true); }); + + // For now, we are using this test to detect oversights in egg tiers. + // Delete this test if the balance team rebalances species costs independently of egg tiers. + it("should have correct egg tiers based on species costs", () => { + const getExpectedEggTier = (starterCost) => + starterCost <= 3 ? EggTier.COMMON + : starterCost <= 5 ? EggTier.RARE + : starterCost <= 7 ? EggTier.EPIC + : EggTier.LEGENDARY; + + allSpecies.forEach(pokemonSpecies => { + const rootSpecies = pokemonSpecies.getRootSpeciesId(); + const speciesCost = speciesStarterCosts[rootSpecies]; + const expectedEggTier = getExpectedEggTier(speciesCost); + const actualEggTier = speciesEggTiers[rootSpecies]; + + expect(actualEggTier).toBe(expectedEggTier); + }); + }); });