Skip to content

Online Pokémon Showdown Team parser that converts your competitive strategies to machine-readable JSON code.

License

Notifications You must be signed in to change notification settings

itsjavi/koffingjs

Repository files navigation

Koffing

npm version Build Status

Koffing is a Pokemon Showdown importable-syntax parser for JavaScript and TypeScript.

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 Gen 9 Pokémon definitions
  • Compatible with web browsers, ES6+, TypeScript and NodeJS
  • Converts from Showdown code to JSON and vice-versa
  • 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 koffing

# or

pnpm add koffing

Usage

Javascript (ES5, web)

<script src="https://unpkg.com/koffing@latest/dist/index.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>

Javascript/TypeScript (ES Modules)

'use strict'

import { Koffing } from 'https://unpkg.com/koffing@latest/dist/index.mjs'
// or
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`

const parsedTeam = Koffing.parse(teamCode)

// This will log a PokemonTeamSet object:
console.log(parsedTeam)

// Convert it back to the Showdown format (prettified). These 3 lines are equivalent:
console.log(parsedTeam.toShowdown())
console.log(parsedTeam.toString())
console.log(parsedTeam + '')

NodeJS

const Koffing = require('koffing').Koffing

const teamCode = `=== [gen7] Folder 1/Example Team ===`
const parsedTeam = Koffing.parse(teamCode)

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/itsjavi/koffing

About

Online Pokémon Showdown Team parser that converts your competitive strategies to machine-readable JSON code.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published