@nxpkmn/mods
v0.6.1
Published
Support for non-standard mods to @nxpkmn/sim and @nxpkmn/dex
Downloads
2
Readme
@nxpkmn/mods
An automatically generated extraction of the non-canonical mainstream mods from the
smogon/pokemon-showdown simulator which can be
applied to @nxpkmn/sim
and @nxpkmn/dex
.
Installation
$ npm install @nxpkmn/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 Pearl
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 @nxpkmn/sim
and @nxpkmn/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 '@nxpkmn/dex'; // '@nxpkmn/sim'
const dex = Dex.mod('gen7sm' as ID, await import('@nxpkmn/mods/gen7sm') as ModData);
The TypeScript compiler may require special configuration to be able to directly import a
subdirectory of the main @nxpkmn/mods
package - see the
tsconfig.json
documentation on
baseUrl
and
paths
.
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@nxpkmn/mods/*": ["node_modules/@nxpkmn/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 '@nxpkmn/dex'; // '@nxpkmn/sim'
import {ModdexDex} from '@nxpkmn/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);
Browser
The recommended way of using @nxpkmn/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.