mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-06-27 12:02:47 +02:00
[Misc] getPokemonSpecies()
no longer accepts undefined
(#5477)
This commit is contained in:
parent
9544973f1f
commit
6595966478
@ -68,10 +68,7 @@ export const normalForm: Species[] = [
|
|||||||
* @param species The species to fetch
|
* @param species The species to fetch
|
||||||
* @returns The associated {@linkcode PokemonSpecies} object
|
* @returns The associated {@linkcode PokemonSpecies} object
|
||||||
*/
|
*/
|
||||||
export function getPokemonSpecies(species: Species | Species[] | undefined): PokemonSpecies {
|
export function getPokemonSpecies(species: Species | Species[]): PokemonSpecies {
|
||||||
if (!species) {
|
|
||||||
throw new Error("`species` must not be undefined in `getPokemonSpecies()`");
|
|
||||||
}
|
|
||||||
// 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 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)) {
|
if (Array.isArray(species)) {
|
||||||
// Pick a random species from the list
|
// 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()) {
|
for (const weight of evolutionPool.keys()) {
|
||||||
if (randValue < weight) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ describe("Uncommon Breed - Mystery Encounter", () => {
|
|||||||
await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty);
|
await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty);
|
||||||
|
|
||||||
const config = game.scene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0];
|
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);
|
await runMysteryEncounterToEnd(game, 1, undefined, true);
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ describe("Uncommon Breed - Mystery Encounter", () => {
|
|||||||
await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty);
|
await game.runToMysteryEncounter(MysteryEncounterType.UNCOMMON_BREED, defaultParty);
|
||||||
|
|
||||||
const config = game.scene.currentBattle.mysteryEncounter!.enemyPartyConfigs[0];
|
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);
|
await runMysteryEncounterToEnd(game, 1, undefined, true);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user