Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

koffing

0.4.0 • Public • Published

Koffing

Koffing is a Pokemon Showdown Team parser that converts your strategies to machine-readable JSON code.

koffing 🔁koffing

Pokémon Showdown is the most popular online Pokémon battle simulator, one of the best ways to quickly try your strategies for the official Pokémon VGC Championships. This library is just a parser for the teams generated by the Showdown Team Builder exports.

This repository holds the source code for the library as well as the code for the Online Parser. The Online Parser, does not require you to download any library or script, it is recommended if all you want is to sanitize, prettify or convert to JSON your Showdown team exports.

Features

  • Compatible with web browsers and NodeJS, including ES6+ imports
  • Converts from Showdown code to JSON
  • Converts from JSON to Showdown code
  • Sanitizes Showdown code (removing invalid data, applying max and mins values, etc.)
  • Prettifies Showdown code (proper indentation, line breaks and sorting of the data, etc.)
  • Online Parser, which is using the library featuring all the above mentioned.

Installation

As a package:

npm i --save koffing

In the browser, using a CDN:

<script src="https://cdn.rawgit.com/capsulemonsters/koffing/0.4.0/dist/koffing.min.js"></script>

Usage

Modern Javascript (ES6+)

"use strict";
 
import {Koffing} from 'koffing';
 
const teamCode = `
=== [gen7] Folder 1/Example Team ===
 
Smogon (Koffing) (F) @ Eviolite
Level: 5
Ability: Levitate
Shiny: Yes
Happiness: 255
EVs: 36 HP / 236 Def / 236 SpD
IVs: 31 HP / 30 Atk / 31 SpA / 30 SpD / 31 Spe
Bold Nature
- Will-O-Wisp
- Pain Split
- Sludge Bomb
- Fire Blast`;
 
 
let parsedTeam = Koffing.parse(teamCode);
 
// This will log a PokémonTeamSet object:
console.log(parsedTeam);
// Convert it back to the Showdown format (prettified):
console.log(parsedTeam.toShowdown());
// which is the same as:
console.log(parsedTeam.toString());
// and the same as:
console.log(parsedTeam + "");
// You can also convert the object to JSON:
console.log(parsedTeam.toJson());
// which is the same as:
console.log(Koffing.toJson(teamCode));

Web (ES5)

<script src="dist/koffing.min.js"></script>
<script>
var teamCode = `=== [gen7] Folder 1/Example Team ===`;
var parsedTeam = Koffing.parse(teamCode);
console.log(parsedTeam);
 
// Note that the ShowdownParser class, which is used internally by the Koffing class
// is also exposed in the global scope:
console.log(new ShowdownParser(teamCode).parse());
</script> 

NodeJS

const Koffing = require('koffing').Koffing;
 
const teamCode = `=== [gen7] Folder 1/Example Team ===`;
let parsedTeam = Koffing.parse(teamCode);
console.log(parsedTeam);

Class Reference

The Koffing class is basically a wrapper of the ShowdownParser class, the difference is that it can be used statically.

ShowdownParser class methods:

  • parse(): PokemonTeamSet: Parses the Showdown code and returns a PokemonTeamSet object.
  • format(): String: Parses the Showdown code and returns a prettified and sanitized version of it.
  • toString(): String: Basically returns the internal Showdown code string as it is.

Koffing class methods:

  • static parse(showdownCode): PokemonTeamSet: Wrapper for ShowdownParser.prototype.parse()
  • static format(showdownCode): String: Wrapper for ShowdownParser.prototype.format()
  • static toJson(showdownCode): String: Wrapper for ShowdownParser.prototype.parse().toJson()
  • static toShowdown(jsonCode): String: Wrapper for ShowdownParser.prototype.parse().toShowdown()

License

This software is copyrighted and licensed under the MIT license.

Disclaimer

This software comes bundled with data and graphics extracted from the Pokémon series of video games. Some terminology from the Pokémon franchise is also necessarily used within the software itself. This is all the intellectual property of Nintendo, Creatures, inc., and GAME FREAK, inc. and is protected by various copyrights and trademarks.

The authors believe that the use of this intellectual property for a fan reference is covered by fair use and that the software is significantly impaired without said property included. Any use of this copyrighted property is at your own legal risk.

This software is not affiliated in any way with Nintendo, Pokémon or any other game company.

A complete revision history of this software is available from https://github.com/capsulemonsters/koffing

Install

npm i koffing

DownloadsWeekly Downloads

0

Version

0.4.0

License

MIT

Unpacked Size

62.1 kB

Total Files

10

Last publish

Collaborators

  • avatar