Commit Graph

113 Commits

Author SHA1 Message Date
Kris Johnson
1bb842e099
Convert evos/prevo/etc from IDs to names (#6625) 2020-04-28 16:02:50 -07:00
Kris Johnson
979be98574
Refactor inheritsFrom to changesFrom (#6611) 2020-04-26 14:44:25 -07:00
Kris Johnson
28bf388b98
Typescript data (#6553) 2020-04-23 09:16:09 -07:00
Guangcong Luo
091f764681 Fix rule inheritance 2020-04-08 13:25:11 -07:00
The Immortal
879b117b27 Add OU suspect test
I also made it such that unbans are no longer inherited. This makes it simpler to follow Smogon's system of tier transitivity, and suspect tests without suspect ladders.
2020-04-06 23:32:09 +04:00
Kirk Scheibelhut
d17a48cc47 Fix Dex#getForme for Flabebe 2020-04-04 21:36:58 -07:00
Kris Johnson
18dfc9ae30
Add Shared Power (#6522) 2020-04-05 00:01:02 +04:00
Kirk Scheibelhut
f4d6b7d19c Add Dex#forGen for symmetry with the client 2020-03-26 10:26:05 -07:00
Kris Johnson
ea1b028950
Rename cosmeticFormeName to forme (#6492) 2020-03-26 18:13:31 +04:00
Kris Johnson
994fc60aed
Rename Template to Species (#6478) 2020-03-25 23:29:27 -07:00
The Immortal
bbb4da0131 Refactor forme data 2020-03-18 15:17:55 +04:00
Kris Johnson
3e26318758
Refactor learnsets.js (#6466) 2020-03-18 00:59:29 -07:00
Guangcong Luo
884e059529 Correctly crash for errors in data files
Four years ago, Slayer95 added an error for invalid data files.

c1e452ea59 (diff-498e7bc80cf67d246be8aa3f2bbbb653R88)

To bypass the try/catch, he returned the error, and then checked for
the result being `instanceof Error`.

Three years ago, I refactored `tryRequire` to `loadDataFile` and moved
the `MODULE_NOT_FOUND` check from outside the function to inside it.

2604780ec5

But I didn't notice the `return new Error` pattern, so I didn't update
that to the modern pattern, so error checking has been broken ever
since.
2020-03-17 23:21:47 -07:00
Kirk Scheibelhut
743173be57 Export Nature to allow TSC to compile Pokemon
"TS4053: Return type of public method from exported class has or is
using name 'Nature' from external module but cannot be named."

PS misses out on these errors because its TSC is dump in checkJS
mode, but if you ever try to emit with TSC it will type check things
properly.
2020-03-17 18:56:44 -07:00
Kris Johnson
83ebdb27da
Add Dex#getOutOfBattleSpecies (#6463) 2020-03-16 20:31:38 +04:00
The Immortal
f0ce9b76d4 Make gen8 the default mod 2020-03-07 14:00:13 +04:00
Guangcong Luo
125fe31d06 Improve eslintrc
Fixed some more code style, allowing these rules to be enabled:

- `comma-dangle`
- `function-paren-newline`
- `member-delimiter-style`
- `no-eval`
- `no-fallthrough`
- `no-misused-promises`
- `no-unused-vars`
- `operator-linebreak`
2020-03-06 22:35:55 -08:00
Guangcong Luo
2f0e83c14b Categorize eslintrc rules
eslintrc rules are now sorted into categories, in theory making them
easier to maintain.
2020-03-06 22:35:45 -08:00
Waleed Hassan
8aa4f053bb
Use optional chaining and linter improvements (#6422)
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)
2020-03-06 11:44:32 -08:00
Guangcong Luo
b21c9047e2
Migrate to typescript-eslint (#6342) 2020-03-05 08:33:06 -08:00
Guangcong Luo
0df0d234f2 Fix Dragon Darts
Dragon Darts has a variety of mechanics that I don't care to fully
write unit tests for, but this commit should track its in-game
implementation much more closely.

If anyone still has a Dragon Darts interaction that this implementation
handles incorrectly, they should confront me about it.

Fixes #6279
2020-02-20 00:14:58 -08:00
Waleed Hassan
6714e14fc5 Fix max line length warnings (#6286) 2020-01-14 15:30:50 +04:00
Guangcong Luo
138fccbaa8 Consolidate more rules into Standard
- `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.
2020-01-03 23:42:48 -05:00
Guangcong Luo
2310934a45 Support checking for redundant rules 2020-01-03 23:42:45 -05:00
Guangcong Luo
267c815d7d Allow piecemeal repeal of inherited rules
Specifically, removing a subrule now correctly removes subsubrules.
2020-01-01 11:10:48 +09:00
Kris Johnson
36a92b5465 Move Darmanitan-Galar to Ubers (#6236) 2019-12-30 01:13:39 +04:00
Guangcong Luo
b31b88a79b Add documentation for custom rules 2019-12-25 11:26:23 +09:00
Guangcong Luo
15cfd06795 Support whitelisting in custom rules
Custom rules can now use whitelists instead of blacklists.
Whitelist rules look like:

`- all moves, + Metronome`

(Metronome Battle does not use this ruleset currently, because its
scripted check displays a better error message than a whitelist rule,
which can't actually display the whitelist as of the current
implementation.)
2019-12-25 10:05:49 +09:00
The Immortal
f62ff19e8a Improve validation for unobtainable Pokemon
This merges the Glitch and Pokestar tags into a new Unobtainable tag that defines Pokemon that are only obtainable through hacking (such as Floette-Eternal and Missingno.). These Pokemon are legal in Hackmons of their specific generation only. Custom is used in future gens instead of Past because of National Dex legality.
2019-12-25 00:35:39 +04:00
Guangcong Luo
b9fb3e3a0a Refactor test formats
`Dex.installFormat` has been deprecated and removed. Formats are now
directly created and cached by our unit test framework. This should
lead to fewer weird bugs.
2019-12-11 03:41:36 +09:00
Guangcong Luo
fe0d044d2b Fix tests to run on Gen 8 instead of Gen 7 2019-12-04 13:36:37 +09:00
Spandan Punwatkar
599a6e39fc Add some Gen 8 aliases (#6069) 2019-11-27 18:57:17 +13:00
asgdf
736f357dab Default to gen 8 mod for formats (#5969) 2019-11-16 23:25:37 +04:00
Guangcong Luo
43ef4d9785 Preload data when using Dex.forFormat
This supposedly fixes a bug where old-gen randbats were generating
invalid teams.
2019-11-17 06:32:12 +13:00
Guangcong Luo
99da82e098 Correctly set Dex mod ID to gen8
This is required for `Dex.mod('gen8')` to not crash.
2019-11-16 07:00:49 +13:00
Guangcong Luo
801af59b98 Fix remaining build errors
- Centiskorch was misspelled in formats-data, causing a crash in the
  egg validator

- A few validation errors were due to Gen 6 not inheriting from Gen 7,
  Gen 7 not having a scripts file, and Gen 8 having a gen of 7

- Intimidate (Gen 7) wasn't inheriting from Intimidate (Gen 8), giving
  it no name, causing a few validation errors

  (Technically not a build error, but I also added Keen Eye to the list
  of Intimidate immunities, as reported by SadisticMystic.)

- A lot of tests relied on Teleport always failing; these have been
  switched to Gen 7 or swapped Teleport for Celebrate

- Inverse Mod suddenly stopped working; its implementation was a huge
  hack and I can't figure out what went wrong, so I've switched it to
	using the same system the other mod tests use. It's still a huge
	hack, but I don't have the free time to fix it right now.
2019-11-16 06:08:48 +13:00
Guangcong Luo
3ddaebd181 Fix Let's Go Eevee/Pikachu-Starter validation 2019-10-07 01:58:56 +11:00
Guangcong Luo
bb9bfb8fcd Make validator bans/unbans apply in order
(Fixes an issue with RU's unban of Drought overriding NU's ban of
Drought.)
2019-10-06 17:54:28 +11:00
Guangcong Luo
c1ecbc6522 Fix misc validator bugs
- Repealing rules now always works, regardless of rule order
  (Fixes AAA validation)
- Fix a check for egg move hidden ability validation
  (Fixes a Gen 4 Dragon Dance Charizard set)
- Always ban AG when banning Uber
  (Fixes allowing Rayquaza-Mega in lower tiers)
- Fix ability validation in Let's Go
- Fix valid-move-combo dexsearch
2019-10-06 17:21:01 +11:00
Guangcong Luo
7a023746ba
Refactor battle.dex out of battle (#5851)
In most other similar systems, like TeamValidator, we use `thing.dex` instead of having it extend `ModdedDex`. Battle has always extended `ModdedDex`, though. This changes Battle to match the others.

This should fix an issue with `Battle.data` not being cached.

This also frees up Battle to extend ObjectReadWriteStream<string> in a future update.
2019-10-06 07:38:08 +11:00
Guangcong Luo
71498d451d
New validator (#5840)
* 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
2019-10-06 04:21:30 +11:00
Kirk Scheibelhut
25cea76a08
Change packed encoding of ability and gender
0|1|H|S saves minimal space over the ability ID and requires parsers have the data files, in addition to limiting the ability to search abilities in the teambuilder. Similar, gender can be elided most of the time and just chosen randomly if not specified.
2019-08-06 09:55:07 +02:00
Kirk Scheibelhut
875b02c816 Make Blitz/VGC Timer 'Rule' instead of 'ValidatorRule' 2019-07-17 12:14:35 -07:00
Guangcong Luo
0cc534092a Support timer rules 2019-07-16 16:03:02 -05:00
Guangcong Luo
413bf26d0d Correct .tier/.isNonstandard for future gens
Fixes #5243
2019-07-09 06:31:42 -05:00
Guangcong Luo
7436c1f0f2 Remove import = and export =
`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.
2019-05-16 01:27:07 +04:00
Konrad Borowski
f2ef0b62ab Remove TODO from flatMap implementation
Closes #5369
2019-05-13 19:58:20 +02:00
Kirk Scheibelhut
3d24166cdf toId -> toID
Closes #5479
2019-05-12 17:53:01 -07:00
Jacob McLemore
a1f18f0290 Chat-Plugins: Fix regression in weakness command (#5484) 2019-05-07 18:42:53 +09:30
Kirk Scheibelhut
49403556d1 getEffectByID (#5475) 2019-05-06 13:05:12 +09:30
Kirk Scheibelhut
10c744f733 Introduce an ID type to sim (#5468) 2019-05-04 13:13:12 +12:00
Guangcong Luo
4c47af28aa Refactor moveHitData
This is actually three refactors:

- swap around thing:slot for slot:thing in MoveHitData
- add Pokemon#getSlot
- remove the ActiveMove class; it's back to being an interface
2019-04-06 19:10:45 +08:00
MacChaeger
d3f1161b62 Fix Weakness Policy and Clangorous Soulblaze in doubles (#5389) 2019-04-04 18:51:27 +08:00
Konrad Borowski
d71a5c90a4 Temporarily mark flatMap as non-enumerable
This should deal with the issues with code using for-in
for arrays. This is a hack and should be removed.
2019-03-28 19:43:07 +01:00
MacChaeger
6ac8266696 Support 4 player battles (#5266) 2019-03-18 13:37:27 +09:00
Kirk Scheibelhut
0e1708bf9f Enable prefer-const and max 120 character lines for .ts files (#5292) 2019-03-16 07:14:04 +09:00
Slayer95
7a7ad8453d Fix regressions in team generators (#5302) 2019-03-12 18:44:38 -07:00
Ivo Julca
3686dcfe46 TS: ModdedDex#generateTeam() returns PokemonSet[] 2019-03-12 00:29:59 -05:00
Kirk Scheibelhut
e634d9a7b9 Cleanup Side & Dex after .ts refactor (#5273) 2019-03-09 10:14:11 -06:00
Kirk Scheibelhut
5410514b3c Refactor sim/dex-data.ts to minimize @ts-ignore (#5214) 2019-03-02 15:03:43 -06:00
Guangcong Luo
5de019ac3d Fix fs.promises warning properly
The modern `__esModule` fallback isn't compatible with Node, and also
entirely unnecessary in practice.

The approach of disabling all the fallback code allows us to once again
`import * as fs`.
2019-02-28 11:49:48 -06:00
Konrad Borowski
0d32e03159 Explicitly import readdirSync in dex.ts
This avoids ExperimentalWarnings caused by wildcard import of fs.
2019-02-27 17:17:27 +01:00
Kirk Scheibelhut
b09fd63377 Refactor sim/ to be native Typescript (#5210) 2019-02-26 11:03:30 -06:00