Skip to content

Latest commit

 

History

History
244 lines (200 loc) · 4.25 KB

README.md

File metadata and controls

244 lines (200 loc) · 4.25 KB

pokemagic

Usage

npm install pokemagic

API

Pokedex

Example

const dex = require('pokemagic/dex');

dex.findPokemon('jolteon'); // Pokemon
dex.findMove('struggle'); // Move
dex.getAllPokemon(); // [Pokemon]
dex.getMoves(); // [Moves]

Battle Simulator

Example

const simulateBattle = require('pokemagic/simulateBattle');

const attacker = {
  iv: 0xfff,
  lvl: 40,
  name: 'machamp',
  move1: 'counter',
  move2: 'dynamic punch',
};

const defender = {
  iv: 0xfff,
  lvl: 40,
  name: 'tyranitar',
  move1: 'bite',
  move2: 'crunch',
};

const options = {
  pvp: false,
  raid: null,
  weather: 'EXTREME',
};

const stats = simulateBattle(attacker, defender, options);

stats.winner === 'atk'; // true

Attacker/Defender Objects

{
  iv: 'number', // hexadecimal
  lvl: 'number', // 1-40
  move1: 'string', // a valid Move name (see json/moves.json)
  move2: 'string',
  pokemon: { // a valid Pokemon object (see json/pokemon.json)
    id: 'number',
    name: 'string',
    type1: 'string',
    type2: 'string',
    stats: { stamina: 'number', attack: 'number', defense: 'number' },
  },
}

Request Options

{
  pvp: 'boolean',
  raid: {
    cp: 'number',
    hp: 'number',
    cpm: 'number',
  },
  weather: 'string', // EXTREME, CLEAR, FOGGY, SUNNY (see lib/weather.js)
};

Response

const Pokemon = {
  id: 'number',
  name: 'string',
  iv: 'string',
  moves: ['string', 'string'],
  cp: 'number',
  hp: 'number',
  dmgDealt: 'number',
  dmgTaken: 'number',
}

const Response = {
  log: [{ // A log of all the moves that took place
    p: 'string', // Pokemon
    m: 'string', // Move
    dmg: 'number', // Damage
    ms: 'number', // Time
  }],
  winner: 'string', // atk | def
  timedOut: 'boolean',
  timeElapsed: 'number',
  timeRemaining: 'number',
  atk: Pokemon,
  def: Pokemon,
}

Breakpoint & Bulkpoint

Example

const breakpoint = require('pokemagic/breakpoint');

// Calculate the break/bulk points for a Raikou fighting a Kyogre
const point = breakpoint('raikou', 'kyogre');

Response

{
  atk: [{ // breakpoints
    move: 'string',
    table: [{
      dmg: 'number',
      cp: 'number',
      lvl: 'number',
      pct: 'string', // percentage increase over previous point
    }],
  }],
  def: [{ // bulkpoints
    move: 'string',
    table: [{
      dmg: 'number',
      cp: 'number',
      lvl: 'number',
      pct: 'string',
    }],
  }],

Defender Profile

Response

{
  pokemon: Pokemon,
  raidInfo: {
    cp: "number",
    hp: "number",
    cpm: "number"
  },
  counters: [{
    // Each move will have its own counters list
    quick: "string",
    charge: "string",
    // Each list belongs to a Pokemon, in case there are multiple movesets
    // that are viable counters
    results: [{
      name: "string",
      stats: [{
        dmg: 'number', // Damage dealt
        hp: 'number', // HP lost
        kop: 'number', // KO% How close can you get to KO opponent
        moves: ['string', 'string'], // Quick & Charge move
        name: 'string', // Pokemon's name
        retired: 'boolean', // Whether the moveset is legacy or not
        score: 'number', // Internally used to rank best counters
        time: 'number', // Time to win
        tm: 'boolean', // Whether moveset combo is exclusive to TM
      }],
    }],
  }],
  immune: ['string'],
  notEffective: ['string'],
  superEffective: ['string'],
}

Type Rankings

Example

  const typeRankings = require('pokemagic/typeRankings');

  const rank = typeRankings('electric');

Response

[{
  name: 'string',
  moves: ['string', 'string'],
  avgHPLoss: 'number',
  avgTime: 'number',
  dps: 'number', // Damage per second
  score: 'number', // Internally used to sort
  dmg: 'number', // Total DMG
  hp: 'number', // Total HP lost
  time: 'number', // Total time
  wins: 'number', // Number of battles won
  count: 'number', // Number of battles fought
}]

IV Calculator

Example

  const calculateIV = require('pokemagic/calculateIV');

  const matches = calculateIV(
    findPokemon('MEWTWO'), // Pokemon
    3982, // CP
    164, // HP
    40 // Level
  );

Response

Possible IV values are returned. If the array is empty then no IVs were matched.

[{ atk: 'number', def: 'number', sta: 'number' }]