Commit Graph

1096 Commits

Author SHA1 Message Date
Guangcong Luo
5f8c36c616 Ban Gen 1 Japan-only event moves
Fixes #7516
2020-10-26 15:30:47 +00:00
Annika
099346ee1e Tools: Modernize modlog entries for blacklists 2020-10-25 16:13:46 -07:00
The Immortal
381c8190c6 Fix Dragon Ascent Rayquaza validation 2020-10-24 04:58:05 +04:00
Leonard Craft III
4e6ff7e72c
Validator: Allow Hidden Ability Entei/Raikou/Suicune in Gen 8 natively (#7563) 2020-10-23 15:28:12 +04:00
Leonard Craft
db2a55a1bb Clarify Neutralizing Gas + Imposter test 2020-10-22 11:53:11 -05:00
Leonard Craft
4e3c8bd3cc Consolidate Neutralizing Gas tests; add Gluttony/Slow Start NGas tests 2020-10-22 11:49:11 -05:00
Guangcong Luo
d6eeb197c1 Improve Chat.toDurationString
- Default precision is now 3.

  (Instead of "3 months 25 days 17 hours 46 minutes 40 seconds", it'll
	say "3 months 25 days 17 hours". You can still set the precision to
	`Infinity` if you actually prefer that.)

- Now displays "forever" for Infinity or overflow durations

- No longer skips blank precision levels

  (Shows "3 hours 0 minutes 10 seconds" instead of
	"3 hours  10 seconds")
2020-10-21 13:05:08 +01:00
Leonard Craft
993a5cc645 Unskip passing validator test 2020-10-20 21:36:28 -05:00
Leonard Craft
07a721dd96 Unskip passing move self-target test 2020-10-19 19:57:37 -05:00
Guangcong Luo
9d87616176
Add more style linting rules (#7537)
* Lint arrow-body-style

* Lint prefer-object-spread

Object spread is faster _and_ more readable.

This also fixes a few unnecessary object clones.

* Enable no-parameter-properties

This isn't currently used, but this makes clear that it shouldn't be.

* Refactor more Promises to async/await

* Remove unnecessary code from getDataMoveHTML etc

* Lint prefer-string-starts-ends-with

* Stop using no-undef

According to the typescript-eslint FAQ, this is redundant with
TypeScript, and they're not wrong. This will save us from needing to
specify globals in two different places which will be nice.
2020-10-19 02:42:28 -07:00
Ben Davies
6f26265ff9 Tests: simplify Dashycode transcodeWithSets helper 2020-10-19 05:15:02 -03:00
Leonard Craft III
1081a4423f
Add various mechanics tests (#7506) 2020-10-16 21:07:05 -07:00
The Immortal
7638f8238a Fix Present healing vs Substitute 2020-10-15 18:46:58 +04:00
Guangcong Luo
a65faf263f
Stop using assert.strict.strictEqual (#7515)
It turns out that when I switched us from `assert` to `assert.strict`,
I didn't actually update any existing tests or tell anyone:

0df0d234f2

So apparently everyone else just kept on using `strictEqual`.

This will be a PR and also throw an error if people continue trying to
use it, which should make it much clearer what PS policy is on this.

A lot of the problem may be that TypeScript marks assert.strict.equal
as deprecated when it's not. This was fixed 4 days ago:

https://github.com/DefinitelyTyped/DefinitelyTyped/pull/48452

But this probably hasn't made it to a thing yet. Until then, you'll
have to deal with TS marking your tests as deprecated, but it shouldn't
be too long.

Accidentally using `assert` instead of `assert.strict` should now show
an error. This protects against the probably much worse mistake of
accidentally using `assert.equal` rather than `assert.strict.equal`.

`assert.ok` is also deprecated now.
2020-10-14 01:19:03 -07:00
Guangcong Luo
67a4e9f185 Add validator for Pokestar event moves
See #7412
2020-10-13 18:01:32 -07:00
Kris Johnson
510ab4ecb3
Fix typo 2020-10-13 16:55:31 -06:00
Guangcong Luo
7fc498ff88 Add validator for evoItem
See also #7412
2020-10-13 04:40:38 -07:00
Kris Johnson
d9b3a510ad
TextFormatter: Support replacing \n without trusted (#7507) 2020-10-11 13:38:34 -07:00
Guangcong Luo
e40ab96db7 Update Mocha dependency version 2020-10-09 22:33:17 -07:00
Kris Johnson
b107236dc5
Repeats: Refactor storing and deleting repeats, let people repeat room FAQs (#7488) 2020-10-07 23:42:30 -07:00
Leonard Craft III
2ed8a97ff8
Add skipped failing event validator tests (#7472) 2020-10-06 16:06:05 -07:00
Mia
4279d1f3bc
Update attributions in various locations (#7354) 2020-10-06 15:55:26 -07:00
Annika
216e4a7354
Add a plugin to repeat phrases in chatrooms (#7338) 2020-10-05 14:25:18 -07:00
Annika
0877f0ae1e
Modlog: Fix entries with an IP address and no user (#7446) 2020-09-30 17:55:41 -07:00
The Immortal
ca3a106815 Learnsets: Sort V before S 2020-10-01 04:26:23 +04:00
Annika
b3a5f9e59f
Moderation: Refactor room promotions to a function (#7426) 2020-09-28 15:49:26 -07:00
Annika
f1b4e3d43a
Modlog: Refactor to use ModlogEntry objects (#7403) 2020-09-28 11:06:30 -07:00
The Immortal
2b0c77939f Correct Weakness Policy mechanics
And added relevant Burning Jealousy tests.
2020-09-26 00:56:41 +04:00
Annika
1e20f6a96f
Trivia: Add leaderboard management commands (#7402) 2020-09-20 16:33:03 -07:00
Annika
6d8d0bd93a
Trivia: Use Chat.ErrorMessage more (#7384) 2020-09-18 16:19:26 -07:00
Annika
422649dca7
Trivia: Add a new game called Mastermind (#7368) 2020-09-14 16:03:50 -07:00
Annika
83e8262d12
Users: Fix bug with IP handling (#7305) 2020-09-05 08:18:42 -07:00
Kris Johnson
8656d633ac
Format volatiles consistently (#7314) 2020-09-05 08:12:24 -07:00
Annika
c9fa3fc389
Refactor User#prevNames and User#ips to arrays (#7267) 2020-08-29 10:27:03 -07:00
Guangcong Luo
ba4998350a Fix more bugs in /hiderank 2020-08-22 16:03:10 -07:00
Annika
05065dbdb8
IPTools: Support wildcards in string ranges (#7223) 2020-08-18 13:37:58 -07:00
Mia
d8ecdb5f83
Help: Only write state when relevant to the room (#7207) 2020-08-18 13:06:52 -07:00
Kirk Scheibelhut
39c14e0868 Remove EBC staleness from abilities upon switching 2020-08-17 12:59:10 -07:00
Leonard Craft III
53dd591819
Skip failing modlog test (#7197) 2020-08-11 05:58:59 -07:00
Annika
ce8a1dd975
IPTools: Remove '-nohost' suffix and make minor improvements (#7108) 2020-08-07 14:47:18 -07:00
Mia
deeed6c789
Remove sim/ and data/'s globals (#7091) 2020-08-07 06:44:15 -07:00
Annika
f563252418
Modlog: Fix bugs and support hotpatching (#7163) 2020-08-06 22:05:13 -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
Annika
f34ffa9e74
Refactor Modlog into one file (#7127) 2020-08-06 00:39:37 -07:00
Mia
fbe5d90dd0
Youtube: Add tests (#7081) 2020-08-06 00:34:18 -07:00
Mia
647d5af76f
Add a filter for auto-answering questions in the Help room (#7100) 2020-08-05 23:44:46 -07:00
Annika
577b858994
Tests: Allow requiring Config at the top level (#7109)
This solves issues like https://github.com/smogon/pokemon-showdown/pull/7100#discussion_r463922425 and makes it easier to test chat plugins.
2020-08-02 22:10:22 -07:00
Annika
cd85cd7a9d
Hosts & IPTools: Refactor to remove hardcoded ranges (#7078) 2020-07-29 23:04:50 -07:00
Guangcong Luo
fe2eb27860
Refactor ip and modchat permissions (#7076)
- `ip` and `ipself` are now separate permissions. This means that `ip`
  is now a generalized permission for viewing IPs (no more need to use
  `globalban`, since `ipself` now controls the ability to see your own
  IP address)

- `alts` and `altsself` are now also separate (all users used to be
  able to `altsself`).

- `modchat`, `modchatall`, and `manageroom` are now just one `modchat`
  permission whose jurisdiction controls how high you can set modchat.
2020-07-29 00:38:52 -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
Guangcong Luo
4628575b17 Add regression test for Aerial Ace Kubfu in LC 2020-07-23 12:48:08 -07:00
Kirk Scheibelhut
d3b898ef7c Normal |t:| protocol message in Runner's DualStream 2020-07-21 13:35:53 -07:00
Guangcong Luo
eb78b5981e Remove timestamps in state tests 2020-07-21 13:08:16 -07:00
Kris Johnson
77e4a8ad6f
Add type and category support for <psicon> (#6983) 2020-07-18 18:05:19 -07:00
The Immortal
e2d268747c Remove Gmax restrictions
Closes #6954
2020-07-18 21:04:09 +04:00
Jacob McLemore
30e420204a
Fix Fusion Bolt + Fusion Flare interaction when first move fails (#6991) 2020-07-10 16:29:53 -07:00
Kris Johnson
127a04b19e
Make improvements to the UNO game (#6980) 2020-07-08 15:12:14 -07:00
Kirk Scheibelhut
eea2196280
Server side changes to support persistent user settings and privacy changes (#6947)
NOTE: This is changes the semantics of `hidenext`/`ionext` from
applying to the next created *battle* to applying to the next
created *search*/*challenge*.
2020-07-06 21:18:38 -07:00
Guangcong Luo
d7ba455e2b Update permissions
Permissions have gotten out-of-date, so this commit syncs them.
Default permissions are now matched with Main, in particular including
the new & rank as admin (removing the old Leader rank and ~ symbol).

Relevant changes:
- Admin (~) and Leader (&) have been merged into Admin (&)
- The 'ban' permission was split into 'globalban' and 'ban'
- The 'broadcast' permission was renamed 'show' (going forward,
  "broadcast" should only refer to the big red/blue/green
  announcement bars.)
- Bots no longer have global moderation abilities, making it
  easier to give untrustworthy bots the "bot" rank.
2020-07-03 17:32:49 -04:00
Guangcong Luo
46c9afa2f3
"Remove" the global room (#6885)
I couldn't completely remove the global room in one commit, but this
solves basically every problem with it by making it no longer a `Room`.

In particular, this means:

- It's no longer of type `Room`
- It's no longer in the `Rooms.rooms` table
- Its class name is now `GlobalRoomState` rather than `GlobalRoom`
- It no longer tracks its own user list (online user count is now
  provided by `Users.onlineCount`)
- It's no longer a socket channel (there's new syntax for "send this
  message to every user")
2020-07-02 11:31:34 -07:00
The Immortal
6ef15d4a9b Fix Adrenaline Orb 2020-06-19 16:52:56 +04:00
Guangcong Luo
51344c6d3f Fix BattleStream test 2020-06-18 22:40:01 -07:00
Guangcong Luo
dffd9dbff8 Fix stream destroying
`SubprocessStream` wasn't getting properly destroyed.
2020-06-18 21:47:03 -07:00
Kris Johnson
e20178d69d
Isle of Armor: Pokemon (#6839) 2020-06-17 23:37:14 +04:00
Guangcong Luo
e0f97dcf6b Replace Chat.uncache* with Utils.clearRequireCache
This replaces the old approach with a new "clear everything except a
whitelist" approach, which should overall involve much less code and
lead to fewer bugs of the "the path changed for a module and I forgot
to update the uncache paths" variety.

I considered a lot of other approaches, but they seem to have more
flaws without any advantages in exchange for them. (We moved away
from `uncacheTree` because it only tracks the first require: there's
no way to get a full list of dependents for a module, only its first
dependent.)
2020-06-12 22:02:32 -07:00
Mia
6839a1f4db
Add a library for utility functions (#6817) 2020-06-09 22:06:43 -07:00
Mia
15fed24b40
Refactor auth and room.settings (#6777)
This implements two big changes:

- All settings shared between `room.chatRoomData` and `room` have been
  merged into `room.settings` (so, for instance, `room.slowchat` is now
  only `room.settings.slowchat`).

  This makes it so we never have to worry about them getting "out of
  sync".

  - Checking to see if a room is persistent is now `if (room.persist)`
    instead of `if (room.chatRoomData)`

  - `Rooms.global.writeChatRoomData()` is now rarely called directly;
    there's a new `room.saveSettings()` which will handle it for you.

  - All properties of `room.settings` are now optional (except
    `title`).

- There's a new file `user-groups.ts` which handles authority.

  - `room.auth` and `Users.globalAuth` are now
    `Auth extends Map<ID, GroupSymbol>` objects.

  - `room.auth` is now always defined, removing the need for
    `room.auth?.[userid]` workarounds.

  - A lot of code relating to usergroups and permission checks have
    been refactored.

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
2020-06-09 08:22:25 -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
Guangcong Luo
36941fe898 Add Learnsets validator
I didn't have time to fix all the errors the validator found, but I
fixed half of them.
2020-06-02 00:38:56 -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
18fbcbc914
Typescript Trivia (#6768) 2020-05-29 23:53:52 -07:00
urkerab
fc6e4b82ae
Disguise breaking prevents critical hits (#6766) 2020-05-29 18:57:39 -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
7dd6e8bd64
Fix doubled effectiveness for victims of Tar Shot (#6566) 2020-05-29 01:27:53 -07:00
Kirk Scheibelhut
adfc77246b EBC: Entrainment/Skill Swap inflicts staleness 2020-05-28 12:05:16 -07:00
The Immortal
df8b99d244 Fix Kyurem learnset validation 2020-05-28 00:41:31 +04:00
HoeenHero
148570ddb5 Fix Emergency Exit Bug
Fixes 0450e8cb65
2020-05-27 10:11:04 -04:00
Leonard Craft III
27efca0f32
Add EE tests for new bugged behavior (#6752) 2020-05-27 10:00:16 -04:00
fart
0450e8cb65
Fix Life Orb + Emergency Exit interaction (#6738) 2020-05-25 14:14:59 -07:00
Leonard Craft III
c249a8f0be
Add various mechanics tests (#6714) 2020-05-18 12:19:18 -07:00
Leonard Craft III
576e0c7d0f
Add forme-exclusive move validator tests (#6709) 2020-05-16 18:27:50 -07:00
Leonard Craft III
4e4261267c
Add a few G-Max Chi Strike tests (#6631) 2020-05-14 11:34:09 -07:00
Marty-D
c8c048a645 Update Curse targeting 2020-05-14 13:23:37 -04: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
9f5d1bc681
Fix Dynamax Clause validation (#6674) 2020-05-10 14:42:53 -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
291f891309 Fix mod loader test 2020-05-08 07:25:09 -07:00
Guangcong Luo
c76ea9a497 More thoroughly remove old sockets tests
I don't want to remove them completely because they can still be used
for inspiration for writing new tests, but to me, "skipped test"
implies "bug that needs to be fixed", and these aren't bugs so much as
outright outdated code.

Closes #6665
2020-05-08 07:11:05 -07:00
Leonard Craft III
1dbb1a280b
Unskip passing tests (#6662) 2020-05-07 16:53:10 -07:00
Marty-D
339f516a2b Gen II: Fix residual damage when opponent is KOed 2020-05-06 15:41:18 -04:00
Guangcong Luo
5aa5f53089 Fix Shields Down for cosmetic formes 2020-05-01 23:30:04 -07:00
Guangcong Luo
6d5ea45adf Fix misc bugs preventing build 2020-05-01 12:48:54 -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
Kirk Scheibelhut
b05e1941e2 Ensure explosion halves defense in Gen 3&4 2020-05-01 11:03:54 -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
9209201f1c Improve pokedex changesFrom/battleOnly validation 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
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
urkerab
8476a24318
Shell Trap should not power up if hit by a Z- or Max move (#6622) 2020-04-27 08:04:49 -07:00
Guangcong Luo
5d57aaaedf Fix Imprison test
I'm pretty sure the old Imprison test was straight-up wrong, and based
on the old bugged behavior.
2020-04-26 18:21:02 -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
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
urkerab
554cb570a7
Dancer should not activate if the holder fainted (#6613) 2020-04-25 09:55:13 -04:00
Guangcong Luo
f6f4467265 Turn on prefer-const for .js files
Not having prefer-const on the JS side makes JS -> TS refactors really
unreadable. This commit just auto-fixes it so we're using
`prefer-const` everywhere.
2020-04-23 11:37:47 -07:00
Kris Johnson
28bf388b98
Typescript data (#6553) 2020-04-23 09:16:09 -07:00
Luc Moussiegt
be4ff58260
Fix Sky Drop Wonder Guard interaction (#6593) 2020-04-20 12:14:37 -04:00
Marty-D
d9d345d8df Correct power modifier priorities
Thanks @dawoblefet!
2020-04-18 20:33:13 -04:00
Luc Moussiegt
4a749aff3e
Fix Technician interaction with Battery/Auras/PowerSpot (#6587) 2020-04-18 12:46:19 -04:00
Guangcong Luo
776ccf9796
Refactor Sockets to ProcessManager+TypeScript (#6584) 2020-04-17 04:05:45 -07:00
Guangcong Luo
80634c6918 Fix Dazzling
I don't like using Bulbapedia as a source, but our researchers are all
asleep and TI said this was high-priority.
2020-04-16 03:12:40 -07:00
Leonard Craft III
6792b82a21
Add Teatime tests (#6582) 2020-04-15 21:27:45 -07:00
Leonard Craft III
2a07102281
Add G-Max move validator illegality test (#6580) 2020-04-15 21:27:16 -07:00
Kirk Scheibelhut
79ea998a93 Skip failing dazzling test 2020-04-15 16:17:37 -07:00
Kirk Scheibelhut
ea601caf6c Add tests for Dex edgecases 2020-04-15 16:15:13 -07:00
The Immortal
01aac3b491 Add Dazzling tests 2020-04-15 22:22:56 +04:00
Leonard Craft III
3842e03d60
Fix residual order for G-Max Volcalith / Wildfire (#6565) 2020-04-15 12:20:27 -04: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
urkerab
19be262793
Fix Pastel Veil mechanics (#6571)
Makes Pastel Veil pass the tests from #6568
2020-04-13 15:18:14 -07:00
urkerab
9c8c1e1468
Fix Fell Stinger after redirection (#6572) 2020-04-13 14:20:37 -07:00
Leonard Craft III
be3a396bf7
Add Pastel Veil, Emergency Exit, and Fell Stinger tests (#6568) 2020-04-12 23:06:36 -07:00
Kirk Scheibelhut
ca69c8e6e3
Fix Minior-Meteor forme not being allowed in Gen 7 (#6563) 2020-04-12 16:25:13 +04:00
Kirk Scheibelhut
2b8c03fe04 Increase test timeout in test/sim/misc/state.js
This is already marked as '(slow)' so could be timeout(0), but this
shouldn't be *that* slow, so increasing it from 2000 to 5000 seems
sufficient.
2020-04-11 12:04:17 -07:00
Guangcong Luo
091f764681 Fix rule inheritance 2020-04-08 13:25:11 -07:00
Guangcong Luo
40783b7dc6 Fix spread moves vs Unaware 2020-04-07 10:56:20 -07:00
Guangcong Luo
ff0b80f297 Fix triples shift priority 2020-04-07 10:56:20 -07:00
Guangcong Luo
33fa9d56ef Fix mega evolving into self
A hacked-in Megazard X can mega evolve into Megazard Y, but not into
Megazard X.
2020-04-07 10:56:19 -07:00
Marty-D
ff3ca6783a Fix Imposter activation 2020-04-05 14:56:42 -04:00
Leonard Craft III
d8cf01bee1
Add Primal weather phazing test (#6525) 2020-04-05 08:50:17 +04:00
Kirk Scheibelhut
d17a48cc47 Fix Dex#getForme for Flabebe 2020-04-04 21:36:58 -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
urkerab
76a78f46b3
Add test for priority of shift action in Triples battles (#6509) 2020-04-01 06:17:21 -07:00
Leonard Craft III
dbf7d33e50
Add test for Unaware & spread moves (#6506) 2020-04-01 00:46:45 -07:00
Marty-D
2aae13ff62 Fix Round and Pledge move interaction with Z- and Max Moves 2020-03-31 16:33:42 -04: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
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
Leonard Craft III
296c308e62
Add test for when Dynamax should revert (#6502) 2020-03-30 01:03:37 -07:00
Marty-D
7a09037213 Validator: Fix Gen 2 event move tradebacks 2020-03-26 13:54:14 -04:00
The Immortal
81891546b9 Rename Missingno. to MissingNo. 2020-03-26 18:37:35 +04:00
Kris Johnson
994fc60aed
Rename Template to Species (#6478) 2020-03-25 23:29:27 -07:00
Leonard Craft III
380b4ac1cd
Add tests for Pledge moves modified by Z/Dynamax (#6489) 2020-03-25 19:14:48 -07:00
Guangcong Luo
2534753325 Fix Hidden Ability validation 2020-03-24 23:55:54 -07:00
Guangcong Luo
f562a18a26 Update tests for new targeting syntax 2020-03-24 02:56:39 -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
The Immortal
2ad5525e8b Fix Parting Shot mechanics 2020-03-20 21:23:33 +04:00
The Immortal
a0c2d72fac Add another Emergency Exit test 2020-03-20 00:36:40 +04:00
Leonard Craft III
bce32d4613
Add Mirror Armor Parting Shot test (#6452) 2020-03-17 20:38:31 -07:00
Leonard Craft III
5e320c337c
Add additional Eject Pack tests (#6453) 2020-03-17 20:38:19 -07:00
Peach
7761c69763
Ignore existing chatrooms in tests (#6446) 2020-03-11 10:46:45 -07:00
Leonard Craft III
0dabac28ef
Fix G-Max Volcalith and add tests for G-Max Wildfire/Volcalith (#6442)
* Fix G-Max Volcalith mechanics

* Add tests for G-Max Wildfire/Volcalith
2020-03-11 12:53:49 +04:00
The Immortal
5211e36778 Add another Emergency Exit test 2020-03-11 10:00:49 +04: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
Guangcong Luo
ac50dc2a48 Fix Dynamax Liquid Voice 2020-03-07 14:57:54 -08:00
Guangcong Luo
185966f44d Fix G-Max Steelsurge damage against Eiscue 2020-03-07 14:52:45 -08:00
asgdf
cac033ab86
Improve handling of mobile IPs with permalocks (#6338) 2020-03-07 11:50:08 -08: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
8d140b4bca Fix Gmax validation
(Gmax Pokémon can't be from older gens.)
2020-03-06 10:41:33 -08:00
Guangcong Luo
b21c9047e2
Migrate to typescript-eslint (#6342) 2020-03-05 08:33:06 -08:00
Guangcong Luo
1a447f7487 Add tests for Max Geyser Sand Spit 2020-02-23 22:10:49 -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
The Immortal
cecbf396cd Revert "Fix Moxie and Beast Boost in doubles"
This reverts commit d7af602017.
2020-02-23 13:46:18 +04:00
The Immortal
d7af602017 Fix Moxie and Beast Boost in doubles 2020-02-22 19:30:44 +04:00
The Immortal
563323f4c1 Fix Lum Berry activation 2020-02-22 05:39:37 +04:00
urkerab
98edf3e025
Refactor Dragon Darts (#6378) 2020-02-21 06:36:41 -08:00
The Immortal
79af87374a Fix Wandering Spirit 2020-02-21 18:18:51 +04:00
Waleed Hassan
34e215c7a6
Support renaming rooms (#6295) 2020-02-21 00:47:07 -08:00
Guangcong Luo
f89f44f209 Max Guard is disabled by Assault Vest 2020-02-21 00:46:28 -08:00
Alexander B
88fa845350 Add Gen 8 unit tests
Closes #5952

(Bugs in PR fixed by Zarel)
2020-02-21 00:46:28 -08:00
The Immortal
bf2665ca1d Add tests for Lum Berry 2020-02-21 05:27:35 +04:00
Guangcong Luo
1d09dd1174 Fix Dragon Darts bugs
- should not stop after one faint
- should not show miss message for first miss
2020-02-20 15:58:36 -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
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
6778bc585d Fix Yawn Safeguard 2020-02-18 13:18:39 -08:00
Guangcong Luo
206b5c2b26 Fix multihit moves vs Emergency Exit 2020-02-18 01:13:10 -08:00
Guangcong Luo
518d4b796a Fix Rapid Spin not activating against Sub 2020-02-17 14:10:29 -08:00
The Immortal
a05bd59720 Update Rapid Spin test 2020-02-17 16:41:59 +04:00
The Immortal
45e4e64f5f Add another Emergency Exit test 2020-02-16 04:45:57 +04:00
Guangcong Luo
eee403fbea Properly fix Pledge moves
I had this fixed and forgot to commit + push it. :(
2020-02-15 15:40:59 -08:00
Guangcong Luo
1fa9e141f6 Fix Pledge moves 2020-02-15 13:38:58 -08:00
Guangcong Luo
09e563f9fc Fix some moves triggering abilities twice 2020-02-15 08:54:14 -08:00
The Immortal
62f3c0f4fd Change Aftermath test 2020-02-15 18:26:49 +04:00
The Immortal
1b20253547 Add Rocky Helmet test 2020-02-15 15:37:19 +04:00
The Immortal
a6100c5978 Add Rapid Spin tests 2020-02-15 02:20:54 +04:00
Russell Jones
4615693685
Fix Gyro Ball/Electro Ball divide-by-0 edge cases (#5805) 2020-02-14 10:39:54 -08:00
Guangcong Luo
1914a37aba Fix Eject Pack to activate for self-boosting 2020-02-11 11:16:46 -08:00
Guangcong Luo
ee4435716f Fix crash in Knock Off + Substitute
(This also fixes a bug where hitting Substitute procced DamagingHit
events.)
2020-02-10 15:37:34 -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
Waleed Hassan
f7e024e009
Allow safer and exact type retrieval of Room#game (#6315)
By adding a `getGame` function of type:

```
// null is returned if the gameids don't match
// or the game doesn't exist
getGame<T extends RoomGame>(constructor: new (...args: any[]) => T) => T | null
```
(Credits @urkerab and @whalemer for the function signature.)

It allows refactoring previous code of:

```
if (room.game && room.game.gameid !== 'hangman') return;
const game = room.game as Hangman;
```

to:

```
const game = room.getGame(Hangman);
if (!game) return;
```

This has a couple of advantages:
- TypeScript will throw an error if the if condition is not present.

- In the new code, the template must extends `RoomGame` and be assignable to the same ID, so it's 100% typesafe
2020-02-03 05:09:37 -08:00
Marty-D
47c8d6b52b Fix Pickpocket interaction with switches
U-turn is the only switch effect that occurs after Pickpocket resolves during an attack segment (even though the switch message and animation appear to happen before it)
2020-02-02 15:02:41 -05: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
Waleed Hassan
6b62cfb06a Stop using Rooms.lobby in tests (#6316)
It's not guaranteed to exist.
2020-01-26 13:41:39 -08:00
Kirk Scheibelhut
e44a5683c3 Add EBC to Gens 1 and 2 (#6298)
Also add test for 1000 turn termination behavior.
2020-01-22 14:13:36 -08:00
Guangcong Luo
e6f53a7ad2 Implement smart target tracking
(Stalwart, Propeller Tail, Snipe Shot behavior.)
2020-01-18 15:43:33 -07:00
CK Yong
f8d0f3fffd Fix Pickpocket applying when being switched out through Eject Button (#6254)
Also makes sure that dragging moves like Dragon Tail do activate Pickpocket.
2020-01-13 19:32:37 -05:00
not_a_seagull
ae28a960be Convert index.js and team-validator-async.js to typescript (#5987) 2020-01-04 07:11:54 -05: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
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
Guangcong Luo
744f7732e8 Fix rulesets
- Remove "Standard Ubers"

- Rename "Standard ND" -> "Standard NatDex"
2019-12-30 12:23:51 +09:00
Guangcong Luo
a6dd6d7779 Add test for Ultra Necrozma validation 2019-12-25 16:10:16 +09: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
Guangcong Luo
49e65dc803 Refactor unit test battle formats again
It turns out not creating a format on-the-fly breaks deserialization.

We now just use the same custom-rule system that tournaments use.
Some hacks are currently necessary (many tests assume that we're
playing in Anything Goes rather than Custom Game) but we'll work them
out in time.
2019-12-11 16:26:45 +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
The Immortal
26c11a20e8 Add test for Aura Wheel
And clean up the implementation.
2019-12-10 02:05:41 +04:00
The Immortal
29fdcc42cf Update Electric/Grassy/Psychic terrains 2019-12-08 22:35:07 +04:00
The Immortal
1b0eb00ca4 Another Neutralizing Gas test 2019-12-05 17:55:10 +04:00
whales
6aa04a842d Fix Pain Split (#6151) 2019-12-05 17:46:59 +04:00
The Immortal
73d7404b05 Add test for Pain Split
This passes prior to 9b943fb62f.
2019-12-05 03:22:02 +04:00
The Immortal
65df724480 Test Neutralizing Gas against Natural Cure 2019-12-04 23:19:35 +04:00
The Immortal
674c1a64a0 Add tests for Neutralizing Gas 2019-12-04 17:50:48 +04:00
Guangcong Luo
45e5b6cc7d Add more tests for mega evolution Speed changes 2019-12-04 13:36:40 +09: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
Guangcong Luo
d5b4b7964e Fix mega evolution priority move interaction 2019-12-01 20:08:25 +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
Guangcong Luo
a00d64a092 Fix some tests to be less RNG-dependent 2019-11-28 18:16:02 +13:00
The Immortal
7cccda3b18 Update Other Metagames 2019-11-25 06:53:08 +04:00
HoeenHero
c37b57e172 Update Random monotype team generator test to Gen 8 2019-11-18 23:35:03 -05:00
The Immortal
eb905cbe92 Implement Disguise damage 2019-11-18 23:58:00 +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
Kirk Scheibelhut
a4698a52cb Reenable ExhaustiveRunner test with workaround 2019-11-15 14:45:38 -08:00
Guangcong Luo
52cbe7d187 Skip ExhaustiveRunner test
This is until pre gets online and we can figure out what's wrong with
it. The bug doesn't seem to be on our end, and I can't figure out why
it's generating Pokemon with species "".
2019-11-16 10:35:37 +13:00
Guangcong Luo
84fb8d5bb4 Fix some build crashes 2019-11-16 10:13:27 +13:00
Guangcong Luo
801af59b98 Fix remaining build errors
- Centiskorch was misspelled in formats-data, causing a crash in the
  egg validator

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

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

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

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

- Inverse Mod suddenly stopped working; its implementation was a huge
  hack and I can't figure out what went wrong, so I've switched it to
	using the same system the other mod tests use. It's still a huge
	hack, but I don't have the free time to fix it right now.
2019-11-16 06:08:48 +13:00
Guangcong Luo
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
2ebe46bac5 Fix crash in tradeback validation 2019-11-09 05:50:52 +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
Guangcong Luo
77f7cb9fb0 Correctly validate Ash-Greninja 2019-10-18 14:37:23 +10:30
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
whales
fa5f1389f8 Fix a few more userid -> id changes (#5886) 2019-10-15 18:20:58 +10:30
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
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
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
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
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
whales
71cee7bfac Add basic tests for permissions (#5847) 2019-10-05 00:30:49 +10: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
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
TheJetOU
2b28c9fd6b Refactor Rooms(), Users() to Rooms.get(), Users.get() (#5725) 2019-08-25 06:33:56 -07:00
TheJetOU
4f7ad0132b TypeScript Ladders (#5696) 2019-08-12 09:48:18 +02:00
Jacob McLemore
3af1c771c2 Fix Encore + Pledge moves interaction (#5641) 2019-08-01 20:31:38 -04:00
jmclemo6
e4ad7d894b Moves: Fix Flower Veil + Yawn interaction when ally is already under effect of Yawn 2019-07-21 14:21:42 -05:00
Ben Davies
eaf4b6001d Add more Dashycode tests 2019-07-20 10:50:02 -03:00
Jacob McLemore
ae1ac25398 Add tests for Psych Up (#5624) 2019-07-18 09:17:05 -07:00
Jacob McLemore
7e4ebe44aa Make moves called by Dancer target properly (#5616) 2019-07-16 21:15:05 -04:00
Ben Davies
a135ec214a Correct comment about codepoints in Dashycode unit tests 2019-07-13 04:39:38 -03:00
Ben Davies
f5822d9e9f Remove unused parameter from function in Dashycode's unit tests 2019-07-13 02:53:32 -03:00
Ben Davies
e770a565dd Mention why we don't test codepoints above 0xFFFF with Dashycode 2019-07-13 02:45:23 -03:00
Ben Davies
1375d653f9 Unit test Dashycode 2019-07-13 02:42:57 -03:00
Kirk Scheibelhut
df083d7528 Remove Object.assign(function) pattern from TeamValidator{Async} 2019-07-01 08:20:51 -07:00
Kirk Scheibelhut
8fe6d89d14 Make sure randomly generated monotype teams are actually all one type 2019-06-27 12:10:03 -07:00
Kirk Scheibelhut
d279a95829 Ensure random team generation always ends up with 6 Pokemon (#5556) 2019-06-27 10:23:25 -07:00
Kirk Scheibelhut
676b3b276c Actually correct assertions in EBC tests 2019-06-20 11:52:48 -07:00
Kirk Scheibelhut
01f56dbcea Fix asserts in EBC tests to actually check the winner 2019-06-19 21:04:50 -07:00
Kirk Scheibelhut
be19918c49 Fix incorrect ability message from Gen 1 Transform (#5518) 2019-06-02 17:05:41 -05:00
Guangcong Luo
7436c1f0f2 Remove import = and export =
`import =` and `export =` are really only intended for backwards
compatibility with CommonJS. While I really don't like the new module
system TC39 has designed for us, it's what we should be using, and
consistency is important.
2019-05-16 01:27:07 +04:00
Jacob McLemore
0ae5f842d3 Fix Fusion Bolt and Fusion Flare's interaction with each other (#5493) 2019-05-14 15:49:51 -04:00
Kirk Scheibelhut
3d24166cdf toId -> toID
Closes #5479
2019-05-12 17:53:01 -07:00
Guangcong Luo
2093539e06
Update RoomGame API (#5492)
- The big change here is that player.userid can now be empty. You can
  now fit state into RoomGamePlayer subclasses even when there are no
  users associated with them.

- `game.players` has been introduced as the new canonical list of
  players, including userless players. The old `game.players` has been
  renamed `game.playerTable`, for clarity.

- `game.addPlayer` now returns the added player

All existing RoomGames have been updated for the new API, and
RoomBattle is now officially a RoomGame subclass.

Tournaments was also massively refactored to be properly updated for
the old API, since that never happened, and should now be a lot more
readable.
2019-05-12 12:56:32 +09:30
Kirk Scheibelhut
297b7a951c Mark EBC, Random Team Generator and serialization tests as slow 2019-05-09 17:47:00 -07:00
Kirk Scheibelhut
a0734bde6f Redo Endless Battle Clause with a new specification (#5472) 2019-05-07 11:18:06 +09:30
Kirk Scheibelhut
df3d9b91ef Battle toJSON/fromJSON (#5427) 2019-04-30 14:48:27 +12:00
Kirk Scheibelhut
3a366d0499 Fix Gen 2 TOX -> PSN crash (#5463) 2019-04-26 09:21:11 -07:00
Kirk Scheibelhut
1adcd40e48 Windows-friendly Mocha setup
This reverts commit cccc904059.
2019-04-23 07:51:06 -07:00
Kirk Scheibelhut
cccc904059 Fix Mocha setup so that filtering works properly.
With `-i` in tests/mocha.opts, `npx mocha -g Foo` runs everything
*except* the tests you actually wanted to run (the `-g` overrides
the default `-g`, but unless you specify `--no-invert`, nothing will
override the default `-i`).

Having `test` not just be `mocha` is regrettable, but breaking `npx
mocha -g` or requiring users who want to filter remember to also
pass `--no-invert` is not a good tradeoff.
2019-04-22 21:52:46 -07:00
Kirk Scheibelhut
4975f1902b Move simulator harness to sim/tools (#5451) 2019-04-18 04:17:07 +09:30
Kirk Scheibelhut
8c7abf8729 Move dev-tools/user-utils.js -> test/user-utils.js 2019-04-15 15:24:56 -07:00
Kirk Scheibelhut
e689913084
Unify dev-tools runners and convert to Typescript (#5441)
- Refactor dev-tools/harness.js and dev-tools/smokes.js to separate
  out the script/CLI code and implementation code into separate
  files.
- Rename 'smoke' to 'exhaustive' ('multi' mode can also be used
  for "smoke testing") to better describe its behavior.
- Rewrite the runners in Typescript for type safety.
- Refactor common build utilities into dev-tools/build.js and
  introduce the notion of a 'full' build analogous to 'full' tests.
2019-04-15 15:22:37 -07:00
Kirk Scheibelhut
5c10ebf428
Rework mocha fulltest configuration (#5442) 2019-04-15 14:16:52 -07:00
Slayer95
ffb3678b0f Test: Update folder structure to match source code (#5436) 2019-04-14 23:57:06 +09:30
Kris Johnson
eb6c438466 Battle Factory: Add tests for EVs, learnsets, and natures (#5397) 2019-04-13 04:40:00 +09:30
Slayer95
72b7e990fd Test: Implement npm run fulltest (#5437)
- Tests flagged with (slow) will no longer be run in `npm test`.
- Travis CI will now run `fulltest`.
- Unskip slow dev-tools tests and flag as such.
2019-04-13 04:38:32 +09:30
Kirk Scheibelhut
d29c08a12e Disable slow harness tests to avoid timeouts
Poor @KrisXV can't run these. Flip them to pending while we sort
out a better story for slower tests.
2019-04-08 19:14:07 -07:00
Marty-D
e5167babcf Fix Jump Kicks against no target 2019-04-08 17:15:05 -04:00
Kirk Scheibelhut
b2777f9bf6 Remove |callback| in favor of |error| (#5418) 2019-04-09 03:33:32 +08:00
Kirk Scheibelhut
32a457c808
Add a smoke test runner to dev-tools (#5405) 2019-04-07 08:34:43 -07:00
Kirk Scheibelhut
0efd71dfef Move Data.ActiveMove methods to Pokemon (#5416)
See #5415 for context - having these methods is unsafe and leads
to crashes because not all ActiveMoves are created through the
Data.ActiveMove constructor. Instead of Pokemon, these could
alternatively be static methods on ActiveMove (or the ActiveMove
class could be completely abolished and reverted back to an
interface), but #5415 will deal with ActiveMove long term, this just
fixes the crashes.
2019-04-06 13:14:50 +08:00
MacChaeger
fe1613797f Fix Z Moves breaking Protect (#5413) 2019-04-06 01:06:22 +08:00
MacChaeger
d3f1161b62 Fix Weakness Policy and Clangorous Soulblaze in doubles (#5389) 2019-04-04 18:51:27 +08:00
Kirk Scheibelhut
272700f2b2 Fix crash from Gen 4 Custap Berry + Trump Card interaction (#5395)
Fixes #5393
2019-04-04 01:20:11 +08:00
Kirk Scheibelhut
ece322801d Introduce dev-tools/harness.js for testing/benchmarking (#5370) 2019-04-04 00:47:47 +08:00
Kirk Scheibelhut
0f8241045b Test 'noCancel' behavior to prevent #5344 (#5348)
Renames currentRequest -> requestState to avoid confusion.
2019-04-03 11:58:53 +08:00
Ivo Julca
b369b0f680 Sim: Fix crash in Team Preview
Regression from the deletion of parseChoice() @698fb2a
2019-03-30 19:39:24 -05:00
Slayer95
6384964a10 Sim: Z Moves may only be disabled when all base moves are (#5387) 2019-03-30 18:14:53 -04:00
Slayer95
694cd47e7b Fix target resolution (#5363) 2019-03-30 22:34:44 +08:00
MacChaeger
a729cb577f Fix duration of slot conditions (#5372) 2019-03-29 23:03:10 +08:00
MacChaeger
2edd8a354f Fix Leech Seed vs. Magic Guard (#5374) 2019-03-29 23:01:50 +08:00
MacChaeger
5a4578420b Fix attacks failing if only their effect fails (#5373) 2019-03-29 22:48:15 +08:00
MacChaeger
9472019e03 Fix Gear Up and Magnetic Flux (#5368) 2019-03-28 14:19:47 -04:00
MacChaeger
905ed1e95c Fix multihit moves continuing after a KO (#5360) 2019-03-28 19:02:37 +08:00
Slayer95
c18f244071
Test: Prevent before hook from timing out
It times out often in certain environments.
2019-03-28 00:06:45 -05:00
Ivo Julca
ac4b94876b Sim: Refactor to use Battle#getAllPokemon() and Battle#getAllActive() 2019-03-26 23:18:19 -05:00
MacChaeger
6adc779a19 Fix doubled recoil (#5358) 2019-03-27 11:15:57 +08:00
MacChaeger
9a7ce3dedf Put side conditions on p1 and p2 in multi battles (#5341) 2019-03-27 11:00:36 +08:00
MacChaeger
860900ac57 Fix AfterDamage event running on secondary effects (#5350) 2019-03-26 15:29:46 +09:00
Kirk Scheibelhut
9f5a727ad1 Pull Field out of Battle (#5333) 2019-03-23 02:52:12 +09:00
Ivo Julca
3cbe38130c Test: Fix usage of assert.throws() 2019-03-22 02:26:14 -05:00
Ivo Julca
dd2759c1c3 Test: Fix testing of choice internals 2019-03-22 02:21:22 -05:00
Ivo Julca
7736cbf21d Test: Remove usage of deprecated Battle#join() API 2019-03-22 01:48:34 -05:00
Kirk Scheibelhut
564dae455d Make Battle throw on choice errors in tests (#5286) 2019-03-21 13:14:38 +09:00
MacChaeger
a44f16c6e3 Fix pivot moves vs. Substitute (#5314) 2019-03-19 11:50:27 +09:00
MacChaeger
6c486409f4 Fix spread move effect order (#5216) 2019-03-17 23:30:08 +09:00
Marty-D
39a8b4270e Fix Stealth Rock effectiveness during Delta Stream 2019-03-16 14:38:03 -04:00
urkerab
2ea89698b0 Run effectiveness events even for string type (#5310) 2019-03-14 20:03:14 +09:00
Slayer95
7a7ad8453d Fix regressions in team generators (#5302) 2019-03-12 18:44:38 -07:00
Kirk Scheibelhut
e9ccc7ecd6 Fix Stadium mod's stat modification logic (#5301) 2019-03-12 13:52:32 -07:00
Ivo Julca
6fe53e6b6d Test: Remove deprecated API in common lib 2019-03-11 21:26:16 -05:00
Kirk Scheibelhut
4fe5fd2bf5 Split out 'Conversion 2' tests from targeting 2019-03-10 13:48:09 -05:00
Kirk Scheibelhut
1b2aeb696b Reject move commands with multiple flags (#5290) 2019-03-09 23:23:36 -06:00
Kirk Scheibelhut
538731d6df Accept move choices with target/mega in either order (#5284) 2019-03-09 20:21:17 -06:00
Kirk Scheibelhut
a8903d2563 Cleanup stat naming and types (storedStats, StatNameExceptHP) (#5274) 2019-03-09 09:53:11 -06:00
Kirk Scheibelhut
d5710acf8a Remove unnecessary Array.prototype.values() calls (#5282)
These break on Node < v10.9.0
2019-03-09 08:49:10 -06:00
JetOU
85533ee3a0 Change forEach to for...of (#5269) 2019-03-08 11:24:58 -06:00
Kirk Scheibelhut
dc5255f7c8 Fix Gen 1 Substitute + self damage behavior (#5263) 2019-03-06 16:12:32 -05:00
Kirk Scheibelhut
961b9882f5 Fix Gen 4 interaction between U-turn/Substitute/Intimidate (#5222) 2019-03-06 08:33:52 -05:00
Kirk Scheibelhut
6f82443101 Fix GSC Toxic interaction with Baton Pass/Heal Bell (#5226) 2019-03-05 13:28:01 -05:00
MacChaeger
82ae8db93a Fix Snarl test (#5253) 2019-03-05 09:20:11 -06:00
MacChaeger
33a872e029 Gen 7: Stockpile tracks individual stat alterations (#5246) 2019-03-04 17:59:44 -06:00
Guangcong Luo
39f0ca022e Fix validation of Gen 2 Marowak set
This was a lot of work for what turned out to be a really simple fix.
Gen 2 tradeback validation ended up being slightly too strict.
2019-03-03 08:45:45 -06:00
Kirk Scheibelhut
6e122d5d74 Refactor lib/ to be native Typescript (#5217) 2019-03-02 11:12:24 -06:00
Kirk Scheibelhut
aa81f2a2d8 Fix Shell Trap behavior with Encore (#5218) 2019-02-28 14:27:56 -05:00
Guangcong Luo
4e1ef51b8a Add one more volatile switch test 2019-02-26 19:21:14 -06:00
Kirk Scheibelhut
b09fd63377 Refactor sim/ to be native Typescript (#5210) 2019-02-26 11:03:30 -06:00
Kirk Scheibelhut
6ddb714f44 Fix Counter/Mirror Coat to respect redirection (#5212) 2019-02-26 09:52:10 -06:00
Kirk Scheibelhut
623b349fc1 Fix Gen 1 bug involving last damage and Substitute (#2598) (#5211) 2019-02-25 21:24:14 -06:00
Kirk Scheibelhut
4e421c1bd9 Refactor getEffect for speed safely (#5201)
Rollforward of 7a20245 which retains the `hasOwnProperty` checks.

Also changes the method to call `toId` earlier and use the id
as the key to the cache to ensure 'Stealth Rock' and 'stealthrock'
return the same. NOTE: 'move: Stealth Rock' and 'Stealth Rock' will
still continue to return different results.
2019-02-23 19:28:06 -06:00
Guangcong Luo
5f41684442 Further improve switch tests
- Test that Baton Pass passes Ingrain
- Test that Baton Pass doesn't pass Imprison
- Test that other forms of switching don't pass either
2019-02-23 07:01:07 -06:00
Guangcong Luo
9b694fa350 Add Imprison switch-out test
Apparently we had zero tests to make sure volatile statuses go away
after switching out and back in!
2019-02-23 03:27:32 -06:00
Kirk Scheibelhut
fd0059f39b Fix random typos in tests (#5190) 2019-02-20 22:16:44 -06:00
Guangcong Luo
94b2d65b05 Finally remove deprecated legacy API
It's gone! The last remnants of the old choice parsing system is
finally gone!
2019-02-20 02:58:41 -06:00
Kirk Scheibelhut
0e4ed7fd40 Refactor remaining tests to use Battle#makeChoices (#5183) 2019-02-20 00:34:31 -06:00
Konrad Borowski
7481ccc680 Disallow 0 EVs even when EVs weren't sent (#5187) 2019-02-20 00:05:12 -06:00
HoeenHero
9c9004cacf Fix "Fix terrain seed activation timing (#5163)"
Shouldn't of reverted this so quickly. Credit to the code goes to @MacChaeger
2019-02-16 20:31:07 -05:00
HoeenHero
f8a1612906
Revert "Fix terrain seed activation timing (#5163)" (#5173)
This reverts commit 250955ee68.
2019-02-16 19:46:53 -05:00