Coder Social home page Coder Social logo

pokemagic's Introduction

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' }]

pokemagic's People

Contributors

evertsd avatar goatslacker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pokemagic's Issues

Should probably add a README

You would probably want to add a README explaining how to compile the program and how to use it.
What it does etc...

Pokemon.json out of date

I noticed Muk's moves are incorrect. I've not found a full parse-able list of the current moves anywhere. Thanks for your work on this!

What is the pokemon level

Hi it's look great

But I have 2 small questions. What do you enter in the pokemon Level?
is it the number of power-up for this pokemon or something else?

Also when do you use this ivcalculator ?

  • Just when you catch a new Pokemon
  • Any time even with old Pokemon
  • just when you hatch an egg
  • after the first or second powerup

not working

module.js:327
throw err;
^

Error: Cannot find module 'chalk'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (-----\src\magic.js:3:15)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)

`Not found` for some pokemons.

Got most result, but not below:

name,cp,hp,stardust,leveled,minIV,maxIV
nidoran,443,72,2500,false,Not found,Not found
nidoran,437,67,3000,false,Not found,Not found
nidoran,482,62,3000,false,Not found,Not found
sparky,1171,86,3000,false,Not found,Not found

And powerup a 36~87 vaporeon, and get 22~47 IV. Will this be right?

# Before power up: 
vaporeon,1663,167,3000,false,36,87

# After power up:
vaporeon,1700,169,3500,false,22,47

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.