gpkm/pkm/pkm_builder

Types

Pkm record, containing the most valuable info about a Pokemon: pid, nickname, species, moves, ivs, evs, ot id/sid, shininess…

It also contains the original pkm bytes as a base64 string

Each Pkm parameter is an Option, to construct the record using the builder pattern

let b64_pkm_data = ""
let pid_bytes = [42, 21, 12, 24]
let level_bytes = [42]

pkm_builder.new(b64_pkm_data)
|> with_pid(pid_bytes)
|> with_level(level_bytes)
// -> Pkm(pid: Some(42211224), level: 42, nickname: None, ..., b64_pkm_data: "")
pub type Pkm {
  Pkm(
    pid: Option(Int),
    nickname: Option(String),
    national_pokedex_id: Option(Int),
    held_item: Option(String),
    origin_game: Option(String),
    ot_name: Option(String),
    ot_id: Option(Int),
    ot_secret_id: Option(Int),
    moves: Option(Moves),
    ability: Option(String),
    individual_values: Option(IndividualValues),
    effort_values: Option(EffortValues),
    experience_points: Option(Int),
    friendship: Option(Int),
    original_language: Option(String),
    shiny: Option(Bool),
    level: Option(Int),
    nature: Option(String),
    species: Option(String),
    gender: Option(String),
    hidden_power: Option(HiddenPower),
    b64_pkm_data: String,
  )
}

Constructors

  • Pkm(
      pid: Option(Int),
      nickname: Option(String),
      national_pokedex_id: Option(Int),
      held_item: Option(String),
      origin_game: Option(String),
      ot_name: Option(String),
      ot_id: Option(Int),
      ot_secret_id: Option(Int),
      moves: Option(Moves),
      ability: Option(String),
      individual_values: Option(IndividualValues),
      effort_values: Option(EffortValues),
      experience_points: Option(Int),
      friendship: Option(Int),
      original_language: Option(String),
      shiny: Option(Bool),
      level: Option(Int),
      nature: Option(String),
      species: Option(String),
      gender: Option(String),
      hidden_power: Option(HiddenPower),
      b64_pkm_data: String,
    )

Functions

pub fn get_nature(pid: Int) -> Result(String, Nil)

Gets the nature from the corresponding lookup table

pub fn get_species(
  national_pokedex_id: Int,
) -> Result(String, Nil)

Gets the species from the corresponding lookup table

pub fn is_shiny(
  gen: Int,
  pid: Int,
  ot_id: Int,
  secret_id: Int,
) -> Bool

Checks shininess according to Gen3+ algorithm

S = OT_ID xor OT_SID xor PID{31..16} xor PID{15..0}
  if gen{3..5}: S < 8
  if gen{6.. }: S < 16
pub fn new(b64_pkm_data: String) -> Pkm

Construct the Pkm using the builder pattern, with a mandatory pattern: the pkm data as a base64 string, which will be used to serialize the Pkm as pkm binary

pub fn with_ability(pkm: Pkm, ability: List(Int)) -> Pkm

Gets the ability from the corresponding lookup table

pub fn with_effort_values(
  pkm: Pkm,
  bs: UnencryptedPkmBytes,
) -> Pkm

Uses the whole UnencryptedPkmBytes to build Pkm with effort values

As each effort_value is a field of UnencryptedPkmBytes, each effort_value will be extracted from the get_evs function

pub fn with_experience_points(
  pkm: Pkm,
  experience_points: List(Int),
) -> Pkm
pub fn with_friendship(pkm: Pkm, friendship: List(Int)) -> Pkm
pub fn with_gender(
  pkm: Pkm,
  encounter_main_info: List(Int),
) -> Pkm
pub fn with_held_item(pkm: Pkm, held_item: List(Int)) -> Pkm
pub fn with_hidden_power(pkm: Pkm) -> Pkm
pub fn with_individual_values(
  pkm: Pkm,
  individual_values: List(Int),
) -> Pkm
pub fn with_level(pkm: Pkm, level: List(Int)) -> Pkm
pub fn with_moves(pkm: Pkm, bs: UnencryptedPkmBytes) -> Pkm

Uses the whole UnencryptedPkmBytes to build Pkm with moves

As each move/pp is a field of UnencryptedPkmBytes, each move/pp will be extracted from the get_moves function

pub fn with_national_pokedex_id(
  pkm: Pkm,
  national_pokedex_id: List(Int),
) -> Pkm
pub fn with_nature(pkm: Pkm, pid: List(Int)) -> Pkm
pub fn with_nickname(pkm: Pkm, nickname: List(Int)) -> Pkm
pub fn with_origin_game(pkm: Pkm, origin_game: List(Int)) -> Pkm

This Pkm origin_game parameter, needs to be set before the shiny parameter.

The origin_game will be used to determine shininess, as shiny odds have been increased since Gen6

pub fn with_original_language(
  pkm: Pkm,
  original_language: List(Int),
) -> Pkm

Gets the original language from the corresponding lookup table

pub fn with_ot_id(pkm: Pkm, ot_id: List(Int)) -> Pkm
pub fn with_ot_name(pkm: Pkm, ot_name: List(Int)) -> Pkm
pub fn with_ot_secret_id(
  pkm: Pkm,
  ot_secret_id: List(Int),
) -> Pkm
pub fn with_pid(pkm: Pkm, pid: List(Int)) -> Pkm
pub fn with_shiny(
  pkm: Pkm,
  pid: List(Int),
  ot_id: List(Int),
  secret_id: List(Int),
) -> Pkm
pub fn with_species(
  pkm: Pkm,
  national_pokedex_id: List(Int),
) -> Pkm
Search Document