1.13.5 • Published 26 days ago

@erezushi/pokemon-randomizer v1.13.5

Weekly downloads
-
License
ISC
Repository
github
Last release
26 days ago

Pokémon Randomizer - By Dylan Stankievech

Try @erezushi/pokemon-randomizer on RunKit NPM npm bundle size (scoped) Libraries.io dependency status for latest release

Edits by Erez Bracha, original library here

This is a simple library to generate random teams of Pokémon.

For an interactive UI based on this package, click here

Table of Contents:

Options

OptionTypeDescriptionDefaultNotes
numbernumberNumber of random Pokémon to generate6integer > 0
babybooleanChoose only baby Pokémon (species released in a later generation than their evolutions)false
basicbooleanChoose only basic Pokémon (lowest evolution stage excluding babies)false
evolvedbooleanChoose only fully evolved Pokémonfalse
typestringChoose only Pokémon of this type-enter a single type's name in lowercase
randomTypebooleanChoose only Pokémon of a random typefalse
superEffectivestringChoose only Pokémon super effective against this type-enter a single type's name in lowercase
uniquebooleanChoose no duplicate Pokémonfalse
starterbooleanChoose only Pokémon from the starter linesfalse
legendarybooleanChoose only Legendary and Mythical Pokémon (Legendary can be a controversial term)false
mythicalbooleanChoose only Mythical Pokémonfalse
formsbooleanInclude alternate forms of Pokémon in the resultsfalse
generationsstring[]Choose Pokémon only from the specified generations-Example: '1', '2', '4', '6'
customListstring[]Specify names of Pokémon to choose from-Pokémon names must match internal names in all but case. Internal list can be obtained using the exported getPokemon function for increased ease.

Please note that some options are supposed to be mutually exclusive:

  • Setting baby to true together with either basic and/or evolved would return no results
  • Setting starter to true together with either legendary and/or mythical would return no results
  • Setting both legendary and mythical to true is the same as just setting mythical to true
  • randomType option will be ignored if you've set the type option
  • Setting the customList option will cause all options except number, unique and forms to be ignored

return to top

Returned Fields

  • name: The name of the Pokémon.
  • type: The types of the Pokémon.
  • dexNo: The national Pokédex number of the Pokémon.
  • evolveTo: The national Pokédex numbers of the Pokémon this Pokémon evolves to (where applicable).
  • starter: states that this Pokémon is a starter (will wither be true or won't exist).
  • legendary: states that this Pokémon is a legendary Pokémon (will wither be true or won't exist).
  • mythical: states that this Pokémon is a mythical Pokémon (will wither be true or won't exist).
  • basic: states that this Pokémon is a basic stage Pokémon (will wither be true or won't exist).
  • forms: an object array with different forms of the Pokémon (where applicable). Form object contains the fields name, type and evolveTo (function the same as these fields above).

return to top

Non-Default Exports

  • TypeScript types (all types used in the library are exported):
    • PokemonType: String enum of all 18 types.
    • SpecieType: String enum of all possible typings a Pokémon specie can have.
    • Form: The type of the values in the forms field of the Pokémon list.
    • ListPokemon: Object detailing a Pokémon species (Returned Fields without dexNo).
    • Pokemon: The type of the values in the main function's result array.
    • PokemonMap: Record<string, ListPokemon> - The type of the internal Pokémon List.
    • TypeMatchups: Object detailing type matchups of a specific type.
    • TypeMap: Record<PokemonType, TypeMatchups> - The type of the internal type list.
    • Options: Type of the only parameter of the main function.
    • Generation: Object detailing the first and last indices of a generation.
    • GenerationMap: Record<string, Generation> - The type of the internal generation list.
  • Extra functions:
    • getPokemon: () => PokemonMap - Returns the internal Pokémon list
    • getTypes: () => TypeMap - Returns the internal type list
    • getGenerations: () => GenerationMap - Returns the internal Generation list

return to top

Examples

import RandomPokemon from '@erezushi/pokemon-randomizer';

// No options - Chooses 6 random Pokémon
const result = RandomPokemon();
// result = [
//     { name: 'Pikachu', ... },
//     { name: 'Mewtwo', ... },
//     ...
// ]

// Chooses 3 random, unique, final stage Pokémon, that are super effective against fire
const fullyEvolved = RandomPokemon({
    number: 3,
    unique: true,
    evolved: true,
    superEffective: 'fire'
});
// fullyEvolved = [
//     { name: 'Blastoise', ... },
//     { name: 'Golem', ... },
//     { name: 'Omastar', ...},
// ]

// Using the customList option
const customList = [
    "charmander",
    "vulpix",
    "eevee",
    "latias",
    "zorua",
    "fennekin",
    "litten",
    "sprigatito",
];

const customFilter = RandomPokemon({
    number: 3,
    unique: true,
    customList,
});
// CustomFilter = [
//     { name: 'Fennekin' ... },
//     { name: 'Vulpix' ... },
//     { name: 'Latias' ... },
// ]

return to top

1.13.5

26 days ago

1.13.2

4 months ago

1.13.1

4 months ago

1.13.0

4 months ago

1.13.4

4 months ago

1.13.3

4 months ago

1.12.1

6 months ago

1.12.0

7 months ago

1.11.7

10 months ago

1.11.4

1 year ago

1.11.6

1 year ago

1.11.5

1 year ago

1.11.3

1 year ago

1.11.2

1 year ago

1.11.1

1 year ago

1.9.0

1 year ago

1.11.0

1 year ago

1.10.1

1 year ago

1.10.0

1 year ago

1.8.3

2 years ago

1.8.1

2 years ago

1.8.0

2 years ago

1.7.2

2 years ago

1.6.2-rev4

2 years ago

1.6.2-rev3

2 years ago

1.6.2-rev5

2 years ago

1.6.3

2 years ago

1.7.1

2 years ago

1.6.2

2 years ago

1.7.0

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.6.2-rev2

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago