Commit Graph

1096 Commits

Author SHA1 Message Date
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
MacChaeger
250955ee68 Fix terrain seed activation timing (#5163) 2019-02-16 19:30:00 -05:00
Konrad Borowski
883c611078 Add tests for Sleep Clause Mod (#5171) 2019-02-16 12:47:22 -06:00
Konrad Borowski
a97b879e2d Prevent using Leppa Berry from triggering Endless Battle (#5158)
Previously, using Leppa Berry by itself caused Endless Battle Clause
to consider Pokemon to be stale. However, it is reasonable to use
Leppa Berry without an intent to cause an endless battle - for
instance to increase the PP of a move with a low PP.
2019-02-15 17:43:19 -06:00
Guangcong Luo
8ff241906d Check capitalization in Factory sets
This might be debatably important, but if it's worth pointing it out
in reviews, we might as well automate it.
2019-02-06 10:40:10 -06:00
Guangcong Luo
70b3e9a525 Rename channel -> room, subchannel -> channel
"channel" is just a fancy way of saying "room, but in sockets".
Renaming them like this should make it clearer exactly what's going
on in sockets.
2019-02-05 16:55:37 -06:00
Guangcong Luo
b15c9a60f9 Fix formatText support for & > etc in URLs 2019-02-04 09:17:48 -06:00
Guangcong Luo
f3e45fbb72 Move server code to server/
Also move mods/ to data/mods/

This makes PS more monorepo-like. The intent is to further separate
the sim and the server code, but without fully committing to splitting
the repository itself.

We now support `./pokemon-showdown start` in addition to
`./pokemon-showdown`. I'm not clear which I want to be the default
yet.
2019-02-03 16:07:06 -06:00
MacChaeger
cf7670f0b2 Gen 1: Paralysis should not reapply stat drop because of a failed move (#5123) 2019-01-26 01:30:58 -06:00
Guangcong Luo
74dfd71355 Support Config.fakeladder
Useful for local testing, ignores matchmaking conditions like "can't
match same player twice in a row" and "can't match same IP", to make
it easier to test ladder stuff.
2019-01-26 00:40:00 -06:00
MacChaeger
2a60ad7589 Fix stomping tantrum vs. only Protect (#5081) 2019-01-15 22:03:54 -06:00
Russell Jones
d35aeb0b23 Trying another fix for Fake Out (#5103) 2019-01-14 09:52:04 -06:00
Konrad Borowski
92d69fe8f8 Add basic Fake Out tests 2019-01-13 19:08:36 +01:00
Konrad Borowski
4f9375e5d0 Trivia alternate leaderboards (#5096) 2019-01-12 07:58:13 -06:00
MacChaeger
54eeb88e5e Fix Stomping Tantrum interaction with spread moves and Protect (#5055) 2018-12-28 20:09:31 +04:00
Russell Jones
c70d369c10 Add unit tests for Photon Geyser (#5050) 2018-12-27 14:30:11 -08:00
MacChaeger
2710633765 Magic Guard should block crash damage (#5042) 2018-12-25 09:08:00 -08:00
Alexander B
eecde00ed3 Fix Leppa Berry (#5025) 2018-12-14 01:12:41 -06:00
Guangcong Luo
13614b9890 Update for TypeScript 3.2
TypeScript 3.2 unearthed a metric fuckton of bugs, making this change
take effectively forever.
2018-12-08 21:39:38 -06:00
Guangcong Luo
b95fe3a497 Implement proper RNG for speed ties
So the Pursuit unit test is broken in Node 0.11, because PS relies on
the sort function deterministically calling the comparison function,
and due to a recent V8 update, the call order changed.

This was a good thing, anyway, since PS didn't handle 3+-way speed ties
correctly, anyway, and it reminded me to go and fix that. Which I did.

This is as cartridge-accurate as possible, given the description given
to me by V4 in #1157.

Fixes #1157
2018-11-27 22:22:34 -06:00
whales
c85d931fdf Use default config for tests (#4959) 2018-11-08 10:13:32 -06:00
Konrad Borowski
09360e88ca Add a test for self-damage critical hits (#4954) 2018-11-04 10:55:49 -06:00
Alexander B
34c3096d6b "But it failed!" messages should not reveal the target (#4944) 2018-11-01 09:41:04 -04:00
Konrad Borowski
bd99a2b9b0 Support gTLDs in e-mail addresses (#4931)
Back when this code was introduced, the TLDs were relatively short,
with only two outliers: .museum and .travel.

Since then, a generic TLD system was introduced which opened
registration of top level domains. The number of TLDs registered this
way exceeds 1 200, with the longest TLDs having 18 characters.

Parsing longer TLDs for emails shouldn't cause practical issues, as
e-mail syntax is unusual enough. In fact, in the older versions, this
code was buggy as it linked example@example.exa in
example@example.example, not noticing that there should be a word
bounary.
2018-10-25 15:40:18 -05:00
Konrad Borowski
60c3fe5e05 Test links with parenthesis (#4932)
A lot of complexity in a chat formatter link regular expression is to
support links with parentheses in them. This commit introduces a test of
this to avoid accidentally breaking this functionality.
2018-10-25 15:37:28 -05:00
Guangcong Luo
d687de0dd5 Add tests for Weather Ball 2018-10-11 13:10:33 -05:00
Guangcong Luo
e709249a65 Fix frozen battle with partial choices
PS is inconsistent about which parts do or don't support partial
choices.

This change makes it so battle.choose no longer supports partial
choices, while side.choose still does.

This fixes the bug where making a partial choice caused a battle
freeze.
2018-10-05 03:54:59 -05:00
Marty-D
02332ce2fa
Test some more illegal egg move combinations 2018-08-21 13:47:21 -04:00
Guangcong Luo
3d148a10f6 Validate species ID in factory-sets.json
Regression test for 139a852a70

(Commented out due to failing test; TODO: figure out what to do about
this)
2018-08-18 22:28:33 -05:00
Kevin Lau
ab7813cc74 Add Parental Bond Tests (#4803) 2018-08-11 11:44:08 +09:00
Quinton Lee
58b20d99eb Dex: Support custom rules altering complex bans (#4738)
Also adds some tests for custom rules
2018-07-03 17:22:28 -07:00
urkerab
89e33bc649 Fix Bestow, Covet, Symbiosis and Thief with a required item (#4715) 2018-07-02 17:36:37 -04:00
MacChaeger
b082705569 Transform should ignore Roost's effects (#4698) 2018-05-28 13:17:06 -04:00
MacChaeger
1aaeca908f Fix transforming into Arceus/Silvally (#4687) 2018-05-23 19:55:59 -04:00
MacChaeger
08ba5bc831 Make formeChange handle relevant messages and ability changes (#4654) 2018-05-23 19:55:05 -04:00
MacChaeger
526c118d1e Imprison shouldn't stop z-status moves (#4686) 2018-05-23 14:40:36 -05:00
MacChaeger
1be208916a Improve Stomping Tantrum interaction with Protect (#4680) 2018-05-21 22:39:30 -04:00
MacChaeger
e3174ebc02 Fix type display in Gen 7 metas (#4655) 2018-05-21 17:27:23 -05:00
Kevin Lau
4847ecb06d Add Truant unit tests (#4681) 2018-05-21 18:07:08 -04:00
MacChaeger
6a7c3aa138 Heal Block should not prevent any direct healing effects from Z-Moves (#4676) 2018-05-19 22:51:45 -04:00
Guangcong Luo
40c1dcdb1d Add a longer timeout to BSS set validator 2018-05-02 17:45:15 -05:00
MacChaeger
c6806c84ff Fix Defog and Splash-likes being erroneously counted as failures (#4627) 2018-04-27 21:59:52 -05:00
Kris Johnson
09bf67da3a BSS Factory: Remove unnecessary set properties (#4623) 2018-04-26 10:51:57 -04:00
Kevin Lau
f35d43ef36 Fix countering a hit for 0 damage (#4621) 2018-04-26 10:51:05 -04:00
MacChaeger
711a0d4ce4 Check semi-invulnerability before immunities (#4574) 2018-04-14 10:27:45 -04:00
whales
eb61aac282 Tests#Ban: Ignore shared IPs (#4565) 2018-04-09 01:58:31 -05:00
Ivo Julca
9d25f7fde7 Test: Add Fusion Bolt and Fusion Flare
Refs #4558
2018-04-08 01:25:58 -05:00
Ivo Julca
52746acd49 Test: Add Trump Card 2018-04-08 01:23:43 -05:00
Ivo Julca
da4a8b72ce Fix: Preserve pranksterBoosted for Status moves overriden into other moves
So if a Prankster-mon chooses in two successive turns an attacking move and an Status move,
and this Pokémon is encored into the attacking move before the Status move proceeds,
the attacking move will be used and it won't affect a Dark-type target.
2018-04-06 05:09:47 -05:00
MacChaeger
2feb607c9d Pursuit should not move before a switch when targeting an ally (#4548) 2018-04-05 22:07:54 -04:00
MacChaeger
27afe1b6b8 Gen VI-VII: Transform should copy Focus Energy (#4546) 2018-04-05 09:19:43 -04:00
MacChaeger
054c545c05 Fix Prankster interaction with bounced/encored moves (#4533) 2018-04-01 22:23:43 -04:00
Brandon Gottlob
27d3e4fc5b Refactor tests to use new makeChoices API (#4528)
See 8473c3f4fa for the example followed in the refactor
2018-03-30 16:06:14 -05:00
asgdf
913d126e17 Fix Rock Head throwing errors in valid situations 2018-03-29 02:24:51 -05:00
asgdf
324e853f4a Enable explicit allowing/disallowing of renames in battles (#4510) 2018-03-22 10:07:47 -05:00
asgdf
b205140de0 Tests: Prevent expired battle warning message (#4505) 2018-03-20 10:54:11 +09:00
Marty-D
bcf17f9471 Move Gen 6 Battle Factory to its mod 2018-03-16 19:28:12 -04:00
Matthew Glazar
6c2350f5b6 Refactor random indexes into sample function
Often, you just need a random item in an array. Throughout Pokemon
Showdown's code, there are many instances of the following pattern:

    let randomThing = things[this.random(things.length)];

Make this code easier to read by factoring the indexing into the
PRNG#sample function:

    let randomThing = this.sample(things);

Run the following sed script to refactor lots of code to use sample:

    s/\([a-zA-Z0-9.]\{1,\}\)\[this\.random(\1\.length)\]/this.sample(\1)/

This commit should not change behaviour. In particular, PRNG#next is
called the same number of times with the same number of parameter as
before this commit, and PRNG#next's results are interpreted in the same
way as before this commit.
2018-03-12 05:53:33 +09:00
Matthew Glazar
45a876917d Refactor random booleans into randomChance function
Often, you just need a random boolean. Throughout Pokemon Showdown's
code, there are many creative ways of requesting random booleans. For
example:

    if (this.random(10) < 3) {
    if (this.isWeather(['sunnyday', 'desolateland']) || this.random(2) === 0) {
    let shiny = !this.random(1024);
    if (uberCount > 1 && this.random(5) >= 1) continue;
    if (!this.random(3)) ability = ability1.name;
    } else if ((ability === 'Iron Barbs' || ability === 'Rough Skin') && this.random(2)) {
    if (typeof secondary.chance === 'undefined' || this.random(256) <= effectChance) {
    if (accuracy !== true && this.random(256) > accuracy) {

Enable these methods to converge by introducing the PRNG#randomChance
function. It accepts a probability and returns true with that
probability.

Run the following sed script to refactor many common patterns to use
randomChance:

    s/this\.random(\([0-9]\{1,\}\)) >= \([0-9]\{1,\}\)/!this.randomChance(\2, \1)/g
    s/this\.random(\([0-9]\{1,\}\)) < \([0-9]\{1,\}\)/this.randomChance(\2, \1)/g
    s/this\.random(\([0-9]\{1,\}\)) === 0/this.randomChance(1, \1)/g
    s/!this\.random(\([0-9]\{1,\}\))/this.randomChance(1, \1)/g

The sed script takes advantage of the following properties:

    random(x) < y     is equivalent to   randomChance(y, x)
    random(x) >= y    is equivalent to   !(random(x) < y), i.e. !randomChance(y, x)
    random(x) === 0   is equivalent to   random(x) < 1, i.e. randomChance(1, x)
    !random(x)        is equivalent to   random(x) === 0, i.e. randomChance(1, x)

This commit should not change behaviour. In particular, PRNG#next is
called the same number of times with the same number of parameter as
before this commit, and PRNG#next's results are interpreted in the same
way as before this commit.
2018-03-08 20:11:33 +09:00
asgdf
d9c3b46b83 Extend Protective Pads unit tests (#4467) 2018-03-08 04:11:37 +09:00
asgdf
9448f51db7 Add unit test for Protective Pads/Mummy interaction (#4462) 2018-03-06 13:38:20 +09:00
strager
423509bceb Cache species-specific effects (e.g. Arceus); 20% overall perf win (#4459)
Battle#getRelevantEffectsInner performs a lookup for the base species of
every Pokemon with ModdedDex#getEffect, then invokes callbacks. The
lookup is expensive, and callbacks very rare. In fact, there are only
ever two callbacks: one for Arceus (SwitchIn) and one for Silvally
(SwitchIn).

Instead of an expensive ModdedDex#getEffect lookup for the callbacks,
put the callbacks directly on the Pokemon's Template object.

On my machine, this commit speeds up Pokemon Showdown's tests by 20%.

Methodology: With and without this commit, I ran mocha four times with
zsh' 'time' builtin, dropped the first result, and averaged the wall
times:

    mocha times before this commit:
    18.20s user 0.33s system 118% cpu 15.704 total
    17.91s user 0.34s system 118% cpu 15.454 total
    18.11s user 0.33s system 118% cpu 15.558 total

    mocha times after this commit:
    15.58s user 0.33s system 122% cpu 13.028 total
    15.32s user 0.33s system 121% cpu 12.890 total
    15.56s user 0.32s system 121% cpu 13.068 total

    Hardware:
    Mid 2012 MacBook Pro
    2.6 GHz Intel Core i7

    Software:
    Node v9.0.0
    macOS 10.10.5
2018-03-05 17:24:14 +09:00
Marty-D
3e9a92b1be
Tests: Fix typo 2018-03-02 14:32:28 +00:00
Guangcong Luo
fae7174912 Add BSS factory set validator 2018-03-02 20:29:30 +09:00
Guangcong Luo
8b19a546b8 Fix chainbreeding validator 2018-02-01 21:06:37 -06:00
Guangcong Luo
245af440d4 Fix style error 2018-01-31 22:26:24 -06:00
Guangcong Luo
78c327028e Fix Blissey Present + Heal Bell egg move bug
I originally thought this would have to be hardcoded, but actually this
can be coded slightly less hardly than expected!

Getting a Blissey with Present + Heal Bell in Gen 2 works like this:

- Teach Smeargle Present + Heal Bell
- Breed Present + Heal Bell into Snubbull
- Chainbreed Present + Heal Bell into Blissey

The main issue is that checking chainbreeding is very hard, so PS
mostly just takes the stance of "chainbreeding multiple moves is
probably impossible; hardcode exceptions".

BUT! BUT!!!!

Instead of hardcoding this exact move combination, we can actually
just hardcode the fact "the first step of chainbreeding is always legal
if the first father is Smeargle". Which I did and it works!
2018-01-31 21:53:11 -06:00
Guangcong Luo
1b8d7775d9 Tests: Improve error message for Promise rejections 2018-01-31 21:53:10 -06:00
Guangcong Luo
ba4e9870d4 Fix getChoice
It now returns a valid choice string for Team Preview choices.
2018-01-29 20:59:52 -06:00
Guangcong Luo
4c0699abc6 Implement inputLog
A battle's inputLog is now stored separately from the output log. It's
not an exact log of inputs, but rather just a collection of the inputs
that resulted in the battle: a default choice expands to the choice
that was actually used, and the starting seed is logged whether or not
it was explicitly passed into the battle stream.

Fixes #4348

Fixes #3201
2018-01-28 21:23:06 -06:00
Guangcong Luo
1531b662c6 Refactor battle stream system
This contains a lot of minor refactors, but the main thing that's going
on here is that battle stream writes have been streamlined to be a lot
easier for others to use.

We even support:

    ./pokemon-showdown simulate-battle

which provides a stdio interface for anyone using any programming
language to simulate a battle.
2018-01-28 21:06:49 -06:00
Guangcong Luo
9c037b17fe Refactor Battle constructor
`Sim.construct` no longer exists. Battles are now constructed directly
with `new Battle()`. Parameters other than formatid are now passed as
`options`.
2018-01-28 21:06:49 -06:00
Ricky Amparo
8e12a7ffd0 Tests: Refactor more tests to use makeChoices() (#4325) 2018-01-24 14:56:58 -06:00
Dan Huang
9c37960ab6 Use PRNG in sim/ files (#4365) 2018-01-24 12:27:07 -06:00
Guangcong Luo
e8163824ff Remove validate-conditionals eslint rule
As far as I can tell, `curly, multi-line, consistent` does everything I
want; there's no reason to keep around a validate-conditionals rule.

Which is probably good, since eslint is deprecating the API for this,
anyway. The nice thing about not relying on deprecated APIs is that now
you can lint PS with `eslint` rather than needing to memorize
command-line switches.
2018-01-19 13:25:10 -06:00
Guangcong Luo
43103f98ae Disable ProcessManager in tests 2018-01-18 04:10:19 -06:00
Guangcong Luo
ab1f995daa Rewrite Process Manager
Process Manager is now lib/process-manager.js

It's been entirely rewritten to reflect what I think a process manager
API should look like.

In particular, there are now two Process Managers, QueryProcessManager
and StreamProcessManager.

Pass QueryProcessManager a pure-ish query function (sync or async) that
takes a JSON value and returns a JSON value, and PM.query() will
execute that function in a subprocess, and return a Promise for its
return value.

StreamProcessManager is the same idea: Pass it a function to create an
ObjectReadWriteStream, and PM.createStream() will create a stream in a
subprocess and return a stream connected to it.
2018-01-18 03:34:16 -06:00
Guangcong Luo
d395424fd3 TeamValidator: Return null, not false, for valid team
As usual, having `T | false` be our optional is a really old PHP
convention; we should be using `T | null` basically everywhere.
2018-01-18 03:32:32 -06:00
Guangcong Luo
72d4f73160 Improve seed-passing experience in test API
Now, seeds are passed as arrays, rather than needing to pass an entire
PRNG object. In addition, they're now passed in the options object,
instead of as a separate argument.

This is done mostly so the Miracle Eye can be rewritten with a custom
seed, which requires fewer turns and should overall be faster. Which
was in turn done because a Miracle Eye timed out on Travis CI earlier.
Overall, the speed increase is pretty negligible, so this is mostly
just about improving the test API.
2018-01-18 03:31:13 -06:00
urkerab
99d682ca26 Change lastMove from a string to a Move (#4298) 2018-01-03 11:54:35 -06:00
Kris Johnson
238ac1fdd7 Refactor old gens to for...of (#4274) 2017-12-23 21:46:04 -06:00
Guangcong Luo
5094631fcf Implement Roomlog library
Rooms now have their logging abstracted into their own file, which also
allows the rest of rooms.js to be simplified by a decent margin.

This is in preparation for using Redis as a backing for scrollback log
storage, which will give us a lot more RAM to work with.

My newest newest plan is actually to locally cache room scrollback, and
only read battle logs from Redis. This will make chatroom-joining
faster.
2017-12-16 15:40:45 -06:00
Guangcong Luo
738c60ed8b Move repl.js -> lib/repl.js 2017-12-16 15:40:45 -06:00
MacChaeger
8d571be74e Fix certain Abilities not being overwritten by most forme changes (#4245) 2017-12-14 11:45:12 -05:00
Bär Halberkamp
65a82f28f0 Add a system for subrooms (#4014) 2017-12-13 23:33:25 -06:00
Guangcong Luo
f403a5d3ea Refactor some forEach to for...of 2017-12-12 14:50:08 -06:00
Marty-D
4d3440fedb
Tests: Fix Clangorous Soulblaze choices 2017-12-11 21:27:55 -05:00
urkerab
dc3945ff86 Protect should not affect Clangorous Soulblaze's other target (#4237)
Closes #4232
2017-12-11 09:02:24 -05:00
MacChaeger
d2a419d2be Update Stomping Tantrum's description (#4231) 2017-12-10 16:18:53 -05:00
Guangcong Luo
7e02b57016 Refactor Matchmaker to subclass Ladder
As expected, this resulted in zero API changes. (Aside from a minor
test change.)
2017-12-09 15:45:10 -06:00
Guangcong Luo
799a6a1e44 Improve Matchmaker API
Ladder is now a subclass of Matchmaker, and all the APIs previously
attached to Matchmaker are now directly available in Ladder.

In addition, all functions that take a formatid are now of the form
`Ladders(formatid).function(other arguments)`

TODO: Reverse polarity; it makes more sense for Matchmaker to be
a subclass of Ladder. Fortunately, this wouldn't involve API changes.
2017-12-09 15:04:29 -06:00
Guangcong Luo
5d11ec89f1 Fix base-pokemon banning 2017-12-08 22:27:30 -06:00
Guangcong Luo
0613939874 Refactor tournament rule validation
It was happening in two different places. It's been consolidated now.
2017-12-08 21:04:05 -06:00
Guangcong Luo
bb598ed6c2 Add rule validator for format rules 2017-12-07 22:07:12 -06:00
MacChaeger
0d10cfcf03 Add test for Recharge -> Stomping Tantrum (#4223) 2017-12-07 22:58:50 -05:00
MacChaeger
801883c53a Implement Stomping Tantrum (#4175) 2017-12-07 18:36:19 -06:00
Quinton Lee
b13098a684 Formatter: fix linking text followed by > (#4222) 2017-12-07 16:13:35 -06:00
Guangcong Luo
ead4ffff64 Sky Drop only makes contact on the way down 2017-12-06 12:05:42 -06:00
Guangcong Luo
c0da44c482 Refactor moveset -> moveSlots
pokemon.moveset is now pokemon.moveSlots, which is at least slightly
clearer about what it's doing (tracking move state, mainly PP).

Mostly, this gives a consistent naming scheme for `move` (a Move
object) vs `moveSlot` (a MoveSlot object).

This also refactors a lot of existing `moveSlot` accesses to be modern,
including using `for...of`.
2017-12-05 11:12:44 -06:00
Guangcong Luo
f3dbfbe685 Refactor Decision -> Action
"Decision" and "Choice" were always kind of unclear, so Decision is now
Action. It should now be a lot clearer.

Actions are also now strongly typed.
2017-12-02 11:34:55 -06:00
Guangcong Luo
70a5f3cf6d Fix Pursuit KO canceling a switch in Gen 3 2017-12-02 08:27:44 -06:00