Commit Graph

1124 Commits

Author SHA1 Message Date
The Immortal
d79ca8eae5 Don't show EVs warning for level 1 Pokemon 2020-08-12 15:22:37 +04:00
Marty-D
479ea5a72b Validator: Fix passing down level up moves
and finish implementing `canHatch`
2020-08-08 17:17:45 -04:00
Mia
deeed6c789
Remove sim/ and data/'s globals (#7091) 2020-08-07 06:44:15 -07:00
Marty-D
cc8e3723de
Validator: Fix event Pokemon with separate learnsets 2020-08-06 16:14:43 -04:00
Leonard Craft III
9e82f05ebb
Gen 3-4: Fix Camouflage to change to Normal-type (#7130) 2020-08-06 14:54:57 -04:00
Kris Johnson
f96ec4fb05
Add strict types to tiers (#7135) 2020-08-06 00:41:42 -07:00
Mia
fd0f83ff8d
Add a command to show the user's team in battles (#7068) 2020-08-06 00:36:43 -07:00
Guangcong Luo
54027d62bd
Support custom ladders (#6541)
This allows formats to specify a different ladder than their own, for
their rated battles to go on.
2020-08-06 00:28:53 -07:00
The Immortal
ca983630c1 Add Ripen activation for berries 2020-08-03 20:11:47 +04:00
Leonard Craft III
95243cdb00
Don't leak target of two-turn charge moves (#7104) 2020-07-31 17:55:28 -07:00
Annika
05a9f9a1e5
Minor code quality improvements based on LGTM (#7092) 2020-07-30 14:24:37 -07:00
Kris Johnson
70edfaa64c
Add support for more OMs (#7084) 2020-07-30 05:22:21 +04:00
Guangcong Luo
4d09f7acde Rename more instances of Effect to Condition 2020-07-26 11:26:23 -07:00
Kris Johnson
e042c81310
Fix Gigantamaxing (#7054) 2020-07-24 15:40:27 -07:00
Guangcong Luo
2f805c93a2
Remove "Battle" prefix from data exports (#7039)
`BattlePokedex` is now `Pokedex`, `BattleItems` is now `Items`, etc.

I also renamed `Movedex` to `Moves` and `Statuses` to `Conditions`.

`TypeChart` isn't `Types` yet, because unlike the others, it's not
indexed by ID. That should probably be fixed one day.
2020-07-24 12:42:26 -07:00
Kris Johnson
00b88b521d
Handle Gigantamaxing properly (#7001) 2020-07-23 13:27:42 -07:00
The Immortal
beb0ad1288 Fix validation for unbreedable Pokemon
Thanks @nineage.
2020-07-22 01:17:50 +04:00
Kirk Scheibelhut
d3b898ef7c Normal |t:| protocol message in Runner's DualStream 2020-07-21 13:35:53 -07:00
Marty-D
10e4ecdc84 Clean up event priorities 2020-07-21 10:43:12 -04:00
Kirk Scheibelhut
12f9edd729
Add |t:| to support real-time replays (#6998) 2020-07-20 05:26:04 -07:00
The Immortal
e2d268747c Remove Gmax restrictions
Closes #6954
2020-07-18 21:04:09 +04:00
Kirk Scheibelhut
47492210dc Fix battle serialization post 994fc60a
Thanks JXCoder for finding this!
2020-07-17 12:49:59 -07:00
Kris Johnson
b5ff34f862
Add OM Snake Draft formats (#7009) 2020-07-17 16:55:55 +04:00
Jacob McLemore
30e420204a
Fix Fusion Bolt + Fusion Flare interaction when first move fails (#6991) 2020-07-10 16:29:53 -07:00
urkerab
09350a01bf
Centralise the check for a restricted species (#6973) 2020-07-07 15:30:37 -07:00
ACakeWearingAHat
f9699c1be0
Random Doubles Updates (#6962) 2020-07-06 12:48:48 +04:00
urkerab
6fb5b4e90d
Allow custom formats (e.g. for tours) to modify format restrictions (#6958) 2020-07-05 14:32:30 -07:00
Guangcong Luo
8fd572f1f6 Refactor BattleQueue to wrap Array
The old decision to make it extend Array was wrong, as clearly
illustrated by the problems with slice/splice.
2020-07-01 16:37:36 -07:00
Kris Johnson
7010e0286f
Add OMotM and RoA Spotlight for July 2020 (#6936) 2020-07-01 12:59:10 +04:00
urkerab
17e4cb49a4
Adjust fractional priority for latest research (#6928) 2020-06-29 12:09:10 -07:00
The Immortal
393e2b10ff Ice Face isn't affected by Neutralizing Gas 2020-06-29 21:48:26 +04:00
The Immortal
5e7af36442 Fix Illusion interaction with Dynamax 2020-06-28 16:41:02 +04:00
Kris Johnson
28a4a9a91e
Fix STABmons Move Legality (#6918) 2020-06-25 16:12:57 -07:00
Guangcong Luo
ffecbc289b Fix infinite loop in Pumpkaboo validation 2020-06-25 16:05:04 -07:00
Marty-D
1516a56a93
Fix Burning Jealousy and Lash Out 2020-06-22 16:01:59 -04:00
The Immortal
4b4e7a57fc Implement "battle-ready" mechanic
This allows past-gen event Pokemon to be used in VGC. Closes #6881.
2020-06-21 04:23:52 +04:00
Guangcong Luo
dffd9dbff8 Fix stream destroying
`SubprocessStream` wasn't getting properly destroyed.
2020-06-18 21:47:03 -07:00
The Immortal
8817ca88c7 Move unreleasedHidden and maleOnlyHidden to Pokedex 2020-06-18 17:44:44 +04:00
Kris Johnson
4156eef05d
Fix various Isle of Armor DLC moves (#6862) 2020-06-18 00:25:26 -07:00
Kris Johnson
e20178d69d
Isle of Armor: Pokemon (#6839) 2020-06-17 23:37:14 +04:00
Kris Johnson
6b8826df58
Isle of Armor: Moves (#6841) 2020-06-17 22:02:25 +04:00
Enigami
21685eb661
Fix various Stadium issues (#6838) 2020-06-16 14:27:09 -07:00
Kris Johnson
b0675d7ff2
Add National Dex UU (#6836) 2020-06-15 18:22:45 +04:00
Enigami
8825960c9a
Fix event validator for RBY Tradebacks (#6832) 2020-06-14 11:08:58 -07:00
Guangcong Luo
1e5b5ab465 Update Streams API with pushEnd/writeEnd
Previously, ending a read stream was `stream.push(null)`, and ending a
write stream was `stream.end()`. This was often confusing, and so now,
these are consistently `stream.pushEnd()` and `stream.writeEnd()`.

This refactor already found a bug in which `stream.end()` was used
where `stream.push(null)` should have been.

Also in this refactor: By default, `pushError` ends the stream. You can
pass `true` as the second parameter if the error is recoverable (the
stream shouldn't end).
2020-06-10 16:07:24 -07:00
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
The Immortal
f1530288e5 Move Keldeo-R validation to Obtainable rule
Keldeo-R is not a battle forme and is possible to hack without Secret Sword, unlike most other formes. It should be restricted by the rule that prevents hacks and not the rule that validates battle formes. This is mostly relevant for Hackmons.
2019-12-05 22:36:20 +04:00
The Immortal
4266000df4 Update forme validation
- In gen 8, Silvally is able to enter battles in different types if it doesn't have RKS System (i.e. it doesn't require a Memory).
- In gen 8, formes that transform in battle are no longer able to start in that forme (relevant to BH).
2019-12-05 07:29:15 +04:00
The Immortal
c7bc102c5a Max happiness in gen 8 is 160 2019-12-05 03:01:59 +04:00
Guangcong Luo
eb614e627f Fix switch order
Fixes #6135
2019-12-04 13:36:39 +09:00
Guangcong Luo
fe0d044d2b Fix tests to run on Gen 8 instead of Gen 7 2019-12-04 13:36:37 +09:00
HoeenHero
fe6ee1339f Sort battle actions by order instead of priority (#6143)
This fixes the issues with priority moves in gen 8.
2019-12-04 12:56:50 +09:00
Guangcong Luo
9b943fb62f Fix Dynamax stat handling
We now track `baseMaxhp`, the pre-Dynamax max HP. We also have a new
function `getUndynamaxedHP` for use by moves that use it (famously,
Endeavor).

- `baseStoredStats` is unused outside of the mouseover stats display.
  I updated its implementation to reflect this.

- Power Construct doesn't have a defined behavior during Dynamax. I
  ended up implementing an approximation of what it should probably do.

- Endeavor, Pain Split, Super Fang, and Nature's Madness now work on
  undynamaxed HP.

- Moves that deal or heal percentage damage now do it based on
  undynamaxed max HP, other than G-Max Finale.

Fixes #6131

Fixes #6087
2019-12-04 09:25:46 +09:00
The Immortal
a133a5b28b Fix 4b324e536
This reverts the other changes that were related to that commit.
2019-12-02 18:13:08 +04:00
Kris Johnson
953531cb6f Add inheritsLearnsetFrom property (#6133) 2019-12-02 21:15:48 +09:00
Guangcong Luo
d550bb64d8 Support past-gen-only tracking in minPastGen
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.
2019-12-01 20:24:52 +13:00
Guangcong Luo
d5b4b7964e Fix mega evolution priority move interaction 2019-12-01 20:08:25 +13:00
Guangcong Luo
2c95b17e98 Improve debugging support
We have a new command:

`./pokemon-showdown simulate-battle --replay`

which will extract the omniscient log from an input log.

Remember: debugging is as easy as running `simulate-battle` and pasting
an input log. `--replay` will just make the output easier to read.
2019-12-01 19:38:51 +13:00
YaBoiJD
546065a10d Update National Dex Mechanics (#6108)
Pokemon that are holding an Item that enables Mega Evolution, Primal Revision, or the use of a Z-Move cannot Dynamax. A Rayquaza that can Mega Evolve also cannot Dynamax.

Also fixes an alias loop with the national dex format/ruleset.
2019-11-30 14:50:09 -05:00
urkerab
2e85e8afe1 Only in Gen 7 can level-up moves be relearned at any level (#6114) 2019-11-30 04:20:25 +04:00
urkerab
5d97111f34 Initialise the m property on Pokemon earlier (#6097) 2019-11-30 10:16:18 +13:00
HoeenHero
7957e74b75
Dynamic speed updates for Gen 8 (#6100)
In Generation 8, a Pokemon's speed updates dynamically. Meaning that it can move sooner than expected if its speed is modified by something such as tailwind or swift swim. This is different from past generations where the Pokemon's updated speed would only take effect the next turn.
2019-11-28 17:08:58 -05:00
Spandan Punwatkar
0e8ee00acb Add Eternamax forme for Eternatus (#6081) 2019-11-28 12:24:47 -05:00
Spandan Punwatkar
b6b66de896 Update Repo Links (#6102) 2019-11-28 12:47:38 +04:00
Guangcong Luo
c26d6c313b
SIM-PROTOCOL: Document -block 2019-11-28 10:42:54 +13:00
Spandan Punwatkar
599a6e39fc Add some Gen 8 aliases (#6069) 2019-11-27 18:57:17 +13:00
The Immortal
6018270cbc Dex: Identify Galar Darmanitan as gen 8 2019-11-26 23:38:11 +04:00
HoeenHero
b2625ed70c Remove formeLetters
We don't use these at all currently and they are starting
to overlap. As discussed at the start of Gen 8 development
were removing them now.
2019-11-26 13:26:17 -05:00
HoeenHero
44a7fa0946 Make Dynamax checks more dynamic
Specifically we now check the battle.canDynamax method when
notifying a player about their pokemon's eligibility to dynamax.

This enforces the fact that pokemon that are transformed into
dynamax ineligible pokemon cannot dynamax themselves.

As a result of this change the pokemon.canDynamax flag is unnessecary
and has been refactored to a side.canDynamax flag. All pokemon specific
dynamax checks should use the battle.canDynamax method.
2019-11-26 13:05:38 -05:00
Guangcong Luo
5364c63e23 Introduce item.itemUser
`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).
2019-11-25 15:26:36 +13:00
Guangcong Luo
a9e1ec8487 Implement a default zMovePower
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.)
2019-11-25 15:26:36 +13:00
subash955
bee1be1f45 Validator: Ignore Nature restrictions in Gen 8 (#6048) 2019-11-22 12:47:26 +13:00
whales
9e454e3ea6 Mark double iron bash as gen 7 (#6042) 2019-11-21 13:47:08 +04:00
Guangcong Luo
65b17bc669 Properly fix Speed after Dynamaxing 2019-11-21 11:59:12 +13:00
Kris Johnson
8370c488ce Fix the evolution method of new Pokemon (#5982) 2019-11-20 21:44:16 +13:00
Guangcong Luo
18dab87d6b Fix Dynamax move targeting in Doubles 2019-11-20 21:28:51 +13:00
Guangcong Luo
621d55646a Don't change Ability for temporary forme changes
Fixes #6025
2019-11-20 20:23:05 +13:00
Guangcong Luo
b02e91f393 Lose Choice Scarf Speed on first turn of Dynamax
Fixes #6008
2019-11-20 19:53:32 +13:00
Christopher Monsanto
b90475a257 Don't allow Darmanitan-Zen-Galar in previous gens (#6022) 2019-11-20 04:56:00 +04:00
The Immortal
426c013cae Add Gmax events 2019-11-20 03:04:16 +04:00
420Blazeitt
9ed1dec6bf Fix Max Move effects not activating against substitute (#5997) 2019-11-19 17:17:52 +13:00
The Immortal
e7cece5282 Add minSourceGen field to Formats 2019-11-19 03:12:22 +04:00
HoeenHero
d864c798e2 Fix Giantamax 2019-11-18 07:44:29 -05:00
The Immortal
7a3cd9d078 Restrict SwSh metagames to Galar learnsets 2019-11-18 00:22:36 +04:00
Guangcong Luo
6de97db219 TypeScript event handler types 2019-11-18 07:02:32 +13:00
Guangcong Luo
2601450517 Fix Ice Face 2019-11-18 06:23:24 +13:00
Russell Jones
b2e9336c32 Fix Gmax powers (#5985) 2019-11-17 20:14:10 +04:00
HoeenHero
b65826b94e Gigantamax support 2019-11-17 08:00:22 -05:00
Guangcong Luo
4fc49bc7f9 Fix Body Press
Fixes #5975

Fixes #5979
2019-11-17 18:47:16 +13:00
Guangcong Luo
2b55bde8af Output Dynamax to inputlogs 2019-11-17 13:10:43 +13:00
asgdf
736f357dab Default to gen 8 mod for formats (#5969) 2019-11-16 23:25:37 +04:00
The Immortal
0000c69c44 Fix illegal moves in Hackmons Cup
And re-enable the format
2019-11-16 23:07:08 +04:00
Guangcong Luo
0bb2e58efd Fix Dynamax move base power
Dynamax moves now have the correct base power, and now correctly only
deal 25% usual damage against Protect.
2019-11-17 06:32:17 +13: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
HoeenHero
a9f0f752d3 Fix choice lock - dynamax interaction 2019-11-16 08:44:31 -05:00
Guangcong Luo
01f12b3a54 Fix Gigantamax formes being available in past gens
A WIP Gigantamax implementation broke this.

Fixes #5961
2019-11-16 20:00:54 +13:00
HoeenHero
62218ef416 Dynamax is only useable in gen 8 2019-11-15 21:44:44 -05:00
HoeenHero
9ecbcabee9
Dynamaxing (#5946) 2019-11-15 21:33:10 -05:00
Guangcong Luo
10062ece4f Fix Koffing/Weezing Gen 7 Abilities
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.
2019-11-16 14:39:14 +13:00
Kirk Scheibelhut
a4698a52cb Reenable ExhaustiveRunner test with workaround 2019-11-15 14:45:38 -08: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
Kris Johnson
a19ad51a20 Fix one part of the build (#5945) 2019-11-16 00:08:28 +13:00
HoeenHero
5144fc32d7 Add Gen 8 Abilities 2019-11-15 22:01:54 +13:00
Kris Johnson
46ad0bccd7 Add Gen 8 Pokemon 2019-11-15 22:01:36 +13:00
Guangcong Luo
7a90fa7622 Fix DW and baby-only move compatibility checking
PS already tracks which evolution level an egg move or event pokemon
learns a move from, but apparently this was not tracked for DW moves.

This fixes a compatibility interaction between DW Marill and Azurill
moves.
2019-11-11 04:41:51 +13:00
Guangcong Luo
1ac1f2be5e Improve accidental level 50 Pokemon check 2019-11-11 02:31:47 +13:00
Leonard Craft III
592f0e973a Add warning for L50 Pokemon in formats allowing L100 (#5914) 2019-11-10 23:41:13 +10:30
Guangcong Luo
2ebe46bac5 Fix crash in tradeback validation 2019-11-09 05:50:52 +10:30
HoeenHero
4ced391d6b SSB: Apply various updates 2019-10-30 10:39:20 -04:00
WeWuzNidokangz
f7d66afe8a Fix !Obtainable Formes Battle Bond Greninja validation (#5913) 2019-10-29 03:31:21 +10:30
urkerab
bae434e606 Add a single event for a move's own immunity to a specific target (#5904) 2019-10-24 11:00:28 +10:30
Guangcong Luo
52df674a7f Properly fix Nidoqueen egg move crash
It turns out Nidorina can't breed, either.
2019-10-23 14:08:19 +10:30
Guangcong Luo
78e4d3945b Fix Nidoqueen egg move validation 2019-10-23 13:58:50 +10:30
Waleed Hassan
c88dfba1d1 Server: Reorganize TypeScript globals (#5903) 2019-10-21 14:39:59 +10:30
Guangcong Luo
77f7cb9fb0 Correctly validate Ash-Greninja 2019-10-18 14:37:23 +10:30
urkerab
00d6e9d741 Fix activation of Defiant and Competitive when boosts are maxed (#5895) 2019-10-18 13:32:07 +10:30
urkerab
5b9d0c8db6 Centralise invulnerability checks for No Guard and Lock-On (#5894) 2019-10-17 22:32:44 -04:00
urkerab
3bfec7bf2f Rename TryImmunity to Invulnerability (#5877)
It's a check for semi-invulnerability rather than any sort of immunity.
2019-10-16 20:12:12 -04:00
Guangcong Luo
6a32df9a81 Fix egg validation error in Gen 3 Weezing
This happened because the father checker was simplistic enough
that it didn't think to check Duskull for Pain Split, since
Dusclops learns it in future gens.
2019-10-16 12:34:00 +10:30
Guangcong Luo
92c0011b93 Fix HP Fighting Mega Latias validation 2019-10-15 21:00:40 +10:30
Konrad Borowski
3732641ea8 Mark items as items (not moves) during set validation
Fixes a bug which made Fightinium Z + Detect not considered to
be banned in 1v1 format.
2019-10-13 18:09:12 +02:00
urkerab
61faff236a Transform should copy the target's current weight (#5878) 2019-10-13 05:37:10 +11:00
Guangcong Luo
d6752954ef Further improve validator
- 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`.)
2019-10-10 06:33:33 +11:00
Guangcong Luo
a750cd1d7a Fix crash when validating LC egg moves
I put in this `throw` because I thought this condition was impossible,
but it turns out it's possible! Good to know.
2019-10-09 06:50:45 -04:00
Guangcong Luo
5f1f230bde Fix forme validation in Hackmons
In formats without Obtainable Formes, we no longer validate bans as
if they were enabled.
2019-10-09 06:50:44 -04:00
Guangcong Luo
2adc80efe4
Improve egg validator (#5854)
Previously, we split gen 2-5 egg move validation into two phases,
`checkLearnset` where we searched for a valid father, and
`reconcileLearnset` where we made sure the father could learn the move
combination.

Egg move validation has now been completely moved out of these
functions and into `validateSource`, which calls `findEggMoveFathers`.

The new algorithm no longer requires `C` moves to be hardcoded into
`learnsets.js`, now doing a more thorough check validation for the
father's move combination. This should be slower than before, but
net performance should be massively improved due to two other
optimizations in this refactor:

- We no longer do any father-searching if the moveset can be obtained
  any other way - in particular, this means no more father validation
  in gen 6+ where all egg move combinations are legal anyway.

- We only check fully-evolved pokemon as fathers (because anything a
  prevo can learn, its evos can learn, too - yes, we remember to make
  exceptions for Salazzle, Combee, and future-gen evos)

In addition, `/learn` should now provide significantly better
information for egg move breeding, since it uses a more thorough check
instead of the validator's short-circuiting the moment it finds a valid
father.

This also improves some baby-only move validation, specifically fixing
the issue with Seismic Toss Charm Chansey.
2019-10-09 00:59:24 +11:00
urkerab
e717abe802 Require normal targets to be adjacent in Triples battles (#5852) 2019-10-09 00:56:51 +11: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
Kirk Scheibelhut
691cf76de7 Fix EBC for external staleness via consumed Leppa 2019-10-05 15:41:18 -07:00
Guangcong Luo
2a93e9e05e Fix forme validator 2019-10-06 08:00:02 +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
555bd9cdb8 Fix mega evolution ability validation 2019-10-06 07:34:51 +11:00
Guangcong Luo
70b1de52ec Fix egg move validator
`limitedEgg` shouldn't exist, but this is a stopgap for the new way
it works.
2019-10-06 07:17:18 +11:00
Guangcong Luo
3cd04c349e Fix missed conversions of validate -> obtainable 2019-10-06 04:32:23 +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
Waleed Hassan
da4b887054 Rename Room#id -> Room#roomid, User#userid -> User#id (#5826)
These should make it clearer that userids are IDs but roomids aren't.
2019-10-03 18:57:38 +10:00
urkerab
948257cce7 Change weight units to hectograms (#5765) 2019-10-03 14:00:16 +10:00
HoeenHero
3445da848a Move support for overwritting custom terrains to client.
This didnt work anymore anyways since setTerrain was moved from battle to field.
2019-09-27 22:53:49 -04:00
HoeenHero
7f7c2d9a95
Super Staff Bros Brawl Update (#5764) 2019-09-22 14:47:33 -04:00
Guangcong Luo
23a4b6ed66 Correctly ban illegal pokemon
Also support individual nonstandard bans in rule tables.

Fixes #5770
2019-09-11 20:49:29 -07:00
Guangcong Luo
c03499e037 Mark Pikachu/Eevee-Starter as Gen 7 2019-09-11 20:49:29 -07:00
Nol
a60dd6fb11 Fix typo (#5767) 2019-09-09 00:09:06 -05:00
Kirk Scheibelhut
4f70c022d6 Correct EBC switch condition to match the spec
"at least one team does not have the option of switching to a
non-stale Pokémon"
2019-09-01 16:17:36 -07:00
The Immortal
26dfe8fd9e Revamp Random Battle
- New ability ratings
- Improve move pools
- Allow non-status moves to be re-rolled if rejected (this fixes all undesired move set combinations)
- Update move & ability rejections
- New item possibilities
2019-09-01 19:40:53 +04:00
TheJetOU
20ced3f073 Fix linter warning in TeamValidator (#5700) 2019-08-13 17:25:54 +02:00
Kirk Scheibelhut
9ab3f5a668
Make /hotpatch fail if git history hasn't changed (#5688)
/forcehotpatch can be used to perform the hotpatch regardless.
2019-08-12 10:23:24 +02:00
Marty-D
7ed137dffd
Validator: Fix HA Raikou/Entei/Suicune legality in pentagon formats 2019-08-11 16:11:26 -04: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