pokemaster2 package

Subpackages

Submodules

pokemaster2.cli module

Console script for pokemaster2.

pokemaster2.pokemon module

Base Pokemon.

class pokemaster2.pokemon.BasePokemon(national_id: int, species: str, types: Sequence[str], item_held: str, exp: int, level: int, base_stats: pokemaster2.pokemon.Stats, iv: pokemaster2.pokemon.Stats, current_stats: pokemaster2.pokemon.Stats, stats: pokemaster2.pokemon.Stats, ev: pokemaster2.pokemon.Stats, pid: str, gender: str, nature: str, ability: str)[source]

Bases: object

The underlying structure of a Pokémon.

No fancy initializations, no consistency checks, just a very basic Pokémon model. Anything is possible with this BasePokemon. This class also contains common and basic behaviors of Pokémon, such as leveling-up, learning/forgetting moves, evolving into another Pokémon, etc.

This class is never meant to be instantiated directly.

ability: str
base_stats: pokemaster2.pokemon.Stats
current_stats: pokemaster2.pokemon.Stats
ev: pokemaster2.pokemon.Stats
exp: int
gender: str
item_held: str
iv: pokemaster2.pokemon.Stats
level: int
national_id: int
nature: str
pid: str
species: str
stats: pokemaster2.pokemon.Stats
types: Sequence[str]
class pokemaster2.pokemon.Stats(hp: int, atk: int, def_: int, spatk: int, spdef: int, spd: int)[source]

Bases: object

Generic stats, can be used for Pokemon stats/IV/EV.

atk: int
classmethod create_iv(gene: int) pokemaster2.pokemon.S[source]

Create IV stats from a Pokémon’s gene.

Parameters

gene – An int generated by the PRNG.

Returns

A Stats instance.

def_: int
hp: int
classmethod nature_modifiers(nature: str) pokemaster2.pokemon.S[source]

Generate nature modifier Stats.

spatk: int
spd: int
spdef: int
validate_iv() bool[source]

Check if each IV is between 0 and 32.

classmethod zeros() pokemaster2.pokemon.S[source]

Empty Stats.

pokemaster2.prng module

Provides the pseudo-random number generator used in various places.

class pokemaster2.prng.PRNG(seed: int = 0, gen: int = 3)[source]

Bases: object

A linear congruential random number generator.

Usage:
>>> prng = PRNG()
>>> prng()
0
>>> prng()
59774

References

https://bulbapedia.bulbagarden.net/wiki/Pseudorandom_number_generation_in_Pokémon https://www.smogon.com/ingame/rng/pid_iv_creation#pokemon_random_number_generator

generate_pid_and_iv(method: int = 2) Tuple[int, int][source]

Generate the PID and IVs using the internal generator.

The generated 32-bit IVs is different from how it is actually stored.

Method 1: [PID] [PID] [IVs] [IVs] Method 2: [PID] [PID] [xxxx] [IVs] [IVs] Method 4: [PID] [PID] [IVs] [xxxx] [IVs]

Methods 2 and 4 are only used in Pokemon Ruby, Sapphire, Emerald, Fire Red and Leaf Green (RSEFRLG) to produce wild Pokemon.

All the Pokemon you catch in these games that are not wild Pokemon are created using Method 1.

The criterion for choosing whether to use Method 1, 2, or 4 in the creation of wild Pokemon in RSEFRLG seems to be arbitrary.

Checkout [this link](https://www.smogon.com/ingame/rng/pid_iv_creation#rng_pokemon_generation) # noqa: E501 for more information on Method 1, 2, and 4.

Parameters

method – 1, 2, or 4.

Raises

ValueError – if the method is not in (1, 2, 4).

Returns

a tuple of two integers, in the order of ‘PID’ and ‘IVs’.

next_(n: int) List[int][source]

Generate the next n random numbers.

random() float[source]

Generate a random number from the uniform distribution [0, 1).

Returns

A random number between 0 and 1.

reset() None[source]

Reset the generator with the initial seed.

seed: int

Module contents

Top-level package for pokemaster2.