npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

arktosmos-pkmn-battle-engine

v1.0.1

Published

Standalone Pokemon battle simulator - a complete extraction of battle logic without external dependencies

Readme

arktosmos-pkmn-battle-engine

A standalone Pokemon battle simulator - a complete extraction of battle logic without external dependencies.

Features

  • Complete turn-based Pokemon battle simulation
  • Type effectiveness and damage calculations
  • Status conditions (burn, paralysis, sleep, freeze, poison, toxic)
  • Ability effects and triggering
  • STAB, critical hits, and secondary move effects
  • Pokemon switching mechanics
  • Battle streams for real-time event handling
  • Team packing/unpacking utilities
  • Full Pokemon data access (Dex)

Installation

npm install arktosmos-pkmn-battle-engine

Usage

Basic Battle

import { Battle, BattleStream, getPlayerStreams, Teams, Dex } from 'arktosmos-pkmn-battle-engine';

// Create a battle stream
const stream = new BattleStream();
const streams = getPlayerStreams(stream);

// Start the battle
stream.write('>start {"formatid":"gen9randombattle"}');

// Add players with teams
const team1 = Teams.pack([{
  species: 'Pikachu',
  ability: 'Static',
  moves: ['thunderbolt', 'quickattack', 'irontail', 'voltswitch'],
  level: 50,
}]);

const team2 = Teams.pack([{
  species: 'Charizard',
  ability: 'Blaze',
  moves: ['flamethrower', 'airslash', 'dragonpulse', 'roost'],
  level: 50,
}]);

stream.write(`>player p1 {"name":"Player 1","team":"${team1}"}`);
stream.write(`>player p2 {"name":"Player 2","team":"${team2}"}`);

Using the Dex

import { Dex } from 'arktosmos-pkmn-battle-engine';

// Get Pokemon data
const pikachu = Dex.species.get('pikachu');
console.log(pikachu.baseStats); // { hp: 35, atk: 55, def: 40, spa: 50, spd: 50, spe: 90 }

// Get move data
const thunderbolt = Dex.moves.get('thunderbolt');
console.log(thunderbolt.basePower); // 90
console.log(thunderbolt.type); // 'Electric'

// Get ability data
const staticAbility = Dex.abilities.get('static');
console.log(staticAbility.name); // 'Static'

// Get type effectiveness
const typeChart = Dex.types.get('Electric');
console.log(typeChart.damageTaken); // { Ground: 1, ... }

Team Packing/Unpacking

import { Teams } from 'arktosmos-pkmn-battle-engine';

// Create a team
const team = [{
  species: 'Garchomp',
  ability: 'Rough Skin',
  item: 'Choice Scarf',
  nature: 'Jolly',
  evs: { hp: 0, atk: 252, def: 0, spa: 0, spd: 4, spe: 252 },
  moves: ['earthquake', 'outrage', 'stoneedge', 'firefang'],
}];

// Pack team to string format
const packed = Teams.pack(team);

// Unpack back to object
const unpacked = Teams.unpack(packed);

Deterministic RNG

import { PRNG } from 'arktosmos-pkmn-battle-engine';

// Create PRNG with seed for reproducible battles
const prng = new PRNG([1, 2, 3, 4]);

// Generate random numbers
const random = prng.next(); // 0-1 float
const damage = prng.randomChance(85, 100); // 85% chance

ID Normalization

import { toID } from 'arktosmos-pkmn-battle-engine';

toID('Pikachu');        // 'pikachu'
toID('Mr. Mime');       // 'mrmime'
toID('Flamethrower');   // 'flamethrower'

API Reference

Core Exports

| Export | Description | |--------|-------------| | Battle | Main battle simulation class | | BattleStream | Stream-based battle interface | | getPlayerStreams | Get player input/output streams | | PRNG | Seeded pseudo-random number generator | | Dex | Pokemon data access (species, moves, abilities, items, etc.) | | Teams | Team packing/unpacking utilities | | toID | Normalize strings to IDs |

Type Exports

The package exports TypeScript types for all data structures:

  • PokemonSet - Pokemon team member definition
  • SpeciesData, MoveData, AbilityData, ItemData - Data types
  • StatsTable, BoostsTable - Stat structures
  • TypeName, StatusName, NatureName - String literal types
  • And more...

Compatibility

  • Node.js: CommonJS and ESM supported
  • Browser: Works with any modern bundler (Vite, Webpack, esbuild, etc.)
  • TypeScript: Full type definitions included

License

MIT