This is mostly just a follow up to #6342.
`prefer-optional-chaining` was turned on and fixed in every location it
complained in. The transformed function [0] looks expensive from a
glance but from skimming through the replaced sites it doesn't appear
to be ran in any important place, so it should be OK.
The linter improvements are:
- Increase linter performance
- Make `full-lint` and `lint` write to different caches so we
avoid overwriting their caches since they're different configs
- Change husky's hook to `npm run lint` so as to write to the
same cache
- Remove `@typescript-eslint/eslint-plugin-tslint` which is
essentially a wrapper to TSLint because the rules aren't worth
running another linter
- Convert `.eslintrc.json` and `.eslintrc-syntax.json` to two spaces
rather than four tabs to respect PS' `.editorconfig`
- Rename `fulllint` to `full-lint` to ease spelling it
[0] - https://pastie.io/mmtxpf.js (prettified)
- `Obtainable` and `Team Preview` are now part of `Standard`
- `minSourceGen: 8` is now a part of `-Unreleased` (which is part of
`Obtainable`) in Gen 8. Instead, it's NatDex that overrides it with
`minSourceGen: 1`. This allows `!Standard, Standard NatDex` and
`!Standard NatDex, Standard` to work as intended.
- Duplicate rules are now checked for (does not apply to subrules, so
multiple inheritance is still possible)
- It is now possible to inherit `minSourceGen` from rules.
This adds new properties `isUnreleased: 'Past'` and
`unreleasedHidden: 'Past'`, which mark a Pokémon or Hidden Ability as
released in past gens, but not in the current gen. This allows them
to be banned in present-gen-only formats, but not in past-gen-transfer
formats.
`item.itemUser` replaces `item.zMoveUser`, and is a new field
representing a list of possible users of an item, for items that are
restricted to specific species.
`item.zMoveUser` is a base forme for items that affect every forme, and
a forme name otherwise (forme name is currently only used for
`forcedForme` uses).
Arceus is a weird case. Both generic Z crystals and Plates, while
having unique effects on Arceus, also have effects on other Pokémon.
For this reason, Arceus isn't listed as an `itemUser` of either of
these item types - use-cases that want this should also check
`item.forcedForme`.
This is mostly intended to be useful to move-searching and custom
rules (like NatDex, which will only allow past-gen items associated
with removed species).
Like gmaxPower, Z-move powers mostly follow a formula, which can be
applied to newer moves.
(In the future, we can save some bytes by not listing the powers.)
PS apparently doesn't have gen-accurate Ability data for Pokémon in
Gen 3 that gained Abilities between Gen 3 and Gen 4 (like Pidgeot
still has Tangled Feet in Gen 3), but that will have to be left for
a future commit.
- Tyranitar egg moves are fixed
- Staravia egg moves are now properly supported
(9742ecf62f was a hack that caused the Tyranitar problem)
- Some Pokemon evolve by having a move in their learnset (like Piloswine
with Ancient Power). These can only carry three other moves from their
prevo, because the fourth move must be the evo move. This restriction
doesn't apply to gen 6+ eggs, which can get around the restriction with
the relearner.
Fixes#2287
(Except Shiftry and friends, but those are already tracked in
`rulesets:obtainablemoves`.)
* Refactor validator
This is a major refactor intended to make the default rules easier to
understand, and also easier for OMs to bypass.
Removed rules:
- `Pokemon`: This is now `-Nonexistent`. Its previous name was intended
to be interpreted as "simulate the Pokémon games exactly, and only
allow what they allow". The new name should make it clearer that it
mainly bans CAPs and other nonexistent Pokémon and functionality.
- `-Illegal`: This is now `Obtainable` (see below).
- `Allow CAP`: This is now `+CAP`. Instead of having a hardcoded rule,
OMs can now be manually whitelist any pokemon/item/etc or group of
them, overriding `-Nonexistent`.
- `Ignore Illegal Abilities`: This is now `!Obtainable Abilities` (see
below).
`Obtainable` was previously `-Illegal`, and does the same thing: Makes
sure you have a regular Pokémon game with only Pokémon that can be
obtained without hacking.
But instead of being a ban, it's now a rule that does nothing by
itself, except contain more rules:
- `Obtainable Moves`
- `Obtainable Abilities`
- `Obtainable Formes`
- `Obtainable Misc`
- `-Nonexistent`
- `-Unreleased`
This allows OMs to piecemeal repeal and unban any of these individual
rules, instead of the previous approach of unbanning them all and
manually reimplementing every single validation you wanted to keep.
* Refactor PokemonSources into a class
This mostly just makes a lot of the weirder checks in the validator
substantially more readable.
This also renames `lsetData` to `setSources`, which should also help
readability.
* Validate Bottle Cap HP types
Fixes an issue reported here:
https://github.com/Zarel/Pokemon-Showdown/issues/5742#issuecomment-533850288
* Fix several move validation issues
Fixes#5742
We have a new MoveSource type: R for Restricted. R moves work like
level-up/tutor/TM moves, except you're limited to one R move.
- Shedinja move stolen from Ninjask in Gen 3-4 are now R moves instead
of event moves. This allows them to coexist with Nincada egg moves.
- Necrozma-DW/DM now inherit moves/events from Necrozma (like Rotom,
but with event validation). This allows them to be shiny.
- Pokemon can now get egg moves from their own evolutions. This fixes
some Tyrogue, Charmander, and Treecko sets mentioned in #5742
- Some more C moves were added, fixing some Hitmontop and Chatot sets
mentioned in #5742
* Improve ability/move compatibility validator
It turns out Template is the only remotely-easy type to merge the class
and interface for.
The others all have a bunch of event methods which would need to be
redefined on the class.