[Misc] `getPokemonSpecies()` no longer accepts `undefined` (#5477)

This commit is contained in:
NightKev 2025-03-05 18:18:24 -08:00 committed by GitHub
parent 9544973f1f
commit 6595966478
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 7 deletions

View File

@ -68,10 +68,7 @@ export const normalForm: Species[] = [
* @param species The species to fetch
* @returns The associated {@linkcode PokemonSpecies} object
*/
export function getPokemonSpecies(species: Species | Species[] | undefined): PokemonSpecies {
if (!species) {
throw new Error("`species` must not be undefined in `getPokemonSpecies()`");
}
export function getPokemonSpecies(species: Species | Species[]): PokemonSpecies {
// If a special pool (named trainers) is used here it CAN happen that they have a array as species (which means choose one of those two). So we catch that with this code block
if (Array.isArray(species)) {
// Pick a random species from the list
@ -914,7 +911,8 @@ export default class PokemonSpecies extends PokemonSpeciesForm implements Locali
for (const weight of evolutionPool.keys()) {
if (randValue < weight) {
return getPokemonSpecies(evolutionPool.get(weight)).getSpeciesForLevel(level, true, forTrainer, strength, currentWave);
// TODO: this entire function is dumb and should be changed, adding a `!` here for now until then
return getPokemonSpecies(evolutionPool.get(weight)!).getSpeciesForLevel(level, true, forTrainer, strength, currentWave);
}
}

View File

@ -116,7 +116,7 @@ describe("Uncommon Breed - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty);
const config = game.scene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0];
const speciesToSpawn = config.pokemonConfigs?.[0].species.speciesId;
const speciesToSpawn = config.pokemonConfigs?.[0].species.speciesId!;
await runMysteryEncounterToEnd(game, 1, undefined, true);
@ -143,7 +143,7 @@ describe("Uncommon Breed - Mystery Encounter", () => {
await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty);
const config = game.scene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0];
const speciesToSpawn = config.pokemonConfigs?.[0].species.speciesId;
const speciesToSpawn = config.pokemonConfigs?.[0].species.speciesId!;
await runMysteryEncounterToEnd(game, 1, undefined, true);