Commit Graph

929 Commits

Author SHA1 Message Date
Mia
6839a1f4db
Add a library for utility functions (#6817) 2020-06-09 22:06:43 -07:00
urkerab
9c2690321c
Allow formats to reorder all six Pokémon again (#6813) 2020-06-07 06:45:43 -07:00
Kris Johnson
73a84a43ec
Fix remaining learnsets inconsistencies (#6795) 2020-06-02 21:31:48 -07:00
Guangcong Luo
4f790cf04f Validate learnset order 2020-06-02 01:02:01 -07:00
urkerab
29feb50376
Fix display of Gen 8 Nursery Mechanics in /learn (#6784) 2020-06-01 22:00:45 -07:00
Kirk Scheibelhut
a58f26d29c Fix EBC restorative berry-cycling win condition
ede3aaec correctly added restorative berries to the
staleness/termination calculation as per the adjusted specification
but failed to update the win condition.
2020-05-31 15:40:36 -07:00
Kris Johnson
5f724397fc
Make Species#nfe work for previous generations (#6776) 2020-05-30 21:36:47 -07:00
Kirk Scheibelhut
ede3aaec2b Include 1/4 HP restoring berries in EBC with Leppa
Thanks pigeons and thimo for coming up with edge cases!

https://replay.pokemonshowdown.com/gen8balancedhackmons-1124152144
2020-05-30 21:26:37 -07:00
Kirk Scheibelhut
54026a5cf7 Only check for EBC after 100 turns have passed
Per DaWoblefets suggestion to avoid interfering with regular play
2020-05-30 20:46:17 -07:00
Kris Johnson
a7948c7c9c
Typescript config/ (#6760) 2020-05-29 19:34:43 -07:00
urkerab
d3a3666e85
Fix bugs caused by not specifying effectiveness priority (#6765)
Inverse Mod needs to go first, to calculate the negated effectiveness.
Disguise goes second, to suppress effectiveness.
Delta Stream goes third, to weaken moves super-effective against Flying types.
Tar Shot goes last, to make its victim weak to Fire type moves.

This allows the existing test for Delta Stream with Tar Shot to pass.
Additionally a new test for Delta Stream with Inverse Mod now passes.
A test for Flying Press with Inverse Mod is also included.
2020-05-29 16:55:42 -07:00
urkerab
45c4bb42fc
Simplify handling of trunc for custom battles (#6767) 2020-05-29 16:46:04 -07:00
The Immortal
df8b99d244 Fix Kyurem learnset validation 2020-05-28 00:41:31 +04:00
Sigmatecture
18b8d019ed
Set Random Battle singles levels by species (#6706) 2020-05-27 00:31:41 +04:00
Guangcong Luo
381bd7508a Clarify species limit and requiredItem errors 2020-05-16 12:30:41 -04:00
The Immortal
8be031bb6d Gen 3 Random Battle: Overhaul set generation 2020-05-14 07:58:36 +04:00
Guangcong Luo
f186eb8e5b Prevent nicknames from getting cut off
Nicknames that are too long will now give an error message instead of
silently being truncated.
2020-05-12 03:14:56 -07:00
Kris Johnson
56fbb0201a
Pikachu-Gmax is now available from raids (#6679)
* Pikachu-Gmax is now available from raids

* Volt Tackle is legal on Gmax Pikachu now
2020-05-12 06:14:57 +04:00
Kris Johnson
d20f1fbb64
Typescript info (#6670) 2020-05-11 03:08:33 -07:00
Kirk Scheibelhut
fa65ed4979
Add alt form index data to dex (#6669)
AltForm index info obtained from kwsch/PKHeX's FormConverter.cs (thanks Kurt).
Thanks to @Lusamine (Anubis) for help with the peculiarities.
2020-05-10 12:20:40 -07:00
Guangcong Luo
3a1fe75b13 Remove isViable from moves
It's a judgment call that doesn't belong among the other factual
information in `moves.ts`.

The information is still around; in the client's `battle-dex-search.ts`
in `BattleMoveSearch#moveIsNotUseless`. But now it's all in one place.

fb18721e82
2020-05-08 19:25:51 -07:00
Kirk Scheibelhut
d621a4b670 Don't assign Struggle a zMove.basePower of 100
This check exists for maxMove.basePower but not zMove. Thank you
SadisticMystic for confirming that while "it has an entry of 1 in
the data table, [it]'s a meaningless entry which is impossible
to access"
2020-05-04 21:49:01 -07:00
Kirk Scheibelhut
2af7040270
Group zMove and maxMove attributes (#6652)
This mostly serves to provide cleaner and more consistent field
naming. maxMove currently doesn't have boosts or effects to group
together but who knows what will be thrown at us via DLC, and being
symmetrical with zMoves is a nice.
2020-05-04 20:21:27 -07:00
Kris Johnson
8faaa45eb8
Gen 8 CAP learnset updates (#6636) 2020-05-04 19:05:28 +04:00
urkerab
1eff20a530
Fix G-Max Chi Strike's effect on Crit Ratio (#6639) 2020-05-01 21:14:01 -07:00
Guangcong Luo
56f6ab5489 Fix Zygarde-Complete validation 2020-05-01 13:02:30 -07:00
urkerab
544417e31f
Gen6+ Transform should also remove Focus Energy if necessary (#6637) 2020-05-01 12:01:56 -07:00
Guangcong Luo
c4dd88ac96 Update Effect type signatures
- `affectsFainted` is a `PureEffect` property

- `infiltrates` shouldn't exist on moves outside of OMs
2020-05-01 11:56:54 -07:00
Guangcong Luo
517d02f016 Fix crash with validating pokemon without learnsets 2020-05-01 14:54:11 -04:00
Kirk Scheibelhut
b05e1941e2 Ensure explosion halves defense in Gen 3&4 2020-05-01 11:03:54 -07:00
Kirk Scheibelhut
74e1e3692f
Fix default Max/Z power for isMax/isZ moves (#6634) 2020-05-01 00:35:10 -07:00
Guangcong Luo
7aa42b1212 Remove Dex.getOutOfBattleSpecies
Literally every current use is a bug.
2020-04-30 23:29:20 -07:00
Guangcong Luo
e0f6453b60 Refactor data definitions
- `Modded[Effect]Data` are now correctly defined: they must either have
  `inherit: true` and be partial, or not have `inherit: true` and be a
	complete `[Effect]Data` entry

- `id` is no longer allowed; instead, it's calculated directly from
  `toID(name)`. The one exception, Hidden Power, gets a `realMove`
	property to track this (it's still used to set `.id`, though;
	TODO: really fix it properly).

- `num` is still required in `data/pokedex.ts` (dex number),
  `data/moves.ts` (move index number, for Metronome), and
	`data/items.ts` (minisprite sprite-sheet location). It's still not
	required for mod-only items and moves.

- `num` is no longer allowed for PureEffects (in `statuses.ts`) where
  it's always been meaningless.

- `color` and `heightm`, being completely flavor, are still not
  required for `pokedex.ts` in mods. They're still required in the base
	pokedex.
2020-04-30 21:39:29 -07:00
Guangcong Luo
826e544b65 Refactor random set generation
The whole `checkBattleForme` system, introduced in 4410843e5a
and currently used in Gen 6 and 7, seems to have always been bugged.

As TI mentions in #5970, we already use `getPokemonPool` for alternate
forme handling.

I've replaced it with a roll for cosmetic formes.
2020-04-30 17:52:04 -07:00
Marty-D
15e4d4f2bd
Gen I-IV: Correctly treat both players having no Pokemon left as a tie 2020-04-30 14:01:32 -04:00
Kirk Scheibelhut
edddcb5c38
Correct Self-Destruct and Explosion base power (#6630)
As confirmed by SadisticMystic, base power cannot be above 255, so
this move data is clearly incorrect and results in downstream users
of the data files such as the Smogon or PS dex or the tooltips
displaying misleading information.
2020-04-29 14:59:59 -07:00
Guangcong Luo
9319f68423 Remove Unown forme from locked users
Apparently our old hack was to prevent Unown formes completely, because
locked users would sometimes use them to spell bad words.

I don't like that approach, so now only locked users can't use Unown
formes.
2020-04-29 14:15:04 -07:00
Guangcong Luo
800d8bd8f3 Remove Dex.getForme etc
The server now uses the same approach as the client of treating
cosmetic formes as real formes, as documented in `FORMES.md`.

This eliminates the need for the `.forme` and `.speciesid` properties
of `Pokemon`.

`pokemon.id` has also been removed: useful, since it turns out half
of its uses were bugs that should have used `pokemon.species.id`.
2020-04-28 17:38:54 -07:00
Guangcong Luo
42f949a0ed Remove egg group info from Gen 1 Pokédex 2020-04-28 16:25:35 -07:00
Kris Johnson
1bb842e099
Convert evos/prevo/etc from IDs to names (#6625) 2020-04-28 16:02:50 -07:00
urkerab
1ede5508aa
Moxie and Beast Boost should have one combined boost for all fainted Pokémon. (#6557)
In addition, they should not activate for a spread move that ends the game.
(This contrasts with Soul-Heart, which will activate until the last target.)
2020-04-27 15:44:33 -07:00
Guangcong Luo
e8e3493c40 Fix Struggle activation conditions
PS wasn't correctly detecting `disabled: 'hidden'` moves as disabled
for the purposes of detecting Struggle activation. This has been fixed.

Thanks to DaWoblefet for unit tests!

Fixes #6620
2020-04-26 17:52:06 -07:00
Guangcong Luo
987eb08ad2 Fix gmaxPower location 2020-04-26 17:52:06 -07:00
Kris Johnson
979be98574
Refactor inheritsFrom to changesFrom (#6611) 2020-04-26 14:44:25 -07:00
urkerab
fce96d8a15
Pass the Transform or Imposter effect to onModifySpecies (#6623) 2020-04-26 14:12:10 -07:00
Kirk Scheibelhut
30defec706
Validate that SpA and SpD EVs match in Gen 2 (#6615)
Pointed out by FOMG in https://www.smogon.com/forums/threads/gen-2-ps-development-post-bugs-here.3524926/post-8439815
2020-04-25 13:01:02 -07:00
Guangcong Luo
c5faebd739 Remove extraneous properties from BasicEffect
BasicEffect always had a `status` property to support the pattern of
testing it to see if it's a move that sets status directly.

This is just a situation that TypeScript is bad at.

Another possibility would be to set `status: undefined` on PureEffect,
Ability, Item, and Species, but I think that's also ugly. Casting to
Move is probably the best approach, so that's what we do now.
2020-04-25 12:57:46 -07:00
Guangcong Luo
549ef7edb1 Fix MoveData interface definition
For historical reasons, move property definitions have been very blurry
across `EffectData`. Fortunately, recent refactors have made it
possible to put them all where they're supposed to be.
2020-04-25 12:57:46 -07:00
Guangcong Luo
5d63b16d4d Fix botched merge in data/.ts refactor
The data/.ts refactor left a few .js files in, which weren't deleted
between 13 and 3 days ago:

c85f5bccb0

Because of this, the corresponding `.ts` files were considered new,
rather than renamed, and changes to the `.js` files got deleted rather
than merged.

Fortunately, this only affected `moves.js`, which has now been manually
re-merged with the changes.
2020-04-23 11:22:21 -07:00
Kris Johnson
28bf388b98
Typescript data (#6553) 2020-04-23 09:16:09 -07:00
Guangcong Luo
ebbcbf06a8 Fix Gen 2 gender ratio calculation
(Apparently it was based on older incorrect gender ratio information
from Bulbapedia.)

New version confirmed by Marty.
2020-04-20 12:51:44 -07:00
The Immortal
f194d31aac Fix G-Max moves legality again 2020-04-16 04:47:15 +04:00
Kirk Scheibelhut
78151fad79 Fix 32e193b2 to rely on isMax instead of Nonstandard 2020-04-15 16:15:19 -07:00
Guangcong Luo
900ad5a8c8
Prioritize -All Pokemon above +Past etc (#6574)
Previously, format bans/unbans were processed in order of "most specific
to least specific".

So `+Giratina-Origin` trumps `-Giratina` trumps `+Uber` trumps
`-All Pokemon`.

And nonstandard reasons (`Unobtainable`, `Past`, `CAP`, etc) were
slotted between `Uber` and `All Pokemon`.

This has the unfortunate effect that if a base ruleset allows a certain
normally-banned category of Pokémon, you can't use `-All Pokemon` to
whitelist a list of Pokémon.

Moving nonstandard reasons to lowest precedence once again allows
`-All Pokemon` to be used as intended.
2020-04-14 15:27:59 -07:00
The Immortal
32e193b2b9 Prevent G-Max moves from being used in Hackmons 2020-04-13 19:41:54 +04:00
Guangcong Luo
13ddc8f908 Add Custom Game warning for 510 EV limit
Custom Game is intended to be a "choose your own rules" format. It's usually pretty easy to tell if a
rule is being followed or not (a level 500 Pokémon is rather conspicuous) but EVs are generally
considered a secret.

For this reason, I've added a message for a discrepancy in EV use: one player adhering to the 510 EV
limit, and the other player not adhering to it.

This message is specific to Debug Mode (which Custom Game is, by default), which already leaks some
minor information, anyway.

To avoid information leaks completely, use Custom Rules:

https://github.com/smogon/pokemon-showdown/blob/master/config/CUSTOM-RULES.md
2020-04-11 04:20:19 -04:00
Kirk Scheibelhut
1f8c6bc7b8 Fix illegal ActiveMove cast in battle.ts
Frankenstein checkJs-Typescript with globals derps out and lets this
kind of thing slide, but without `hit` (which is only assigned the
line below) you can't cast to ActiveMove.
2020-04-08 22:33:56 -07:00
Kris Johnson
c13a12cb65
Add mod support for Field (#6543) 2020-04-08 16:22:52 -07:00
Guangcong Luo
091f764681 Fix rule inheritance 2020-04-08 13:25:11 -07:00
Guangcong Luo
0fb601f7f2 Don't allow arrays in battle.add
A bug in Mimicry happened because someone put an array into
`battle.add`. This shouldn't happen.

(Also add a hint for Mimicry.)
2020-04-08 11:17:48 -07:00
Guangcong Luo
2a3b739644 Work around teambuilder nickname issue
Apparently the teambuilder still defaults nicknames to full species
names, instead of base names as you might expect. This will have to be
fixed later...
2020-04-08 10:36:37 -07:00
Guangcong Luo
5abdb88e55 Refactor EventListener
Renames:
- .status -> .effect
- .statusData -> .state
- .thing -> .effectHolder

`thing` was always a really weird "I don't know what to call this"
variable name, but it's been renamed `effectHolder`, which should be
much clearer. `status` -> `effect` is I think the last remnant of old
PS code which called all effects "statuses". `statusData` -> `state`,
on the other hand, is the very first step in an initiative to calling
less things "data".
2020-04-07 17:05:19 -07:00
Guangcong Luo
ff0b80f297 Fix triples shift priority 2020-04-07 10:56:20 -07:00
Guangcong Luo
9d3351f12d Nickname Clause: Enforce after format validation
This allows OMs like Cross Evolution to use nicknames of other species
in `onValidateSet`.

Enforcement also now generates an error message, instead of silently
changing the name.
2020-04-07 10:56:19 -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
The Immortal
634658a5ba Refactor unreleased Pokemon
Pokemon that are not available in-game are now consolidated into `isNonstandard`. 'Past' indicates that the Pokemon no longer works in the current generation. 'Unobtainable' indicates that the Pokemon works but can only be obtained through hacking.
2020-04-06 20:53:03 +04:00
The Immortal
78fde78f19 Refactor unavailable moves
Moves that are not available in-game are now consolidated into `isNonstandard`. 'Past' indicates that the item no longer works in the current generation. 'Unobtainable' indicates that the item works but can only be obtained through hacking.
2020-04-06 20:26:10 +04:00
The Immortal
387dd7ce2d Refactor unavailable items
Items that are not available in-game are now consolidated into `isNonstandard`. 'Past' indicates that the item no longer works in the current generation. 'Unobtainable' indicates that the item works but can only be obtained through hacking.

Credit to @lusamine for testing many of these items in Sw/Sh.
2020-04-05 23:54:57 +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
Guangcong Luo
20e7e604eb Unify more switch-in code
This removes the redundant 'SwitchOut' code, and continues to ensure
that switching and dragging share as much code as possible, which
should help avoid bugs where they previously were different for no
reason.
2020-04-03 19:08:54 -07:00
Waleed Hassan
855899b330
Fix Battle#switchIn (#6521)
Regression caused by: 47b55f96bc

`Battle#dragIn` used to run the `SwitchOut` event among other functions
but were accidentally left off in the refactor. This commit adds them back.

The main bug caused by this is Natural Cure not curing status aliments when
phased out by Roar.
2020-04-03 09:22:55 -07:00
Guangcong Luo
e10a6459d7 Refactor hasType
Closes #6501
2020-03-31 02:39:33 -07:00
Guangcong Luo
75bff1cbb7 Fix validation for event-only VC Pokémon
Previously, we had a weird carved-out exception for Celebi from
74143b652d

But it actually applies to all VC Pokémon (most importantly Suicune).
2020-03-30 07:09:12 -07:00
Guangcong Luo
ba4fab47d2 Implement pokemon.previouslySwitchedIn 2020-03-30 05:27:58 -07:00
Guangcong Luo
47b55f96bc Refactor dragIn to delegate to switchIn
dragIn and switchIn being two separate functions is a weird historical
quirk that leads to inconsistencies in implementation.

The only reason they need to be separated is a Mold Breaker quirk:
1da65efb12

(This is now done with an `if` statement.)

This should fix a lot of Roar/Whirlwind mechanics issues from `dragIn`
being on outdated mechanics compared to `switchIn`.
2020-03-30 05:25:20 -07:00
Guangcong Luo
2d78044604 Fix activeTurns/activeMoveActions bugs
`activeTurns` was previously a horrible hack, used for "first full turn
only" effects like Speed Boost as well as "first move action" effects
like Fake Out.

In addition to being a huge hazard for API users such as OMs, this also
means weird bugs such as Speed Boost not working if you get hit by
Sky Drop on your first turn.

This commit fixes them by splitting these counters into two - an
`activeTurns` counter for Speed Boost, and an `activeMoveActions`
counter for Fake Out.
2020-03-30 04:07:05 -07:00
Guangcong Luo
60effa1838 Fix DW move validation 2020-03-30 02:29:13 -07:00
Marty-D
7a09037213 Validator: Fix Gen 2 event move tradebacks 2020-03-26 13:54:14 -04:00
Kirk Scheibelhut
f4d6b7d19c Add Dex#forGen for symmetry with the client 2020-03-26 10:26:05 -07:00
The Immortal
81891546b9 Rename Missingno. to MissingNo. 2020-03-26 18:37:35 +04: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
Guangcong Luo
2534753325 Fix Hidden Ability validation 2020-03-24 23:55:54 -07:00
Guangcong Luo
5108a62f5e Standardize on using + for move targeting
Move targets are now intended to be +1 +2 +3 for foes. The old syntax
of using 1 2 3 is still supported, but is not recommended.

(The old syntax will still be used in the old client, but the Preact
client will support the new syntax going forward.)

This makes the difference between move number and move target
clearer.

This also fixes the Conversion 2 ambiguity (although for backwards
compatibility, we do still need to special-case it).
2020-03-23 23:50:46 -07:00
Guangcong Luo
90c503724f Support and document /move max mindstorm
Dynamax and Z move decisions can now be input by naming the max move
or z-move involved.

Fix #6425
2020-03-21 23:38:04 -07:00
Kris Johnson
770f1a3f7c
Add support for (NU) (#6475) 2020-03-20 20:50:14 -07:00
The Immortal
1765d9fbfa Improve bbb4da013 2020-03-19 02:06:10 +04:00
The Immortal
c09044a777 Move gen property to Pokedex 2020-03-18 23:09:45 +04: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
Guangcong Luo
40499b6cf6 Remove dependency of sim on Config 2020-03-17 21:06:40 -07:00
Guangcong Luo
f2357d167b Document EventInfo.shiny
It defaults to "never shiny" rather than "sometimes shiny" as might be
intuitively obvious, so it deserves documentation about this.
2020-03-17 19:44:50 -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
Kirk Scheibelhut
508c2ed4aa Exported constant classes can't have private modifiers 2020-03-17 18:52:45 -07:00
Kirk Scheibelhut
17501fc001
Remove restrictions on concurrent battle searches (#6462)
https://www.smogon.com/forums/threads/improve-searching-for-concurrent-ladder-battles.3660989/
2020-03-16 21:17:34 -07:00
Kris Johnson
83ebdb27da
Add Dex#getOutOfBattleSpecies (#6463) 2020-03-16 20:31:38 +04:00
Kris Johnson
b077646808
Random Battles chat plugin: Fix various issues (#6448) 2020-03-12 12:37:10 +04:00
Guangcong Luo
64ff1da81f Refactor more things to use inheritsFrom 2020-03-10 09:59:36 -07:00
The Immortal
84253d40ee Fix getPokemonPool 2020-03-10 17:43:03 +04:00
Kris Johnson
82a3fc7b94
Refactor [Gen 2] Random Battle (#6435) 2020-03-09 11:56:15 +04:00
Kris Johnson
86761e3577
Add Random Battles chat plugin (#6433) 2020-03-09 09:55:43 +04:00
Kirk Scheibelhut
36b5b48d79 Add Gen 8 support for RandomPlayerAI and sim tools
- 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
2020-03-08 20:56:59 -07:00
Guangcong Luo
38e4af504c Fix Emergency Exit on switch-in 2020-03-08 20:16:53 -07:00
Guangcong Luo
fbc6d2a6d0 Fix Emergency Exit with residual damage
Fixes #6424
2020-03-07 15:47:44 -08: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
8d140b4bca Fix Gmax validation
(Gmax Pokémon can't be from older gens.)
2020-03-06 10:41:33 -08:00
Guangcong Luo
738503888b
Add a skipSets parameter to validateTeam (#6416) 2020-03-05 15:01:14 -08:00
Guangcong Luo
b21c9047e2
Migrate to typescript-eslint (#6342) 2020-03-05 08:33:06 -08:00
The Immortal
be5ca7d2e3 Update Keldeo validation 2020-03-01 18:21:14 +04:00
asgdf
389fb22376
Validator: Check for negative EVs (#6409) 2020-03-01 03:22:17 -08:00
Guangcong Luo
c64ad07385 Fix typo 2020-02-23 22:17:22 -08:00
Guangcong Luo
9a4cf1149c Rename getRequestData functions
We now have `pokemon.getMoveRequestData()` and
`pokemon.getSwitchRequestData()`, which should make it much clearer
which one does what.
2020-02-23 22:10:49 -08:00
Guangcong Luo
a41e4b051f Fix infinite loop with disabled Max Guard 2020-02-23 04:47:52 -08:00
urkerab
98edf3e025
Refactor Dragon Darts (#6378) 2020-02-21 06:36:41 -08:00
The Immortal
8e93518550 Max Guard is disabled by Taunt 2020-02-21 15:49:27 +04:00
Guangcong Luo
658f853558 Fix bug in Battle Stadium Gigantamax validation 2020-02-21 03:40:16 -08:00
Guangcong Luo
f89f44f209 Max Guard is disabled by Assault Vest 2020-02-21 00:46:28 -08:00
Guangcong Luo
8cb6c1f58f Fix Ally Switch Dragon Darts 2020-02-20 01:27:07 -08:00
Guangcong Luo
229f5f809d Use assert in strict mode
This makes it so we can use `assert.equal` instead of
`assert.strictEqual`, which I think is more readable.
2020-02-20 00:39:31 -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
Guangcong Luo
9a9d27dadd Fix Darmanitan-Galar-Zen 2020-02-19 01:01:58 -08:00
Guangcong Luo
e3c9cf22ab Fix Max move Lightningrod redirection
Max moves can be redirected to allies, even though they can't
normally hit allies.

Fixes #6375
2020-02-19 01:01:58 -08:00
Guangcong Luo
07ae9d0ea2 Add hint for Court Change Sticky Web Defiant 2020-02-17 00:22:47 -08:00
Guangcong Luo
78eceb6f03 Fix Emergency Exit activating on faint 2020-02-16 23:42:43 -08:00
Guangcong Luo
1fa9e141f6 Fix Pledge moves 2020-02-15 13:38:58 -08:00
Guangcong Luo
7dab5f8d79 Fix Rapid Spin activation order
Order should be:

1. -Spe
2. Rocky Helmet
3. hazard removal if not fainted
2020-02-14 18:13:49 -08:00
Guangcong Luo
b14b38598b Improve sim protocol documentation
This new protocol spec resolves ambiguities in cases where multiple
message types would be valid (no more wondering if an ability
activation is `-activate` or `-ability`, no more wondering if a
blocked attack is `-fail` or `-block` or `-immune` or `-activate`). It
also better matches the client's `data/text.js`.
2020-02-14 17:01:18 -08:00
Guangcong Luo
9562fdff58 Fix crash when rejoining battles 2020-02-14 15:00:34 -08:00
Guangcong Luo
d4e2871665 Support validating Gen 8 egg moves
Gen 8 egg moves can be grafted onto existing Pokémon, removing
compatibility issues.
2020-02-14 10:57:31 -08:00
The Immortal
5a7ec76b6b Fix validation for Virtual Console & Let's Go moves 2020-02-13 23:59:51 +04:00
Kris Johnson
358d947b15
Add Let's Go transfer support (#6367) 2020-02-12 21:22:45 -08:00
Guangcong Luo
652c7163cf
Refactor queue to new BattleQueue class (#6358)
Previously, battle queue stuff was just strewn around `battle.ts`.
This gives it a new home: `battle-queue.ts`.

This was intended to make `battle.ts` slightly more tractable, although
the difference is so small that maybe I shouldn't bother. Oh, well,
every little bit helps.
2020-02-12 16:20:17 -08:00
Kris Johnson
92c7d377a7
Add Pokemon Home support (#6349)
Co-authored-by: The Immortal <the_immortal123@live.com>
2020-02-12 14:54:55 +04:00
The Immortal
19cdf79821 Update OMs 2020-02-12 14:19:29 +04:00
Guangcong Luo
1914a37aba Fix Eject Pack to activate for self-boosting 2020-02-11 11:16:46 -08:00
Guangcong Luo
6a677e39e8 Fix Emergency Exit timing
This is a really hacky implementation of Emergency Exit, but Emergency
Exit itself is a huge mess on cart, too.

Our previous implementation:
- activated Emergency Exit at AfterMoveSecondary timing for move damage
- activated Emergency Exit immediately after dealing any other damage

This new one:
- activates Emergency Exit only in three situations:
- right after AfterMoveSecondary timing, for move damage
- right after DamagingHit timing, for DamagingHit residual damage
  (Rough Skin, Iron Barbs, Rocky Helmet)
- right after the switch update, for switch-hazard residual damage
  (Stealth Rock, Spikes)
- does not otherwise activate (so Substitute, Hail, Toxic, etc no
  longer activate Emergency Exit)

This should much accurately simulate Emergency Exit behavior, including
most famously timing it after healing berries after hazards, as
documented in:

https://www.smogon.com/forums/threads/pokemon-sun-moon-battle-mechanics-research.3586701/#post-7075354

Fixes #6309
2020-02-08 08:07:39 -08:00
Guangcong Luo
55cbc52bba Fix bugs with secondary/ability order
Fixes #6346

The `AfterDamage` event has been replaced with `DamagingHit`, which
which happens for damaging moves after secondaries.

The `AfterHit` event has also been moved after `DamagingHit`, to make
sure Knock Off still procs after Rocky Helmet.

`AfterHit` is no longer a valid event on `secondary` and `self` blocks,
because it's meaningless in those blocks, anyway. All `self.onAfterHit`
and `secondary.onAfterHit` handlers have been moved to `onHit`, which
should have the same timing in practice.
2020-02-08 08:07:39 -08:00
Kris Johnson
9f08d93244
Toxtricity-Low-Key can Gigantamax (#6343) 2020-02-07 03:54:07 +04:00
Kris Johnson
d3e266cddd
Fix crash with TRs (#6330) 2020-02-03 00:25:49 -08:00
Kris Johnson
05efe2e011
Add TRs (#6317) 2020-02-02 23:19:45 -08:00
Marty-D
8d644fcb0c Calculate Innards Out damage using non-Dynamax HP 2020-02-02 18:04:33 -05:00
The Immortal
d9327d945a Simplify max moves check in Copycat 2020-02-02 22:30:04 +04:00
The Immortal
6db191a0a8 Implement Copycat interaction with Max moves 2020-02-02 21:29:55 +04:00
QuiteQuiet
211cefb262
Fix Healing Wish for Gen 8 (#6296)
- Healing Wish is not consumed if the Pokemon switching in
  has full health and no status condition.
- Being statused with full health will consume the Healing Wish.
- It does not trigger on damage after switching in.
- The effect will be consumed if an injured Pokemon is swapped
  into a slot with an active Healing Wish by Ally Switch.
2020-02-01 22:04:21 -08:00
Kris Johnson
4c5640d051
Add February 2020 OMotM and RoA Spotlight (#6323) 2020-02-01 15:10:59 +04:00
The Immortal
d2003354f1 Improve 68e0bcb75 2020-01-28 13:43:12 +04:00
The Immortal
68e0bcb75f Refactor single-use items
This adds a `boosts` property to items that runs in `useItem`.
This allows it to be added to `datasearch` or similar plugins.
The item activation messages are now as accurate as in-game.
The Gem activation message is also consolidated in `useItem`.
2020-01-28 13:21:23 +04:00
urkerab
351089c3d9 Always use getAbility to get a Pokémon's Ability (#6293) 2020-01-18 19:37:01 -07:00
Guangcong Luo
b48733cb7a Rename resolveTarget -> getRandomTarget
Should be much clearer in terms of what it's actually doing.
2020-01-18 15:43:34 -07:00
Guangcong Luo
e6f53a7ad2 Implement smart target tracking
(Stalwart, Propeller Tail, Snipe Shot behavior.)
2020-01-18 15:43:33 -07:00
Waleed Hassan
6714e14fc5 Fix max line length warnings (#6286) 2020-01-14 15:30:50 +04:00
urkerab
b589745a25 Typescript move.target (#6260) 2020-01-11 09:10:10 -05:00
The Immortal
5b97367952 Update Skill Swap & Wandering Spirit 2020-01-09 10:49:41 +04:00
The Immortal
491e0575e0 Random Battle updates 2020-01-07 22:07:09 +04:00
The Immortal
d00bcb9927 Fix validator crash 2020-01-07 00:52:13 +04:00
CK Yong
cadc3fa05d Remove tightening focus message when used by dynamaxed pokemon (#6253)
Check whether the move is a max move. If it isn't, then resolve the choice as usual. Otherwise, do not add the move to the queue, and let the runDynamax mechanic handle move resolution.

Added regression test to check for focus punch message in both dynamaxed and regular use
2020-01-04 06:02:35 -05: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
The Immortal
dde10b714f Fix validation for "Unobtainable" Pokemon
As well as the error message for Past/Future Pokemon.
2020-01-04 05:38:52 +04:00
Guangcong Luo
ca1f8ec820 Fix Howl ally-targeting
Fixes #6247
2020-01-01 11:10:49 +09: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
ZardMX
de7d8168af Fix Neutralizing Gas (#6232) 2019-12-31 16:29:21 +09:00
The Immortal
a0bffce283 Revert "Max happiness in gen 8 is 160"
This reverts commit c7bc102c5a.
2019-12-30 16:44:39 +04:00
Guangcong Luo
edb5404e41 fixup! Fix abilityData/itemData type definitions 2019-12-30 12:23:40 +09:00
Guangcong Luo
1c2119c02e Fix Body Press hint
See https://github.com/smogon/pokemon-showdown/pull/6221#issuecomment-569556599
2019-12-30 11:33:18 +09:00
Guangcong Luo
bf8ed1861d Fix abilityData/itemData type definitions
TODO: move EffectState to global types, and properly type it.
2019-12-30 11:32:12 +09:00
urkerab
c02e711375 Body Press uses SpD boosts under Wonder Room (#6221) 2019-12-30 09:37:04 +09:00
Kris Johnson
36a92b5465 Move Darmanitan-Galar to Ubers (#6236) 2019-12-30 01:13:39 +04:00
Guangcong Luo
1e1c97c255 Add default types/stats for template
A stub Template object now has `['???']` as its `types` array.

This should suppress some crashes, but the underlying problem remains.
2019-12-27 22:09:11 +09:00
Liminalia
afffbeb8b0 Fix RandomPlayerAI wrong teamsize assumption (#6216) 2019-12-27 08:04:47 -05:00
urkerab
7152b42daf Calculate fractional priority once per turn (#6224) 2019-12-27 12:42:34 +09:00
Marty-D
c5b8a0e3c0
Fix Pursuit crash in past gens 2019-12-26 13:51:20 -05:00
The Immortal
f58f196190 Fix National Dex validation 2019-12-25 07:18:42 +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
7f772fba67 Fix Teatime
Fixes #6210
2019-12-24 14:49:47 +09:00
Guangcong Luo
b190202356 Fix Eject Pack crash 2019-12-24 14:30:30 +09:00
The Immortal
1287dd8add Fix "Past" unreleased hidden abilities 2019-12-22 19:59:32 +04:00
The Immortal
c9af9eacce Correct forme mechanics
New research shows that only Zacian-Crowned and Zamazenta-Crowned are unobtainable out-of-battle. So, reverting the validateForme changes and hardcoding it in BH instead of using Obtainable Formes.
2019-12-16 05:37:17 +04:00
Quinton Lee
9a97a49b24 Dex: fix Darmanitan-Galar-Zen's gen (#6187) 2019-12-15 16:11:23 +09:00
urkerab
56a0e37e3b Some Utility Umbrella fixes (#6180)
- Cherrim should revert if given a Utility Umbrella in Sun.
- Castform shouldn't keep transforming if it holds a Utility Umbrella.
- Leaf guard Utility Umbrella check works but is just inconsistent placement.
- Sun/Rain affected recovery moves should heal 50% with Utility Umbrella.
- Solar moves power should halve in sand or hail even with Utility Umbrella.
- Weather Ball should double in power if Magic Room blocks Utility Umbrella.
2019-12-15 04:05:25 +09:00
The Immortal
033d41aff8 Crowned formes change Iron Head to their Behemoth move 2019-12-14 00:07:28 +04:00
The Immortal
fc4c185005 Refactor validateForme 2019-12-12 17:13:45 +04:00
Guangcong Luo
c02ef2f56c Fix Neutralizing Gas faint double-trigger 2019-12-12 18:45:57 +09:00
Guangcong Luo
9abdaa1977 Allow "dynamax" choices when already dynamaxed 2019-12-12 17:09:16 +09:00
Kris Johnson
f1ad861659 Fix Necrozma-Ultra's inheritance (#6176) 2019-12-12 00:13:14 +04:00
Guangcong Luo
65187a9053 Improve Dragon Darts
This is not the best implementation and the animation/messages will be
wrong, but the mechanics should be pretty accurate.

Fixes #6085

Fixes #6086
2019-12-11 18:14:29 +09:00
Marty-D
b3a20bffcb
Fix build 2019-12-10 16:54:55 -05:00
Guangcong Luo
b236500fea Fix Struggle/Dynamax interaction
Struggle is now coded as a locked move, meaning you can't use Z-moves,
mega, or dynamax if you're forced to Struggle.

In addition, Dynamax undisables all moves for its duration.

Fixes #6088
2019-12-11 03:41:38 +09: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
420Blazeitt
143ea606fd Fix type-changing moves & abilities while Dynamaxed (#6080) 2019-12-11 03:10:38 +09:00
Kris Johnson
89002124b3 Change inheritsLearnsetFrom to inheritsFrom and fix Necrozma-Ultra's inheritance (#6168) 2019-12-10 08:03:49 +04:00
The Immortal
cb01db1eab Fix Body Press mechanics
It should be affected by abilities and items that modify attack, not defense.
2019-12-10 01:34:22 +04:00
The Immortal
3572be0be8 Update forme validation for gen 8 2019-12-07 17:05:49 +04:00