Skip to content

Commit

Permalink
creates table for tracking species egg tiers
Browse files Browse the repository at this point in the history
  • Loading branch information
ImperialSympathizer committed Oct 5, 2024
1 parent 0a7fab4 commit 82b96ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
3 changes: 3 additions & 0 deletions src/data/balance/species-egg-tiers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Species } from "#enums/species";
import { EggTier } from "#enums/egg-type";

/**
* Map of all starters and their respective {@link EggTier}, which determines which type of egg the starter hatches from.
*/
export const speciesEggTiers = {
[Species.BULBASAUR]: EggTier.COMMON,
[Species.CHARMANDER]: EggTier.COMMON,
Expand Down
36 changes: 7 additions & 29 deletions src/data/egg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class Egg {

// Override egg tier and hatchwaves if species was given
if (eggOptions?.species) {
this._tier = this.getEggTierFromSpeciesStarterValue();
this._tier = this.getEggTier();
this._hatchWaves = eggOptions.hatchWaves ?? this.getEggTierDefaultHatchWaves();
}
// If species has no variant, set variantTier to common. This needs to
Expand Down Expand Up @@ -536,22 +536,8 @@ export class Egg {
}
}

private getEggTierFromSpeciesStarterValue(): EggTier {
const speciesStartValue = speciesStarterCosts[this.species];
if (speciesStartValue >= 1 && speciesStartValue <= 3) {
return EggTier.COMMON;
}
if (speciesStartValue >= 4 && speciesStartValue <= 5) {
return EggTier.GREAT;
}
if (speciesStartValue >= 6 && speciesStartValue <= 7) {
return EggTier.ULTRA;
}
if (speciesStartValue >= 8) {
return EggTier.MASTER;
}

return EggTier.COMMON;
private getEggTier(): EggTier {
return speciesEggTiers[this.species];
}

////
Expand All @@ -560,8 +546,8 @@ export class Egg {
}

export function getLegendaryGachaSpeciesForTimestamp(scene: BattleScene, timestamp: number): Species {
const legendarySpecies = Object.entries(speciesStarterCosts)
.filter(s => s[1] >= 8 && s[1] <= 9)
const legendarySpecies = Object.entries(speciesEggTiers)
.filter(s => s[1] === EggTier.MASTER)
.map(s => parseInt(s[0]))
.filter(s => getPokemonSpecies(s).isObtainable());

Expand All @@ -583,17 +569,9 @@ export function getLegendaryGachaSpeciesForTimestamp(scene: BattleScene, timesta

/**
* Check for a given species EggTier Value
* @param species - Species for wich we will check the egg tier it belongs to
* @param pokemonSpecies - Species for wich we will check the egg tier it belongs to
* @returns The egg tier of a given pokemon species
*/
export function getEggTierForSpecies(pokemonSpecies :PokemonSpecies): EggTier {
const speciesBaseValue = speciesStarterCosts[pokemonSpecies.getRootSpeciesId()];
if (speciesBaseValue <= 3) {
return EggTier.COMMON;
} else if (speciesBaseValue <= 5) {
return EggTier.GREAT;
} else if (speciesBaseValue <= 7) {
return EggTier.ULTRA;
}
return EggTier.MASTER;
return speciesEggTiers[pokemonSpecies.getRootSpeciesId()];
}

0 comments on commit 82b96ea

Please sign in to comment.