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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pkmn/mods

v0.9.23

Published

Support for non-standard mods to @pkmn/sim and @pkmn/dex

Downloads

439

Readme

@pkmn/mods

Test Status License npm version

An automatically generated extraction of the non-canonical mainstream mods from the smogon/pokemon-showdown simulator which can be applied to @pkmn/sim and @pkmn/dex.

Installation

$ npm install @pkmn/mods

Usage

This package contains data and logic for several mods:

  • gen1jpn: A mod on top of Generation 1 which implements Japanese version-specific mechanics
  • gen1stadium: A mod on top of Generation 1 which implements Pokémon Stadium
  • gen2stadium2: A mod on top of Generation 2 which implements Pokémon Stadium 2
  • gen4pt: A mod on top of Generation 4 which contains data from just Diamond, Pearl, and Platinum
  • gen5bw1: A mod on top of Generation 5 which contains data from just Black & White
  • gen6xy: A mod on top of Generation 6 which contains data from just X & Y
  • gen7sm: A mod on top of Generation 7 which contains Pokémon Sun & Moon data (as opposed to Ultra Sun and Ultra Moon)
  • gen7letsgo: A mod on top of Generation 7 which implements Let's Go Pikachu and Let's Go Eevee
  • gen8dlc1: A mod on top of Generation 8 which contains data from just Pokémon Sword and Shield and the Isle of Armor DLC (ie. Generation 8 without the data from the Crown Tundra DLC)
  • gen8bdsp: A mod on top of Generation 8 which implements Brilliant Diamond and Shining Pearl
  • gen9dlc1: A mod on top of Generation 9 which contains data from just Pokémon Scarlet and Violet (ie. Generation 9 without the data from the Teal Mask or the Indigo Disk DLC)
  • gen9dlc1: A mod on top of Generation 9 which contains data from just Pokémon Scarlet and Violet and the Teal Mask DLC (ie. Generation 9 without the data from the Indigo Disk DLC)

These mods can be applied to a Dex implementation by passing the data as an argument to the mod method. Because of type inconsistencies between @pkmn/sim and @pkmn/dex, to typecheck the imported mod must be cast to ModData first. This cast should be safe, but unfortunately results in slightly less ergonomic usage than would be desirable.

import {Dex, ID, ModData} from '@pkmn/dex'; // '@pkmn/sim'

const dex = Dex.mod('gen7sm' as ID, await import('@pkmn/mods/gen7sm') as ModData);

The TypeScript compiler may require special configuration to be able to directly import a subdirectory of the main @pkmn/mods package - see the tsconfig.json documentation on baseUrl and paths.

{
 "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@pkmn/mods/*": ["node_modules/@pkmn/mods/build/*"]
    }
  }
}

The ModdedDex wrapper class around Dex exists for typechecking purposes as well - if mod data contains entirely new fields, ModdedDex (initialized with the correct types as parameters) will allow for presenting a typesafe API to clients (though internally relies on casting, which is not guaranteed to be safe). There are cleaner ways to implement typesafe mods, but this ModdedDex approach aims to simply acheive parity with the upstream Pokémon Showdown implementation.

import {Dex, ID, ModData, Ability, AbilityData} from '@pkmn/dex'; // '@pkmn/sim'
import {ModdexDex} from '@pkmn/mods';

const dex = Dex.mod('foo' as ID, {
  Abilities: {
    magicguard: {
      inherit: true,
      foo: 5,
    },
    ...
  },
} as ModData);
const modded = new ModdedDex<Ability & {foo?: number}, AbilityData & {foo?: number}>(dex);

console.log(modded.abilities.get('magicguard').foo);

While not a true Dex data type, the @pkmn/mods data also includes @pkmn/sim format information for the the various mods it supports that will automatically extend the existing list of available formats when provided as an argument to Dex.mod - please refer to the @pkmn/sim documentation for full details.

Browser

The recommended way of using @pkmn/sim in a web browser is to configure your bundler (Webpack, Rollup, Parcel, etc) to minimize it and package it with the rest of your application.

License

Substantial amounts of the code in this package have been either derived or generated from portions of Pokémon Showdown code which are distributed under the MIT License.