@pkmn/mods
v0.9.23
Published
Support for non-standard mods to @pkmn/sim and @pkmn/dex
Downloads
439
Readme
@pkmn/mods
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 mechanicsgen1stadium
: A mod on top of Generation 1 which implements Pokémon Stadiumgen2stadium2
: A mod on top of Generation 2 which implements Pokémon Stadium 2gen4pt
: A mod on top of Generation 4 which contains data from just Diamond, Pearl, and Platinumgen5bw1
: A mod on top of Generation 5 which contains data from just Black & Whitegen6xy
: A mod on top of Generation 6 which contains data from just X & Ygen7sm
: 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 Eeveegen8dlc1
: 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 Pearlgen9dlc1
: 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.