* Split up dex-data over individual files
This commit introduces:
- `dex-abilities.ts`
- `dex-conditions.ts`
- `dex-formats.ts`
- `dex-items.ts`
- `dex-moves.ts`
- `dex-species.ts`
These files centralize definitions from `dex-data` and `global-types`.
* Inherit ItemData from Item etc
Previously, Condition inherited from ConditionData. Now, ConditionData
inherits from Condition. The advantage of the new approach is that now,
Condition and DataCondition no longer need to be separate types, and
there should be much less duplication of type definitions in general.
This has also been done for
- ItemData/Item/DataItem
- AbilityData/Ability/DataAbility
- FormatData/Format/DataFormat
Species and DataSpecies was already merged, but this also reverses
their inheritance (saving a lot of duplicated definitions in the
process!)
The only one left is MoveData, which is just super complicated and
will need its own commit.
* Lint arrow-body-style
* Lint prefer-object-spread
Object spread is faster _and_ more readable.
This also fixes a few unnecessary object clones.
* Enable no-parameter-properties
This isn't currently used, but this makes clear that it shouldn't be.
* Refactor more Promises to async/await
* Remove unnecessary code from getDataMoveHTML etc
* Lint prefer-string-starts-ends-with
* Stop using no-undef
According to the typescript-eslint FAQ, this is redundant with
TypeScript, and they're not wrong. This will save us from needing to
specify globals in two different places which will be nice.
@smogon is the preferred namespace for packages (eg. @smogon/calc),
but the fact that this import logic previously contained code from
two non-Smogon sources made such naming awkward. Given the damage
calc didn't end up using these sources (and the Pokémon Showdown
client doesn't either), its simpler to just remove the logic for
third party imports entirely. This allows us to remove ugly 'hidden'
JSON5 dependency, as well as `smogon.com/` namespacing on the
sources.
This commit also tidies up the package.json and type definitions to
be more robust. It makes `--access public` the default when
publishing and cleans up unpkg support.
This is obviously a breaking change, but it's also a package rename
so we get to start the version from zero there :). A corresponding
commit will be added to the client to account for these changes.
With this change we no longer make requests to Smogon for battle
only formes (as they just get duped to their base forme), instead we
try to pull out sets for the battle-only forme based on their bases.
This also more gracefully handles the Zygarde/Necrozma edge case.
- updates smogon package dependency to the latest version
- make sure no old artifacts are left around from previous runs
- revert change from 7aa42b12: for whatever reason we do encounter
instances where `typeof species.battleOnly !== 'string'` and
`throw`-ing means no sets get output.
Not having prefer-const on the JS side makes JS -> TS refactors really
unreadable. This commit just auto-fixes it so we're using
`prefer-const` everywhere.
- add support to the RandomPlayerAI for Dynamaxing
- add support to ExhaustiveRunner for Gigantamax Pokemon
- simplify range logic in RandomPlayerAPI
- handle crash from toID (needed by data/scripts.js) and Config
(needed if a Battle takes long enough to potentially allow for
requesting ties) globals not being defined
- mark Gen 8 formats as runnable by the runners
- and error 'ls' found its way into the source
- the sets/{README.md,index.d.ts} were excluded which also meant
the sets/ directory didn't exist, causing errors
- the command is `npm publish --access public` not `publish`
`node tools/set-import [version]` can be run to create a
`@pokemon-showdown/sets` package containing sets from Smogon, usage
stats and third party sources. Some notes:
- The build is set up so that `tools/set-import/importer.ts` is
compiled to `tools/set-import/importer.js` - creating a
`.tools-dist/set-import` directory for the sole artifact was
deemed to be overkill
- The sets package is generated such that it can be used easily on
Node or in a browser (where the large set JSON can be loaded
asynchronously)
- Supported tiers/formats are mostly arbitrary - those popular
enough to have a signficant playerbase or analyses on Smogon have
been included, but additional formats can be added based on demand
- Some set information is redundant for ease of use by downstream
users: certain formes are split out and information that could
theoretically be inferred like level/ability/HP IVs are included
to simplify parsing logic and make the sets more immediately
available. This results in what should mostly be negligible
size overhead.
- In a similar vein, display versions of effect names instead of IDs
are used (name -> ID is trivial, ID -> name requires data lookup)
- All sets pass validation, provided certain simple transformations
are applied (eg. reverting `battleOnly` formes like Megas)
This tool has primarily been tested to run on Linux - running on
other platforms is not guaranteed to result in error-free output.
`import =` and `export =` are really only intended for backwards
compatibility with CommonJS. While I really don't like the new module
system TC39 has designed for us, it's what we should be using, and
consistency is important.