Commit Graph

1124 Commits

Author SHA1 Message Date
Ivo Julca
b369b0f680 Sim: Fix crash in Team Preview
Regression from the deletion of parseChoice() @698fb2a
2019-03-30 19:39:24 -05:00
Kirk Scheibelhut
1c147644e9 Make sure BattleStream only calls _destroy once (#5382) 2019-03-31 00:29:20 +08:00
Slayer95
694cd47e7b Fix target resolution (#5363) 2019-03-30 22:34:44 +08:00
Slayer95
628f32e8fb Stricter type definitions for dex data (#5375)
BattleStatuses switched to PureEffectData
2019-03-30 22:31:04 +08:00
Kirk Scheibelhut
b7d9d6c611 Handle targetting adjacentFoe and adjacentAllyOrSelf in RandomPlayerAI (#5381) 2019-03-30 14:00:25 +08:00
Konrad Borowski
347e8a5181 Replace for-in pokemon.moveSlots iteration with for-of 2019-03-29 17:08:23 +01: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
Marty-D
1f8eeae108 Revert "Battle#residualEvent: Check fainted status earlier"
This reverts commit d499a019f0.
2019-03-28 14:55:13 -04:00
Konrad Borowski
d71a5c90a4 Temporarily mark flatMap as non-enumerable
This should deal with the issues with code using for-in
for arrays. This is a hack and should be removed.
2019-03-28 19:43:07 +01:00
Alexander B
57701a5f04 Refactor OMs to use "m" property of Pokemon (#4957) 2019-03-28 22:28:35 +08:00
Ivo Julca
ac4b94876b Sim: Refactor to use Battle#getAllPokemon() and Battle#getAllActive() 2019-03-26 23:18:19 -05:00
Ivo Julca
0ae0405f46 Sim: Implement Battle#getAllPokemon() and Battle#getAllActive() 2019-03-26 23:18:19 -05:00
Ivo Julca
2747ce61fb Sim: Split Pokemon#nearby(Allies|Foes) feature out of Pokemon#(allies|foes) 2019-03-26 23:18:19 -05:00
MacChaeger
9a7ce3dedf Put side conditions on p1 and p2 in multi battles (#5341) 2019-03-27 11:00:36 +08:00
Slayer95
d499a019f0
Battle#residualEvent: Check fainted status earlier 2019-03-26 18:15:18 -05:00
MacChaeger
860900ac57 Fix AfterDamage event running on secondary effects (#5350) 2019-03-26 15:29:46 +09:00
Kirk Scheibelhut
134fb8b852 Return from nextTurn if Endless Battle Clause is activated (#5347) 2019-03-26 03:07:09 +09:00
Guangcong Luo
c25b152e51 Fix onCreateBattleRoom
(And some other issues introduced by 4p refactor.)
2019-03-26 00:47:48 +09:00
MacChaeger
6760be4264 Restore Cancel Button (#5345) 2019-03-25 14:17:30 +09:00
Kirk Scheibelhut
9f5a727ad1 Pull Field out of Battle (#5333) 2019-03-23 02:52:12 +09:00
Kirk Scheibelhut
22b07d4ae6 Improve autochoose comment per @Slayer95 2019-03-22 02:42:05 -05:00
Kirk Scheibelhut
e61965eaf5 Pull out RandomPlayerAI from example and enhance 2019-03-22 02:42:05 -05:00
Kirk Scheibelhut
c911ee6fa6 Move sim/battle-stream-example.ts to sim/examples subdir 2019-03-22 02:42:05 -05:00
Guangcong Luo
8e7ba4d436
Fix line length for 0-EV check 2019-03-22 02:37:30 +09:00
Kirk Scheibelhut
2b1c278c42 Fix 'floating' promises and enable lint errors going forward (#5297) 2019-03-22 02:21:17 +09:00
Kirk Scheibelhut
03b2c92cb1 Make isNonstandard specify reason for non-standardness (#5330) 2019-03-22 01:49:22 +09:00
Kirk Scheibelhut
4be90a0a28 Cleanup sim/battle.ts (#5325) 2019-03-22 01:25:12 +09:00
Kirk Scheibelhut
564dae455d Make Battle throw on choice errors in tests (#5286) 2019-03-21 13:14:38 +09:00
Slayer95
0861c02479
Validator: Don't reject 0 EVs in debug mode 2019-03-20 15:27:51 -05:00
MacChaeger
d8514b47cc Refactor findEventHandlers to work with 4 players (#5313) 2019-03-19 11:49:18 +09:00
MacChaeger
47aadf9cc8 Fix spread modifier for gen 4 FFA battles (#5321) 2019-03-19 10:46:18 +09:00
Kirk Scheibelhut
cab87325e9 Push 'update' to p3 & p4 in BattleStream (#5317) 2019-03-19 09:40:31 +09:00
MacChaeger
6ac8266696 Support 4 player battles (#5266) 2019-03-18 13:37:27 +09:00
MacChaeger
6c486409f4 Fix spread move effect order (#5216) 2019-03-17 23:30:08 +09:00
Guangcong Luo
efa0af0ef1 Propagate errors through streams 2019-03-17 07:48:02 +09:00
Marty-D
39a8b4270e Fix Stealth Rock effectiveness during Delta Stream 2019-03-16 14:38:03 -04:00
Guangcong Luo
9073a5a8bf Improve Streams typing
When I originally wrote the Streams library, TypeScript-in-JS didn't
support generics. But now the library can have significantly nicer
typing, and so it now does.
2019-03-16 17:12:21 +09:00
Kirk Scheibelhut
0e1708bf9f Enable prefer-const and max 120 character lines for .ts files (#5292) 2019-03-16 07:14:04 +09:00
Guangcong Luo
84eebaad16
Fix sanity check in validTargetLoc 2019-03-15 10:26:54 +09:00
urkerab
2ea89698b0 Run effectiveness events even for string type (#5310) 2019-03-14 20:03:14 +09:00
Slayer95
f7982c390c
Remove |seed| messages
Redundant with randbats' public inputLog
2019-03-13 19:48:15 -05:00
Ivo Julca
150c451d0d PRNG: Fix logging of random team seeds in replays 2019-03-13 01:00:44 -05:00
Guangcong Luo
125ffcc633 Add NOT_FAIL, FAIL, SILENT_FAIL to battle
This replaces battle.NOT_FAILURE. The others aren't used anywhere yet,
but should in theory provide more readability than `null` and `false`.
2019-03-13 11:25:23 +09:00
Slayer95
7a7ad8453d Fix regressions in team generators (#5302) 2019-03-12 18:44:38 -07:00
Ivo Julca
37b537feea Fix long line warning 2019-03-12 00:35:51 -05:00
Ivo Julca
3686dcfe46 TS: ModdedDex#generateTeam() returns PokemonSet[] 2019-03-12 00:29:59 -05:00
Slayer95
5828a60663
Sim: Quit parsing on too many choices 2019-03-11 02:04:22 -05:00
Guangcong Luo
47111ac4c7 Make side#getChoice() show ultra where relevant
Fixes #5294
2019-03-10 13:52:30 -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
98072fff34 Make the switch command more flexible (#5288)
Make it take a case-insensitive nickname or species id,
something several of our test cases already rely upon.
2019-03-09 20:15:12 -06:00
Kirk Scheibelhut
9e7ba68fc4 Properly terminate BattleStream (#5283)
Fixes regression caused by #5210
2019-03-09 10:16:41 -06:00
Kirk Scheibelhut
e634d9a7b9 Cleanup Side & Dex after .ts refactor (#5273) 2019-03-09 10:14:11 -06:00
Kirk Scheibelhut
a8903d2563 Cleanup stat naming and types (storedStats, StatNameExceptHP) (#5274) 2019-03-09 09:53:11 -06:00
JetOU
85533ee3a0 Change forEach to for...of (#5269) 2019-03-08 11:24:58 -06:00
Kirk Scheibelhut
91993df916 Continue cleaning up sim/ after .ts refactor (#5267) 2019-03-08 07:29:04 -06:00
Kirk Scheibelhut
295f7c6c9f Switch hints to use double quotes everywhere (#5261)
Also, have `Battle#hint` take Side per @urkerab's suggestion.

Followup to #5258, no functionality changes.
2019-03-07 09:34:14 -06:00
Kirk Scheibelhut
dc5255f7c8 Fix Gen 1 Substitute + self damage behavior (#5263) 2019-03-06 16:12:32 -05:00
Kirk Scheibelhut
a04d4da992 Add more hints to Gen 1 & 4, migrate others to Battle#hint (#5258) 2019-03-06 11:24:47 -06:00
Kirk Scheibelhut
961b9882f5 Fix Gen 4 interaction between U-turn/Substitute/Intimidate (#5222) 2019-03-06 08:33:52 -05:00
Kirk Scheibelhut
247bb559d6 Fix minor Typescript bugs in dex-data.ts (#5255) 2019-03-06 07:12:26 -06:00
Kirk Scheibelhut
137aaf1a99 Fix Gen 1 Jump Kick to be like Hi Jump Kick (#5256) 2019-03-05 17:59:44 -06:00
Marty-D
0c2ad43e72
Fix per-side hints 2019-03-05 15:49:49 -05:00
Kirk Scheibelhut
6f82443101 Fix GSC Toxic interaction with Baton Pass/Heal Bell (#5226) 2019-03-05 13:28:01 -05:00
Guangcong Luo
ce5a954ae2 Use array spread instead of Array.from 2019-03-03 08:47:08 -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
5410514b3c Refactor sim/dex-data.ts to minimize @ts-ignore (#5214) 2019-03-02 15:03:43 -06:00
Guangcong Luo
5de019ac3d Fix fs.promises warning properly
The modern `__esModule` fallback isn't compatible with Node, and also
entirely unnecessary in practice.

The approach of disabling all the fallback code allows us to once again
`import * as fs`.
2019-02-28 11:49:48 -06:00
Marty-D
f108ec0fba Update Psych Up and Transform interactions with crit rate effects 2019-02-27 12:45:09 -05:00
Konrad Borowski
0d32e03159 Explicitly import readdirSync in dex.ts
This avoids ExperimentalWarnings caused by wildcard import of fs.
2019-02-27 17:17:27 +01:00
MacChaeger
16d078265b Run onModifyTemplate on rulesets (#5207) 2019-02-26 19:23:27 -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
MacChaeger
d764c52887 Don't add inactive rules as pseudoweathers (#5206) 2019-02-25 01:11:46 -06:00
Kris Johnson
da6f42c5c1 Change Untiered to (DUU) for Doubles (#5178) 2019-02-25 07:35:41 +04:00
The Immortal
bc1ff9fac4 Revert "Change (PU) to Untiered (#5170)"
This reverts commit d40fe510b4.
2019-02-25 06:26:21 +04:00
Marty-D
87cbe929cf
Make sure Transform copies the correct type 2019-02-23 22:28:03 -05:00
Kirk Scheibelhut
bb08599353 Fix field initialization ordering in Pokemon (#5204) 2019-02-23 19:58:51 -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
48ecdd492d Revert "Refactor getFormat pattern and ordering for speed (#5194)"
This reverts commit 9ce00664d8.

It doesn't account for bugs relating to Object.prototype
2019-02-23 17:08:41 -06:00
Kirk Scheibelhut
9ce00664d8 Refactor getFormat pattern and ordering for speed (#5194)
Even though 31c6a32 added caching to make this method less of a
hotspot, there's no reason to use a pattern which is an order of
magnitude slower (https://jsperf.com/pokemon-showdown-getEffect).
Also, rearranges Format to get checked first as pkmn.cc/optimize
finds it to be the most frequently accessed.
2019-02-23 21:59:36 +01:00
Kirk Scheibelhut
8ffd29daae Document remaining message types in SIM-PROTOCOL (#5196) 2019-02-22 23:19:26 -06:00
Kirk Scheibelhut
dc4bfbc4ae Fix some Typescript related TODOs (#5198) 2019-02-22 17:48:16 -06:00
Kirk Scheibelhut
f5991aa444 Refactor findEventHandlers further (#5193)
- rename `thing` when we know what it will be.
- simplify `resolveLastPriority`
- remove `findBattleEventHandlers` param given that its always this
- avoid multiple lookups of the same attribute

These functions related to finding events are very hot
(pkmn.cc/optimize) and microbenchmarks indicate TurboFan is unable
to extract out the constants for us. As a side benefit, there's less
`// @ts-ignore` required, and future optimizations will use the
constants anyway. More extraction can be done in findEventHandlers,
but that will be left for a future change where the need becomes
more obvious.
2019-02-21 15:19:26 -06:00
Guangcong Luo
93a76f9fa0 Refactor getRelevantEffects -> findEventHandlers
This fixes getRelevantEffects's massively confusing call structure.

Most parameters relating to bubbling up and down have been removed
entirely, and traversing the many possible event handler types is now
simply done outside the callers.

In addition, a lot of variables/functions have been renamed for much
better clarity.
2019-02-21 02:02:32 -06:00
Guangcong Luo
9742dd29e3 Split getRelevantEffectsInner
This is mainly a readability refactor.
2019-02-21 01:45:08 -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
Konrad Borowski
7481ccc680 Disallow 0 EVs even when EVs weren't sent (#5187) 2019-02-20 00:05:12 -06:00
Kirk Scheibelhut
de4ce7aebe Refactor Dex#getEffect + Dex#getEffectInner back to one method (#5182) 2019-02-19 21:04:01 -06:00
Kirk Scheibelhut
675497307e Optimize Dex#getEffect by caching the result. (#5181)
As outlined by pkmn.cc/optimize, this change should result in a ~30%
increase in Battle performance over repeated runs. Caching the
resultant effect is safe provided nothing mutates it.
2019-02-19 19:45:27 -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
urkerab
9195822c37 Fix transformInto so OMs still work (#5165) 2019-02-15 17:52:20 -06:00
Kris Johnson
d40fe510b4 Change (PU) to Untiered (#5170) 2019-02-16 03:07:51 +04:00
Guangcong Luo
b498bb222c Require object literal method shorthand 2019-02-11 18:14:09 -06:00
Guangcong Luo
c8d4463ffa Refactor formeChange
This fixes an obscure issue where we sent a formechange-to-self on
faint in certain obscure situations (apparently including Gen 4
Custap?)

In case anyone wants to investigate the details (this commit just
patches over some symptoms), the relevant replay is here:

https://replay.pokemonshowdown.com/smogtours-gen4ou-425031
2019-02-11 18:06:32 -06:00
Guangcong Luo
b7c252fbd6 Automatically end BattleStreams at end of battle
PS prefers to keep battle streams open (for `/evalbattle`) until
manually ended, but this is confusing some other users. We now
automatically end streams unless the `keepAlive` option is set.

Fixes #5157
2019-02-09 21:16:45 -06:00
Guangcong Luo
f4aa48083c Improve choice error messages
This should make choice errors clearer.
2019-02-08 16:06:09 -06:00
DubbleClick
0a864e84d8 Fix some LGTM alerts (#5139) 2019-02-05 20:34:32 -06:00
Marty-D
8ad7bacb6e
Fix Illusion when dragged out 2019-02-04 17:05:26 -05: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
Guangcong Luo
5b1e6d6595 Remove useless check 2019-02-02 20:21:35 -06:00
Guangcong Luo
472e27ac3d Remove useless check from pokemon.transformInto 2019-02-02 20:21:34 -06:00
Guangcong Luo
a7f188e7e7 Fix unnecessary ts-ignore 2019-02-02 09:15:11 -06:00
Guangcong Luo
8d57bd1b8c Remove useless param from pokemon.transformInto
Introduced in 743c85127c
2019-02-01 15:10:46 -06:00
urkerab
c9ac10d075 Other Metagames of the Month February 2019 (#5131) 2019-02-01 15:17:57 +04:00
Guangcong Luo
e6c04c0e55 Refactor some forEach to for..of 2019-01-26 00:40:00 -06:00
Marty-D
ca1fca0bf0
Fix rounding for healing from draining moves 2019-01-25 10:31:55 -05:00
Kris Johnson
05854a5798 Fix Crucibelle-Mega (#5109) 2019-01-17 07:58:30 -06:00
Marty-D
a0a81519ca Update Zen Mode 2019-01-16 13:42:18 -05:00
MacChaeger
2a60ad7589 Fix stomping tantrum vs. only Protect (#5081) 2019-01-15 22:03:54 -06:00
Konrad Borowski
f65ad5ab81 Don't mark Crucibelle-Mega as Gen6 (#5105) 2019-01-14 06:48:17 -06:00
urkerab
554060b0b5 Rename crash damage back to (High) Jump Kick (#5104) 2019-01-13 21:46:10 -06:00
Russell Jones
9735b1bd35 Apply modifiers even when they are exactly x1 (#5029) 2019-01-12 03:10:38 -06:00
Guangcong Luo
4f1fe41e96 Fix crash in getSpecies 2019-01-11 00:48:44 -06:00
Guangcong Luo
6424bd5e72 Forward battle process crashes to main process
This makes it so battle process crashes now appear in the Dev room,
instead of failing more silently.

This should also help them be easier to debug.
2019-01-07 20:15:17 -06:00
urkerab
7ec12e435c Ensure spread moves log a valid target (#5053) 2018-12-27 22:02:28 -08:00
Alexander B
ae2c557682 Faint Pokemon after every residual (#5048) 2018-12-27 11:10:34 -08:00
Alexander B
983bbeaf32 Disabling effects should disable every slot the move is in (#5047) 2018-12-27 11:07:39 -08:00
MacChaeger
2710633765 Magic Guard should block crash damage (#5042) 2018-12-25 09:08:00 -08:00
urkerab
d28561d2a5 Illusion should copy post-mega species (#5040) 2018-12-24 17:11:38 -08:00
Marty-D
d3392aa10e
Fix lack of target situations 2018-12-10 17:12:07 -05:00
Guangcong Luo
877c9feeeb Fix onEffectiveness event signature
I fixed `onAfterSubDamage` in the previous commit, but this one I left
for later.
2018-12-08 22:52:59 -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
d90ac63f4f Improve protocol documentation
Battle protocol documentation, instead of being strewn between
`PROTOCOL.md` and `sim/README.md`, is now in `sim/SIM-PROTOCOL.md`.

Also added:

- documentation for how to do searches and challenges
- documentation for packed team format

Fixes #5005
2018-12-01 19:29:50 -06:00
Guangcong Luo
2a8336e1bf Support --debug to simulate a battle in debug mode 2018-12-01 16:04:02 -06:00
Russell Jones
601c09e0af Fix edge cases in truncation (#5003) 2018-11-29 18:54:18 -06:00
Guangcong Luo
c752b327ca Fix no-target charge moves 2018-11-27 23:25:29 -06:00
Guangcong Luo
f7094909c2 Correctly truncate values
Numbers in Pokemon are 32-bit integers, which means that they're
truncated (rounded towards 0) as well as overflowing at 32-bit
limits.

We've been using `Math.floor`, but JavaScript has many functions for
coercing to 32-bit integers which already do everything we want. So
this commit changes to doing that.

It's done in a new function Battle#trunc which is overridden in
Custom Games where players might prefer to play without integer
overflow issues.

(Custom Game _still_ needs a UI rework, blah blah Preact...)

Fixes #4820

Closes #4962
2018-11-27 22:22:35 -06:00
Guangcong Luo
8488835bba Cap Speed at 10000 for Gyro Ball / Electro Ball
This is a real mechanic according to @SadisticMystic
2018-11-27 22:22:34 -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
Guangcong Luo
966cee39df Fix comment indentation in prng.js 2018-11-27 22:22:33 -06:00
Marty-D
7a439d57cb
Make end-of-battle boost check less potentially dangerous 2018-11-22 08:46:17 -05:00
Kris Johnson
5b2d76d75d Add Pokemon Let's Go! (#4967) 2018-11-19 16:19:19 -06:00
Guangcong Luo
3a8add5c4b Remove [msg] parameter of -immune
(It's unnecessary, being the default message for it.)
2018-11-10 12:31:21 -06:00
Guangcong Luo
edbdbbcb51 Partially revert dex-data self-assignment changes
The `|| undefined` code is kinda bugged.
2018-11-04 09:09:09 -06:00
Guangcong Luo
111c47b2b8 Fix format.rated typing
Apparently its original typing was `undefined | false`, not `boolean`.
2018-11-01 10:37:08 -05:00
Alexander B
34c3096d6b "But it failed!" messages should not reveal the target (#4944) 2018-11-01 09:41:04 -04:00
Kris Johnson
1a729f65a3 Add OMotM, LCotM, and RoA Spotlight November (#4946) 2018-11-01 15:45:32 +04:00
Guangcong Luo
1de5e74a9a Move zBrokeProtect to ActiveMove 2018-10-28 05:27:22 -05:00
Guangcong Luo
68e81c8c72 Rename hasSTAB to forceSTAB
This better describes what it actually means.
2018-10-28 05:27:22 -05:00
Guangcong Luo
24571ea603 Fix misc errors found by LGTM 2018-10-28 05:04:30 -05:00
bgsamm
9569dee47f Fix Assurance never doubling when called from other moves (#4905) 2018-10-18 14:54:39 -04:00
Guangcong Luo
2f0be453cc Gen 3: Fix Pressure PP tracking
This commit makes it so players are always informed about their own
Pressure activations. This fixes Pressure PP tracking for players.
PP tracking for spectators will still be wrong; there's no fix for
that.

Fixes https://github.com/Zarel/Pokemon-Showdown-Client/issues/766
2018-10-16 21:00:03 -05:00
Marty-D
dc92d302d7
Fix typo in hurtBy refactor 2018-10-13 10:30:35 -04:00
bgsamm
a68f6276e9 Refactor lastAttackedBy to hurtBy (#4894) 2018-10-11 10:23:38 -05:00
Kris Johnson
c4a41ffd75 Mix and Mega: Fix Illusion (#4904) 2018-10-11 09:37:22 -04:00
Guangcong Luo
affcad7873 Improve documentation of isZ vs isZPowered
move.zPowered is renamed move.isZPowered. It's now documented in JSDoc
exactly how it differs from move.isZ.

This commit includes several minor refactors to Z-move mechanics,
including a bug fix: Z-boosted called Weather Ball is now correctly
typed.
2018-10-10 18:44:05 -05:00
Guangcong Luo
ecb27edb4d
Introduce ActiveMove; make some types read-only (#4902)
The types Template, Move, Ability, and Item are now read-only. This
should guard against accidental writing to types that shouldn't be
written to.

A new type, ActiveMove, has been introduced. Like it sounds, it's
used for moves that are currently actively being used. A lot of
attributes that are only relevant to active moves, such as
`hasBounced`, are now only available on ActiveMove, not on Move.
ActiveMoves are mutable, unlike Moves.

getMoveCopy has been renamed getActiveMove, to better reflect its
role. `isCopy` has been deprecated, and distinguishing Moves from
ActiveMoves is now done by `typeof move.hit === 'number'` where
necessary.

ActiveMoves now internally track which hit of a multihit move
they're on, in move.hit, so move.hit doesn't need to be manually
incremented by Triple Kick and Parental Bond anymore.

move.hasParentalBond has been replaced by a more generic
move.multihitType.
2018-10-10 16:04:35 -05:00
Alvin Ho
89e42c946a Fix Autotomize interaction with forme changes (#4893) 2018-10-08 17:49:31 -04:00
Kris Johnson
b6094806da Support ZU in the teambuilder (server-side) (#4888) 2018-10-07 15:56:36 +04:00
Quinton Lee
94016f6218 Update Typescript to 3.1 (#4879) 2018-10-05 04:02:54 -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
HoeenHero
3c500c06a6 Validator: Validate Hidden Power Type (#4854) 2018-10-03 21:14:55 -05:00
Quinton Lee
f12b09f8dd
Dex: fix unbanning things banned by format + ruleset
This is mainly an issue for formats in which Pokemon are banned by name but also by tier in the inherited banlists.
2018-09-29 15:34:02 -05:00
The Immortal
5df0a02fcb Revert "Implement Illusion Level Mod"
This reverts commit 60075830b6.
2018-09-24 15:54:33 +04:00
Guangcong Luo
60075830b6 Implement Illusion Level Mod
Normally, Illusion copies everything except the level, so if Zoroark is
a different level from the pokemon it's copying, it's very obvious that
it's a copy. This isn't a problem normally (because everyone is 50 or
100), but in randbats, it's a big tell, and makes Zoroark weaker than
it's supposed to be.

And, unrelatedly, everyone thinks it's a bug even though it's not.
2018-09-21 16:33:17 -05:00
Guangcong Luo
bcefeb2925
Fix other typo in Sim Readme 2018-09-17 20:28:50 -05:00
Guangcong Luo
50324e5800
Fix typo in Sim Readme 2018-09-17 20:24:09 -05:00
Marty-D
c494ac362a
"Fix" the second turn of called multi-turn moves
TODO: Not this. Calling moves that select multi-turn moves currently use the target of the calling move on the second turn, which is probably the user and would otherwise fail if not for being re-targeted again. Maybe store a locking move's randomly selected target in a Pokemon or move volatile instead.
2018-09-08 12:05:55 -04:00
Guangcong Luo
ae03a15c74 Fix misc bugs discovered by LGTM 2018-09-06 02:31:12 -05:00
Guangcong Luo
0f2d590e6e
Update SIM README MOVESLOTSPEC table 2018-09-03 21:12:45 -05:00
Guangcong Luo
a96e804c87
Improve Sim README
- Remove reference to "new API" vs "old API"
- Fix `TARGETSPEC` table Markdown
2018-09-03 21:09:28 -05:00
Marty-D
733ea72d4f Make a move fail if the target is the user and it's not self-target 2018-09-03 11:24:38 -04:00
Marty-D
3933cf5c7b
Fix past gen Pursuit knockouts on the switch 2018-09-01 09:31:45 -04:00
Marty-D
5271a3c44f Gen I: Fix PP underflow for binding moves 2018-08-25 15:07:50 -04:00
Marty-D
009515fafe
Validator: Fix past gen egg move validation
Also fixes #4815
2018-08-21 12:17:36 -04:00
Marty-D
c0d9077ce5
Fix forced Struggle targeting 2018-08-07 22:33:33 -04:00
littlefoot22
58e9a8923e Fix Rollout / Ice Ball target locking (#4796) 2018-08-07 21:54:35 -04:00
MacChaeger
82c792f82c Update to TypeScript 3.0.1 (#4710) 2018-08-07 03:27:28 +09:00
urkerab
09319ff399 Followup to #3211 to ignore Z-status moves (#4787) 2018-08-05 05:02:53 +09:00
Marty-D
69733318ba
Correct end-of-battle boost check 2018-08-03 13:57:58 +00:00
urkerab
d8ebd62c87 Other Metagames of the Month August 2018 (#4782) 2018-08-03 13:49:06 +04:00
urkerab
66f398c413 Set gender when validating restricted sources (#4775) 2018-08-03 09:53:51 +09:00
Marty-D
88d02ef8b5 Deal with illegal move combinations
Until the validator can handle them
2018-07-29 18:18:29 -04:00
littlefoot22
ecdd0f8165 Prevent effects from changing stats after final Pokemon is KOed (#4777) 2018-07-29 08:55:34 -04:00
NoahWhite1115
ee6532d0ce Fix Illusion to display Users level instead of Illusions level (#4764) 2018-07-20 15:27:53 +09:00
Guangcong Luo
7ec8bb7bcb Rename getData to getRequestData
Part of an ongoing effort to get rid of ridiculously vague
function/variable names.
2018-07-20 14:40:40 +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
Quinton Lee
ed01c527ba
Validator: allow custom rules to unban unreleased items and moves 2018-07-03 11:29:38 -05:00
Marty-D
538ac5ca55 Fix protection interaction with Z-Powered Z-Moves 2018-06-30 16:34:35 -04:00
Marty-D
f259d43987 Fix Nightmare removal properly 2018-06-09 18:17:58 -04:00
Marty-D
e3416dd54a
Fix some formechange bugs
- Allows Rayquaza to visibly Mega Evolve with no item again
- There's no reason to do complete forme changes in Gen 1 or 2
2018-06-09 15:28:57 +00:00
Marty-D
691ce185b0 Add Shiny Zygarde event 2018-05-31 22:02:02 -04:00
MacChaeger
b082705569 Transform should ignore Roost's effects (#4698) 2018-05-28 13:17:06 -04:00
MacChaeger
df20e45f92 Camomons: Fix permanent forme changes causing apparentType to desync (#4693) 2018-05-26 21:11:58 -05:00
MacChaeger
22ad90d3ff Camomons: Modify the template unless the Pokemon is transforming (#4688) 2018-05-25 19:27:47 -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
a85932f75b Actually fix Camomons (#4685) 2018-05-22 00:54:14 -05:00
MacChaeger
1be208916a Improve Stomping Tantrum interaction with Protect (#4680) 2018-05-21 22:39:30 -04:00
MacChaeger
68783537ca Fix type display in camomons after switching out (#4683) 2018-05-21 21:27:07 -05:00
MacChaeger
e3174ebc02 Fix type display in Gen 7 metas (#4655) 2018-05-21 17:27:23 -05:00
MacChaeger
a4a3d31b7c Properly support Pokemon with no ability (#4678) 2018-05-20 22:13:24 -05:00
Ivo Julca
c3e752c87f Fix leak of trapped status if no healthy Pokémon can switch in
Only request data needs this fix, as choice validation is already safe from this issue.
2018-05-19 15:09:41 -05:00
MacChaeger
dbb3d1a053 Fix failure messages of nonstandard healing moves (again) (#4675) 2018-05-18 15:47:46 -05:00
Marty-D
b450fce65e
Fix Shell Bell damage tracker 2018-05-14 13:34:54 +00:00
Marty-D
d5f9b427de
Validator: Check Secret Sword Keldeo-Ordinary origin 2018-05-06 10:35:21 -04:00
Quinton Lee
cf50a3d642 Typescript the rest of mods/ (#4588) 2018-05-05 14:56:45 -05:00
Marty-D
6bf35eeb2c Rename BLs 2018-04-24 20:29:06 -04:00
urkerab
8d82a3d373 Show only one tier validation problem (#4615) 2018-04-21 21:40:01 -05:00
asgdf
40280a12c0 Fix name of Arceus/Silvally templates (#4603) 2018-04-18 17:32:10 -05:00
asgdf
d5c9a241f3 Fix /dt always displaying normal forme of Arceus/Silvally (#4600) 2018-04-17 07:57:13 -05:00
Guangcong Luo
a1a88999ad Support Doubles in battle-stream-example.js 2018-04-15 17:08:08 -05:00
Guangcong Luo
467b545496 Add example code for using the Sim API 2018-04-15 06:10:08 -05:00
MacChaeger
95e0f30027 Spite: Show actual PP reduction (#4590) 2018-04-15 01:40:49 -05:00
Kris Johnson
61076ec11f Change all Smogon links to https (#4587) 2018-04-13 12:24:42 -04:00
urkerab
0ff06a45ee Properly check for battle before logging crash (#4583) 2018-04-13 08:04:52 -05:00
Quinton Lee
acd812c71e Typescript gens 1-4 (#4556) 2018-04-11 22:11:25 -05:00
Guangcong Luo
925706083e
Sim readme: Fix choice spec 2018-04-06 14:15:07 -05:00
Quinton Lee
b45d595519 Update Typescript to 2.8 (#4532) 2018-04-05 17:33:35 -05:00
MacChaeger
27afe1b6b8 Gen VI-VII: Transform should copy Focus Energy (#4546) 2018-04-05 09:19:43 -04:00
Marty-D
3049e0e172
Fix rated/debug battles 2018-03-28 23:58:35 -04:00
Andi Wang
6621b84efa Gen IV: Fix Disable/Encore interaction with switching effects (#4519)
Specifically, Healing Wish/Lunar Dance/Baton Pass/U-turn.
2018-03-27 22:30:23 -04:00
Quinton Lee
c799393710 Typescript data/ and config/formats (#4513)
Also removes Battle Factory methods accidentally re-added in d0a4a689a7
2018-03-26 09:50:51 -05:00
KrisXV
3bf1aeb79f Refactor for...length to for...of where applicable (#4516) 2018-03-24 14:47:40 -07:00
Marty-D
dc3f9bd0ab Fix Sky Drop interaction with Follow Me/Rage Powder/Snatch 2018-03-16 10:14:47 -04:00
Matthew Glazar
81208685d1 Refactor some code to use sample
Mechanically refactor code which uses PRNG#random to calculate a random
array index to use PRNG#sample instead.
2018-03-12 05:53:33 +09: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
strager
5a5b4182a3 Delete dead code (#4477)
According to `git grep getResidualStatuses`, the
Battle#getResidualStatuses function isn't referenced anywhere. Delete
the definition of that unused function.
2018-03-10 14:44:30 +09:00
Matthew Glazar
df5988bacf Refactor some code to use randomChance
Mechanically refactor code which uses PRNG#random for booleans to use
PRNG#randomChance instead.

Take advantage of the following properties:

    random(x) < y        is equivalent to   randomChance(y, x)
    random(x) <= y       is equivalent to   random(x) < (y + 1), i.e. randomChance(y + 1, x)
    random(x) >= y       is equivalent to   !(random(x) < y), i.e. !randomChance(y, x)
    random(x) > y        is equivalent to   random(x) >= (y + 1), i.e. !randomChance(y + 1, 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)
    Boolean(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
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
strager
5d08426faa Optimize no-op effects (#4460)
Various functions call ModdedDex#getEffect with null, undefined, or an
empty string. For example, in the common case, Battle#getWeather calls
getEffect with an empty string. In these cases, getEffect basically
returns the same object each time: a PureEffect indicating that no
effect with the given name exists.

Creating the dummy PureEffect is expensive and puts pressure on the
JavaScript garbage collector. Memoize the creation in getEffect to
improve performance.

(As a bonus, special-casing null, undefined, and empty strings also lets
us drop some noisy truthiness checks in getEffect.)

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

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:
    16.53s user 0.35s system 120% cpu 13.994 total
    16.43s user 0.34s system 120% cpu 13.918 total
    16.54s user 0.32s system 120% cpu 14.009 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:27:55 +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
Guangcong Luo
d9bf6742ff
Sim readme: Improve stream-consuming example code 2018-03-02 03:13:59 +09:00
urkerab
586861eb79 Fix Endless Battle Clause messages (#4437) 2018-02-26 17:12:16 +08:00
The Immortal
101099b27e Fix Endless Battles Clause message 2018-02-23 21:05:06 +08:00
Guangcong Luo
e14bdfca36 Fix canceling switches against Wobbuffet in Gen 2 2018-02-18 19:10:40 +09:00
urkerab
77c4e32dba Overriding a template should not unban the Mega (#4423) 2018-02-18 16:27:02 +09:00
Guangcong Luo
add2f2efbb Don't inputlog >version if Git isn't installed 2018-02-14 12:54:37 +09:00
Guangcong Luo
2ba6a770fe Validator: Fix message for Hidden Abliity checking
Also allow passing "HA" or "Hidden" to /learn, to do some basic
checking for Hidden Ability legality. This doesn't currently do full
validation - event abilities aren't checked, for instance.
2018-02-13 22:07:58 +09:00
Guangcong Luo
643b364055 Fix "maybe trapped" detection for ability bans 2018-02-13 13:34:42 +09:00
Guangcong Luo
8b19a546b8 Fix chainbreeding validator 2018-02-01 21:06:37 -06:00
Guangcong Luo
fa057d86bf Validator: Fix past-gen-only-move error message 2018-02-01 20:59:53 -06:00
Guangcong Luo
c91bd2f831 Crash battles more gracefully 2018-02-01 17:44:11 -06:00
Marty-D
2b18b09155
Fix crash in Gen 4 Transform 2018-02-01 16:29:10 -05: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
KrisXV
a4cf9f3ab1 Fix Mimikyu-Busted-Totem's tiers (#4390)
handled in https://git.io/vN7tU
2018-01-31 11:30:48 -06:00
Guangcong Luo
c4d3b1f80f Improve move validation phrasing 2018-01-30 11:07: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
b58e08e215 Improve Sim documentation 2018-01-28 22:04:41 -06:00
Guangcong Luo
4af43bd698 Document choice specifications 2018-01-28 21:56:37 -06:00
Guangcong Luo
1c62891008 Document new Sim API 2018-01-28 21:23:06 -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
a0da191024 Improve ./pokemon-showdown commands
./pokemon-showdown help

will now display all the possible ways to use PS on the command-line,
of which there are several new ones:

    ./pokemon-showdown validate-team
    ./pokemon-showdown unpack-team
    ./pokemon-showdown pack-team
2018-01-28 21:06:49 -06:00
Guangcong Luo
b9aba16b52 BattleStream: Refactor message types
The previous complement of way too many message types:

- update, winupdate, sideupdate, request, score, log

are now only:

- update, sideupdate, end

`score` was removed in the previous commit, and this commit adds a new
message type `end`. `end` replaces the previous `log`, and also
contains the data for `winupdate` and `score`.

`request` was also folded into `sideupdate`.
2018-01-28 21:06:49 -06:00
Guangcong Luo
6f2b1c0cd8 Battle protocol: Remove score message
score sending is now combined with the log message.
2018-01-28 21:06:49 -06:00
Guangcong Luo
f756b22dc7 Implement |bigerror|
Battles now send their errors using |bigerror|, which requires less
escaping and also correctly reports errors.
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
urkerab
cdb12bd696 Fix last item handling (#4383) 2018-01-28 20:05:44 -06:00
Guangcong Luo
de7c58aad7 Validator: Fix egg move checking 2018-01-28 15:37:18 -05:00
Guangcong Luo
b19e1b819e
Fix typo in previous commit 2018-01-28 13:30:00 -06:00
Guangcong Luo
bf67a69606
Team Validator: Fix babyOnly check 2018-01-28 13:29:03 -06:00
Guangcong Luo
cd946a0a41
Correctly refactor Mew/Celebi checks 2018-01-28 12:24:42 -06:00
Marty-D
f0e180db0b
Validator: Refactor Mew/Celebi checks 2018-01-28 18:20:34 +00:00
Marty-D
a9d9e199b3
Validator: Add VC level and Ball requirements 2018-01-28 17:17:30 +00:00
Guangcong Luo
4f64074b6c Improve evolution move validation
This is specifically made to fix Nasty Plot + Surf Raichu.

Specifically, prevo moves are no longer compatible with evo event
moves.

Other incompatibilities (specifically, modern prevo moves with old-gen
evo moves) will be harder to fix, unfortunately.
2018-01-28 10:37:43 -06:00
Guangcong Luo
74143b652d Workaround for Celebi VC validation 2018-01-27 22:38:56 -06:00
Marty-D
27dc108d6c
Fix forme tiering in past gens 2018-01-27 04:22:50 +00:00
Guangcong Luo
a22d1d7b20 Fix doublesTier
Should now correctly display NFE and LC tiers.
2018-01-26 18:40:24 -06:00
Guangcong Luo
c9b075ce1f Fix Doubles tiers 2018-01-26 14:26:09 -06:00
KrisXV
aefa8c986a Add doublesTier (#4339) 2018-01-26 14:23:38 -06:00
Dan Huang
9c37960ab6 Use PRNG in sim/ files (#4365) 2018-01-24 12:27:07 -06:00
HoeenHero
f59912a56a Fix /evalbattle (#4372) 2018-01-23 19:25:18 -06:00
urkerab
f0c93655c4 Fix Protective Pads mechanics (#4362) 2018-01-23 11:19:07 -05:00
Guangcong Luo
aae46ffd46 Support checkLearnset in format rules
Fixes #4356
2018-01-20 02:05:21 -06:00
Guangcong Luo
fcfd7c9c25 TypeScript: Add otherFormes to Template 2018-01-19 23:50:22 -06:00
Guangcong Luo
327b004b74 Better support for destroying streams 2018-01-18 04:14:58 -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
Marty-D
6bce102f66
Gen VII: Update critical hit rate 2018-01-17 05:00:13 +00:00
urkerab
297af3b111 Allow formats to override checkLearnset (#4341) 2018-01-16 04:16:48 -06:00
urkerab
99d682ca26 Change lastMove from a string to a Move (#4298) 2018-01-03 11:54:35 -06:00
The Immortal
5d9a98f061 Fix Alphabet Cup validation 2018-01-03 18:23:03 +08:00
Kris Johnson
c30d5baa0e Fix formats.noLearn validation (#4303)
Also i changed the for loops that i had a stroke over in TI's commit to
for...of loops

@theimmortal
2018-01-03 03:29:38 +08:00
The Immortal
9cdb80f28a Fix Alphabet Cup validation 2018-01-02 22:37:32 +08:00
Guangcong Luo
334103f284 Implement 1000-turn limit for Endless Battle Clause 2017-12-29 18:18:45 -05:00
urkerab
59616d8eb7 Ban Mega formes by name (#4292) 2017-12-28 20:03:30 -06:00
urkerab
4cd0a0e389 Allow formats to reorder all six Pokémon (#4281) 2017-12-27 05:51:11 -06:00
The Immortal
c916f2ae9d Remove remnant from old OMotM 2017-12-27 13:20:03 +08:00
CheeseMuffin
def2697f33 Finish typescripting chat.js (#4277) 2017-12-24 00:45:49 -06:00
urkerab
2873bd8366 Remove an unused parameter from eatItem and useItem (#4210) 2017-12-23 21:36:51 -06:00
Guangcong Luo
0a06bb97ef Better support multiline responses in /eval 2017-12-23 21:32:16 -06:00
Guangcong Luo
b9e9a2b7c4 Simplify Promise support in /eval 2017-12-23 21:31:42 -06:00
Guangcong Luo
b8be497142 Improve /eval output 2017-12-19 21:30:47 -05:00
Quinton Lee
361b4d03cc
Fix crash in Dex.getFormat 2017-12-18 19:25:56 -06:00
Guangcong Luo
9542ae2444 Include chat/etc in battle logs 2017-12-18 18:32:58 -06:00
MacChaeger
8d571be74e Fix certain Abilities not being overwritten by most forme changes (#4245) 2017-12-14 11:45:12 -05:00
urkerab
dc3945ff86 Protect should not affect Clangorous Soulblaze's other target (#4237)
Closes #4232
2017-12-11 09:02:24 -05:00
Guangcong Luo
b9e532426a Hardcode VC Entei/Raikou/Suicune validation 2017-12-10 20:03:21 -05:00
Marty-D
439e9654de
Add Z-Moves bypassing protection message 2017-12-10 16:03:43 -05:00
Guangcong Luo
7d9fff71bd Improve custom format performance
It turns out, battle.getFormat() is run once per invocation of
battle.runEvent(), which is a lot.

Especially with the new rule validator.

...It's cached now.
2017-12-10 02:01:19 -05:00
Guangcong Luo
1a68294d6a Fix VC Celebi check
I messed up the capitalization, but more importantly Marty apparently
already implemented this another way.
2017-12-09 23:19:01 -06:00
Guangcong Luo
52f34f42f5 Improve VC move validator 2017-12-09 21:11:20 -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
Spandan Punwatkar
a1270cac7a Fix Ability Aliases (#4228) 2017-12-09 01:48:05 -06:00
Guangcong Luo
e0490ef41f Mark custom rules as non-searchable
This is just a safety precaution that may simplify some future code; we
don't currently allow custom rules in the matchmaker at all.
2017-12-09 00:25:16 -06:00
Guangcong Luo
5260bf6ac3 Fix unreleased template checking
The old code, for allowing unreleased pokemon if they were obtainable
by breeding, was a workaround for a very specific case which as far
as I can tell is no longer necessary.

In the future, a template should just not be marked as unreleased if
it's available by breeding.
2017-12-08 22:41:53 -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
801883c53a Implement Stomping Tantrum (#4175) 2017-12-07 18:36:19 -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
Kris Johnson
06de38fe6d STABmons: Fix Necrozma type inheriting (#4214) 2017-12-05 15:49:07 +08:00
Guangcong Luo
08d079037d Pass source effect of switches to client
We are now tracking source effects for switch actions, if they're
initiated by effects such as U-turn or Baton Pass. This will lead
to better messages client-side.
2017-12-04 19:14:13 -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
Marty-D
dc7c46b427 Update Ability-changing effects
Fixes #3230, closes #3245
2017-12-02 11:37:36 -05:00
Guangcong Luo
f97ab41cb6
FIx bug 2017-12-02 10:19:18 -06:00
Guangcong Luo
70a5f3cf6d Fix Pursuit KO canceling a switch in Gen 3 2017-12-02 08:27:44 -06:00
Guangcong Luo
1ac2745c3e Refactor Pursuit hack
Pursuit no longer uses `moveThisTurn`, but rather `willMove`, which
involves significantly fewer Pursuit hacks.
2017-12-01 15:59:13 -06:00
Guangcong Luo
461706baa5 Correct Gen 2 faint mechanics
Described by Marty here:

https://www.smogon.com/forums/threads/gen-3-on-ps-final-fixes.3527268/#post-5989318
2017-12-01 15:59:03 -06:00
Guangcong Luo
ba9a41c669 Skip switches in gen 2-3 upon faint 2017-12-01 13:06:11 -06:00
Guangcong Luo
f4e535bbd6 Enforce consistent key spacing
This was previously not enforced because we used `:1` in too many
places, but those places seem to all be refactored out at this point.
2017-12-01 08:16:23 -06:00
Guangcong Luo
9bdf674d5f Refactor more tables to arrays
See #4079

Now we're just missing oldgens.
2017-11-30 19:40:16 -06:00
Guangcong Luo
8473c3f4fa Improve test engine
New functions:

battle.makeChoices([side 1], [side 2]);

Intended to be a replacement for the previous .choose/.commitDecisions
API.

If we can get all the test code on it, we can maybe finally actually
deprecate LEGACY_API_DO_NOT_USE.

It's now used in Healing Wish, where I think it makes a very readable
test.
2017-11-30 10:56:01 -06:00
Guangcong Luo
97d773226a Support switching to pokemon by name 2017-11-30 10:56:01 -06:00
Guangcong Luo
80c9a7c5a1 Fix Healing Wish properly
Broken in #4120
2017-11-30 10:39:21 -06:00
urkerab
53ef680bcf Put Rockruff-Dusk's template into the cache (#4185) 2017-11-26 10:02:46 -06:00
urkerab
aea93f25db Fix set name in validation reasons (#4181) 2017-11-25 19:08:06 -06:00
CheeseMuffin
0b3e09b06a Fix generation for totem mons (#4177) 2017-11-24 18:56:33 -06:00
urkerab
802db51ea8 Use ModifyMove to handle Photon Geyser mechanics (#4179) 2017-11-24 18:54:56 -06:00
Guangcong Luo
022839335f Add Gen 2 Virtual Console moves 2017-11-24 18:51:32 -06:00
MacChaeger
b0ba793257 Fix Totem tiers (#4176) 2017-11-24 13:55:47 -05:00
Marty-D
ff16589722 Correct Photon Geyser mechanics 2017-11-23 22:47:20 -05:00
urkerab
c7f9aa009c Fix spread Z-Moves interaction with protection (#4163) 2017-11-18 14:41:47 -05:00
Marty-D
77039602e3
Release Hidden Ability Orange and White Flower Florges line
Thanks, Kaphotics!
2017-11-18 09:15:41 -05:00
Guangcong Luo
e716e9edc7 Implement Ultra Burst 2017-11-17 00:01:09 -06:00
Guangcong Luo
e25eeb9eb0 Correctly validate Rockruff-Dusk 2017-11-16 21:45:24 -06:00
Kris Johnson
f2caefba9b Ultra Sun and Ultra Moon update (#4151) 2017-11-16 20:34:43 -06:00
MacChaeger
6f82808c34 Fix clearing volatiles (#4120) 2017-11-12 22:09:52 -05:00
Guangcong Luo
b9ea17e014 TypeScript: Correctly mark args as optional 2017-11-12 01:57:53 -06:00
Guangcong Luo
9a1cb36882 Support three arguments in addVolatile 2017-11-12 01:22:31 -06:00
Guangcong Luo
6dc65e48cf MODULE_NOT_FOUND is now ENOENT in Node 8 2017-11-09 14:43:43 -06:00
Guangcong Luo
56190af620 Fix up TypeScript errors
Also suppress TypeScript validation of various files we don't want
validated right now.
2017-11-08 01:23:04 -06:00
Guangcong Luo
e377d69395 Fix core team-validation intersection check 2017-11-05 00:11:51 -07:00
Guangcong Luo
7904e7791b Fix Gen 2 Hidden Power IV validation 2017-11-05 00:11:51 -07:00
Kris Johnson
4c5518320b Use standard formatting for STABmons move checking (#4123) 2017-11-04 13:54:54 -07:00
Guangcong Luo
c5d438b7be Fix TypeScript error in validator
...we should probably add TypeScript to CI sometime soon...
2017-11-04 12:14:47 -07:00
Kris Johnson
475e70b822 STABmons: Fix move validation error (#4121) 2017-11-03 15:42:37 +08:00
Guangcong Luo
17015189f1 Don't crash when validating impossible moves 2017-11-02 14:35:26 -05:00
Kris Johnson
c7e11d5469 Fix error in STABmons (#4118) 2017-11-02 14:02:18 -05:00
Guangcong Luo
011528bd5a Fix Hidden Ability validation
Previously, a mix of past-gen and modern event sources for a move would
confuse the validator. This case is now properly handled.
2017-11-02 13:36:05 -05:00
Guangcong Luo
528a6745cb TypeScript: Use GenderName alias in Template 2017-11-02 13:00:41 -05:00
Guangcong Luo
fed55531f1 Make the dexes table null-prototype
Fixes a 'constructor' issue in Dex.mod()
2017-11-02 13:00:40 -05:00
Guangcong Luo
e8d245f97b Support Pomeg Glitch 2017-11-02 13:52:24 -04:00
whales
c28a387a2f Fix Dex#getType (#4116) 2017-11-02 10:29:49 -04:00
urkerab
d86b272145 Other Metagames of the Month November 2017 (#4108) 2017-11-02 14:44:21 +08:00
Guangcong Luo
2d9fc18280 TypeScript sim/team-validator.js 2017-11-02 00:15:04 -05:00
Guangcong Luo
0e728281e6 Move team-validator to sim/team-validator 2017-11-01 05:22:37 -05:00
Guangcong Luo
6a6bc18d44 Work around ESLint 4.1.0 trailing spaces bug 2017-10-23 09:22:30 -05:00
Guangcong Luo
246dfa1da3 Refactor in-object-literal to array-includes (#4079)
Previously, if we wanted to test if A was either 'B' or 'C', we would use
the pattern:

    A in {B:1, C:1}

I actually don't know how common this pattern is; I just started using
it because I was tired of typing `A === 'B' || A === 'C'` all the time.
I never really liked it, though; the `:1` part made it kind of
blatantly a hack.

I did some testing and `['B', 'C'].includes(A)` is overall faster.

(A switch statement is around 20x faster still, but who wants to type
that much code?)

Anyway, the new standard is

    ['B', 'C'].includes(A)

Something something progress!
2017-10-23 09:19:15 -05:00
Marty-D
97bb5af755 Fix crash in confusion damage 2017-10-21 09:28:40 -04:00
Guangcong Luo
c640a69ffc Don't send Rated text for normal rated battles 2017-10-21 03:43:12 -05:00
Marty-D
312f93c47c Revert "Fix confusion interaction with HP-checking items (#4045)"
This reverts commit
6651c5dadb.
2017-10-20 21:05:49 -04:00
Quinton Lee
a0b8228592 TypeScript: Improve Sim typing (#4069)
Also improves intellisense for Visual Studio and Visual Studio Code.
2017-10-20 07:53:26 -05:00
Guangcong Luo
a207147a48 Support custom rated battle message
Currently, the bold circled "Rated" marker in battle logs is only used
for rated battles. This change also supports using them to mark tour
battles.
2017-10-18 05:41:03 -05:00
QuiteQuiet
6651c5dadb Fix confusion interaction with HP-checking items (#4045) 2017-10-17 09:26:27 -04:00
Guangcong Luo
110b6a5511 Implement tiebreaker
This is the tiebreaker used for timeouts in Gen 6-7 (I think), but it's
not currently used anywhere.
2017-10-08 03:39:58 -05:00
Ben Davies
77b4c77864 Dex: constructor is not a format alias 2017-09-18 21:20:03 -03:00
Guangcong Luo
6b870967e0 Fix bug in support for >10 pokemon in Team Preview 2017-09-09 20:31:54 -04:00
Guangcong Luo
737d9dbba0 Support more than 10 Pokemon in Team Preview 2017-09-09 20:19:24 -04:00
Guangcong Luo
066d970b54 Fix >6-pokemon Custom Games 2017-09-09 19:41:55 -04:00
Guangcong Luo
b42a322ecb Support over 6 Pokemon in Custom Game 2017-09-09 18:25:26 -04:00
Guangcong Luo
1e87e989cc Hacky fix to the 6-move bug 2017-09-08 18:20:08 -04:00
Guangcong Luo
057e6b4e89 Alias formats without gen number to Gen 7 formats
Closes #3785
2017-09-08 10:27:20 -04:00
urkerab
bd6743bbe7 Reveal own Ability in Gen 7 (#3969) 2017-09-06 23:21:19 -04:00
Guangcong Luo
25d0079b4f Sim: Fix Berries not activating after weather
Previously, Berries would not activate after weather damage and before
other residual damage/healing.

According to: https://www.youtube.com/watch?v=FRI5PSekhR4

They should activate then. More research is needed to determine what
other situations Berries should activate but don't.
2017-09-05 07:00:55 -04:00
Guangcong Luo
7785375d14 Sim: Faint-switch in fainted pokemon Spe order
Now, if multiple Pokemon fainted in one turn, they will be switched
out in Speed order (of the fainted Pokemon).
2017-09-05 06:53:56 -04:00
Ghoulean Algebra
f067ee13ee Gen II: Fix Hidden Power's power calculation (#3925)
Before : HP_Power=(5*(v+2w+4x+8y)+min(Z, 3))/2 + 31 
After: HP_Power=(5*(v+2w+4x+8y)+(Z % 4))/2 + 31 

where 
* v is 1 if SpcIV>=8; otherwise 0, 
* w is 1 if SpeIV>=8; otherwise 0, 
* x is 1 if DefIV>=8; otherwise 0, 
* y is 1 if AtkIV>=8; otherwise 0, 
* Z = SpcIV

See: 
http://tasvideos.org/forum/viewtopic.php?p=361950#361950
https://github.com/pret/pokecrystal/blob/master/battle/hidden_power.asm#L52
2017-08-27 20:22:05 -04:00
Quinton Lee
0c94145c40 Fix remaining custom format issues (#3910)
Rules for custom formats are once again sanitized and can be passed
around more easily by attaching them to the format's id.

Fixes:
- "Rule:" being required to add or remove a rule
- ruleset changes not being shown in battles
- the display of custom rules being affected by user input
- custom formats being broken by /hotpatch formats
2017-08-23 22:27:09 -07:00
Guangcong Luo
18d656519c Fix chooseMove again 2017-08-09 21:52:30 -05:00
Guangcong Luo
29bfa41f79 Fix crash in autoChoose 2017-08-09 20:28:25 -05:00
Marty-D
5aa7045900 Fix Solar Blade redirection issue 2017-08-05 12:32:35 -04:00
Guangcong Luo
4df6548cf4 Fix bugs in VGC auto-move resolver 2017-08-02 07:02:32 -04:00
HoeenHero
4af068a710 Fix custom banlists (#3832) 2017-07-31 02:18:24 -04:00
Guangcong Luo
bbf7bc98d2 Fix random battle sets
(There were doubles sets in singles games)
2017-07-27 17:49:38 -04:00
Guangcong Luo
acc165d4db Fix bugs in previous commits 2017-07-27 17:24:55 -04:00
Guangcong Luo
7f72f09e5d Rename Dex.format -> Dex.forFormat 2017-07-27 17:10:44 -04:00
Guangcong Luo
0e792dad80 Update default gen for formats to gen 7 2017-07-25 03:37:55 -04:00
Guangcong Luo
4cdf39f13c Remove prototype hack for Battle
Simulator instances still get their scripts included somewhat hackily,
but it's overall much less hacky than before. In particular, the
init code is now an actual constructor, allowing TypeScript to perhaps
validate it one future day.
2017-07-25 02:59:59 -04:00
Guangcong Luo
0ba508bbd3 Support ./pokemon-showdown generate-team
I might regret supporting this syntax, but it's now possible to make
PS generate teams on the commandline using:

./pokemon-showdown generate-team [optional format name] [optional seed]

The output will be in packed team format (which can be pasted into
a teambuilder import box).

The seed-passing should make it significantly more straightforward to
debug team generation weirdness.
2017-07-25 02:59:59 -04:00
Guangcong Luo
3b4d8b3ff0 Split random-teams.js out of scripts.js
Random team generation scripts are no longer in scripts.js, but instead
in a new file random-teams.js.

The scripts are now also no longer run from inside battles, but in a
new team generator object. This makes it easier for external scripts
to generate random teams by running Dex.generateTeam(format).
2017-07-25 02:59:59 -04:00
Guangcong Luo
a86762e4ea Fix in-battle clauses 2017-07-23 22:20:42 -07:00
Guangcong Luo
f38de6d775 Remove padStart shim
The padStart shim is currently unused and commented out. If we ever do
need it, we should increase the minimum Node version to 8.0.
2017-07-23 22:17:07 -07:00
Guangcong Luo
6c1a60df2e Fix limit rules in ruleTable team validation 2017-07-20 19:35:02 -05:00
Guangcong Luo
2b1d7b2cc3 Properly fix crash in /learn 2017-07-20 16:33:40 -05:00
Guangcong Luo
d79e348ebc Refactor banlistTable -> ruleTable
PS's rule table has been renamed from banlistTable, and works a bit
differently now. It's a Map instead of an object now, and the keys
work a bit differently.

The original banlistTable was designed to store bans, and later
additions shoved rules and then unbans in there. The new table is
designed to support all of these.
2017-07-20 12:50:41 -05:00
Konrad Borowski
212b99ed90 Remove Object.values shim (#3787)
It's not correct as far ES2017 specification is concerned, and Showdown
requires Node.js 7 anyway
2017-07-16 17:39:53 -05:00
asgdf
6dc5c877e3 Fix comment typos (#3757) 2017-07-10 16:57:07 +09:00
Guangcong Luo
58a1af0f0f Rename supplementaryBanlist -> customBanlist
It's shorter and clearer.
2017-07-04 09:36:37 +09:00
Guangcong Luo
3f6f9e61a5 Fix supplementary banlists
They're coded as nullable and are better treated that way.
2017-07-04 09:36:37 +09:00
Marty-D
3bf0ffdc97 Gen III: Fix Ingrain 2017-06-29 18:38:36 -04:00
Guangcong Luo
83f70fcf3a Export PRNG from sim/ 2017-06-22 20:57:51 -07:00
Quinton Lee
e3b964a65d Show correct rulesets in custom format battles (#3674)
Also add more format documentation
2017-06-22 15:25:31 -07:00
Quinton Lee
5ab919d858 Refactor supplementary banlists into custom formats (#3671) 2017-06-22 03:10:15 -07:00
Quinton Lee
ec10d30996 eslint: Lint sim/ directory (#3670) 2017-06-21 20:00:17 -07:00
Marty-D
d60c007f3d Update move flag descriptions 2017-06-17 09:36:52 -04:00
Guangcong Luo
cf7607cb90 Move cache tables out of Dex.data
Template/Item/Move/Ability caches are now direct properties of Dex,
instead of being inside Dex.data.
2017-06-13 21:45:53 -05:00
Guangcong Luo
00448ac865 TypeScript: Update for latest nightly
The latest nightly of TypeScript changes how the checks work, and I'm
tracking it because it also fixes several major bugs in --checkJs.
2017-06-11 12:03:38 -05:00
Caleb Young
9dab8e50e1 Implement DPP damage formula (#3583) 2017-06-11 10:18:34 -05:00
asgdf
f22963c718 Fix Last Will crash (#3561)
By moving BeforeFaint right before the faint message, so the move is done
by then.
2017-05-28 17:24:17 +09:00
urkerab
f24d7cbadb Move Illusion-breaking out of the battle engine (#3549) 2017-05-24 20:36:17 -04:00
asgdf
8a33238544 Fix statuses still being effective after being removed that turn (#3538) 2017-05-24 23:55:35 +09:00
urkerab
d212b9f128 Move, Ability and Item effects should inherit the name (#3547) 2017-05-24 23:12:38 +09:00
Guangcong Luo
cd3ac06987 Fix Hail/Sandstorm damage regression
(Also add a test for it since this isn't even the first time this
exact regression has happened.)
2017-05-18 06:29:25 -05:00
Guangcong Luo
109b2cfe1d Slightly refactor teamsize 2017-05-18 05:38:14 -05:00
QuiteQuiet
1be924f6e8 Send team size at the start of battles (#3512) 2017-05-18 05:09:38 -05:00
Guangcong Luo
149ca3759c Add classes for data
Having classes for data will make it better for documenting and make
for overall nicer code that's easier to statically analyze.
2017-05-17 04:10:01 -05:00
Guangcong Luo
fe5fa7889e Fix various TypeScript-related errors
Now that typescript@next fixes the major issue plaguing us, we can
start working on the other issues!
2017-05-17 04:10:01 -05:00
urkerab
b12d9cbf04 Give Natures a Generation (#3528) 2017-05-14 07:22:42 -05:00
urkerab
8ca39d65fc Properly report a near miss for an alias (#3532) 2017-05-14 07:22:20 -05:00
Charlie Kobayashi
78ed58d0c4 Dex: fix dataSearch (#3525)
Use the result's name first instead of inexact search term if search is found.
2017-05-12 17:12:07 -05:00
Charlie Kobayashi
196364adca Effect: don't override inherited properties from moreData (#3524)
- caused weather effects passed in through ``moreData`` to be marked as simply ``"Effect"``
    - as a result, sandstorm and hail will damage Rock/Ground/Steel and Ice types  respectively
- this fix makes ``Effect`` inherit the ``effectType`` from ``moreData`` if it doesn't exist in the primary ``data`` variable passed into the constructor
2017-05-12 14:23:05 -05:00
urkerab
59583ee113 Include aliases when searching the dex (#3475) 2017-05-09 23:58:32 -05:00
Guangcong Luo
e34c77930a Start creating classes for getEffect data
Currently, getEffect/getTemplate/getMove/etc return bare objects.
Refactoring their returns into classes will allow TypeScript to type
check them.
2017-05-09 16:00:11 -05:00
Guangcong Luo
a75282ea97 Fix crash in /weakness 2017-05-08 19:06:54 -05:00
Guangcong Luo
22186f1903 Improve TypeScript typing
sim/dex.js and sim/prng.js are now valid strict TypeScript! Also they
have slightly less "any" use than before.
2017-05-08 02:58:55 -05:00
Quinton Lee
fa1b45f7ab Support supplementary rulesets in battles (#3330) 2017-05-05 20:13:08 -05:00
Guangcong Luo
9e180e4fc1 Remove MockBattle
No MockBattle feature needs to be kept out of sim/...
2017-05-05 16:57:18 -05:00
Guangcong Luo
6dd58b40d3 Refactor simulator into new sim/ directory
This is a surprisingly minor refactor considering how many files it
touches, but most of this is only renames.

In terms of file renames:
- `tools.js` is now `sim/dex.js`
- `battle-engine.js` is now `sim/index.js` and its three classes are
  in `sim/battle.js`, `sim/side.js`, and `sim/pokemon.js`
- `prng.js` is now `sim/prng.js`

In terms of variable renames:
- `Tools` is now `Dex`
- `BattleEngine` is now `Sim`
- `BattleEngine.Battle` is now `Sim.Battle`
- `BattleEngine.BattleSide` is now `Sim.Side`
- `BattleEngine.BattlePokemon` is now `Sim.Pokemon`
2017-05-05 16:48:38 -05:00