Commit Graph

1124 Commits

Author SHA1 Message Date
Waleed Hassan
6714e14fc5 Fix max line length warnings (#6286) 2020-01-14 15:30:50 +04:00
urkerab
b589745a25 Typescript move.target (#6260) 2020-01-11 09:10:10 -05:00
The Immortal
5b97367952 Update Skill Swap & Wandering Spirit 2020-01-09 10:49:41 +04:00
The Immortal
491e0575e0 Random Battle updates 2020-01-07 22:07:09 +04:00
The Immortal
d00bcb9927 Fix validator crash 2020-01-07 00:52:13 +04:00
CK Yong
cadc3fa05d Remove tightening focus message when used by dynamaxed pokemon (#6253)
Check whether the move is a max move. If it isn't, then resolve the choice as usual. Otherwise, do not add the move to the queue, and let the runDynamax mechanic handle move resolution.

Added regression test to check for focus punch message in both dynamaxed and regular use
2020-01-04 06:02:35 -05:00
Guangcong Luo
138fccbaa8 Consolidate more rules into Standard
- `Obtainable` and `Team Preview` are now part of `Standard`

- `minSourceGen: 8` is now a part of `-Unreleased` (which is part of
  `Obtainable`) in Gen 8. Instead, it's NatDex that overrides it with
	`minSourceGen: 1`. This allows `!Standard, Standard NatDex` and
	`!Standard NatDex, Standard` to work as intended.

- Duplicate rules are now checked for (does not apply to subrules, so
  multiple inheritance is still possible)

- It is now possible to inherit `minSourceGen` from rules.
2020-01-03 23:42:48 -05:00
Guangcong Luo
2310934a45 Support checking for redundant rules 2020-01-03 23:42:45 -05:00
The Immortal
dde10b714f Fix validation for "Unobtainable" Pokemon
As well as the error message for Past/Future Pokemon.
2020-01-04 05:38:52 +04:00
Guangcong Luo
ca1f8ec820 Fix Howl ally-targeting
Fixes #6247
2020-01-01 11:10:49 +09:00
Guangcong Luo
267c815d7d Allow piecemeal repeal of inherited rules
Specifically, removing a subrule now correctly removes subsubrules.
2020-01-01 11:10:48 +09:00
ZardMX
de7d8168af Fix Neutralizing Gas (#6232) 2019-12-31 16:29:21 +09:00
The Immortal
a0bffce283 Revert "Max happiness in gen 8 is 160"
This reverts commit c7bc102c5a.
2019-12-30 16:44:39 +04:00
Guangcong Luo
edb5404e41 fixup! Fix abilityData/itemData type definitions 2019-12-30 12:23:40 +09:00
Guangcong Luo
1c2119c02e Fix Body Press hint
See https://github.com/smogon/pokemon-showdown/pull/6221#issuecomment-569556599
2019-12-30 11:33:18 +09:00
Guangcong Luo
bf8ed1861d Fix abilityData/itemData type definitions
TODO: move EffectState to global types, and properly type it.
2019-12-30 11:32:12 +09:00
urkerab
c02e711375 Body Press uses SpD boosts under Wonder Room (#6221) 2019-12-30 09:37:04 +09:00
Kris Johnson
36a92b5465 Move Darmanitan-Galar to Ubers (#6236) 2019-12-30 01:13:39 +04:00
Guangcong Luo
1e1c97c255 Add default types/stats for template
A stub Template object now has `['???']` as its `types` array.

This should suppress some crashes, but the underlying problem remains.
2019-12-27 22:09:11 +09:00
Liminalia
afffbeb8b0 Fix RandomPlayerAI wrong teamsize assumption (#6216) 2019-12-27 08:04:47 -05:00
urkerab
7152b42daf Calculate fractional priority once per turn (#6224) 2019-12-27 12:42:34 +09:00
Marty-D
c5b8a0e3c0
Fix Pursuit crash in past gens 2019-12-26 13:51:20 -05:00
The Immortal
f58f196190 Fix National Dex validation 2019-12-25 07:18:42 +04:00
Guangcong Luo
b31b88a79b Add documentation for custom rules 2019-12-25 11:26:23 +09:00
Guangcong Luo
15cfd06795 Support whitelisting in custom rules
Custom rules can now use whitelists instead of blacklists.
Whitelist rules look like:

`- all moves, + Metronome`

(Metronome Battle does not use this ruleset currently, because its
scripted check displays a better error message than a whitelist rule,
which can't actually display the whitelist as of the current
implementation.)
2019-12-25 10:05:49 +09:00
The Immortal
f62ff19e8a Improve validation for unobtainable Pokemon
This merges the Glitch and Pokestar tags into a new Unobtainable tag that defines Pokemon that are only obtainable through hacking (such as Floette-Eternal and Missingno.). These Pokemon are legal in Hackmons of their specific generation only. Custom is used in future gens instead of Past because of National Dex legality.
2019-12-25 00:35:39 +04:00
Guangcong Luo
7f772fba67 Fix Teatime
Fixes #6210
2019-12-24 14:49:47 +09:00
Guangcong Luo
b190202356 Fix Eject Pack crash 2019-12-24 14:30:30 +09:00
The Immortal
1287dd8add Fix "Past" unreleased hidden abilities 2019-12-22 19:59:32 +04:00
The Immortal
c9af9eacce Correct forme mechanics
New research shows that only Zacian-Crowned and Zamazenta-Crowned are unobtainable out-of-battle. So, reverting the validateForme changes and hardcoding it in BH instead of using Obtainable Formes.
2019-12-16 05:37:17 +04:00
Quinton Lee
9a97a49b24 Dex: fix Darmanitan-Galar-Zen's gen (#6187) 2019-12-15 16:11:23 +09:00
urkerab
56a0e37e3b Some Utility Umbrella fixes (#6180)
- Cherrim should revert if given a Utility Umbrella in Sun.
- Castform shouldn't keep transforming if it holds a Utility Umbrella.
- Leaf guard Utility Umbrella check works but is just inconsistent placement.
- Sun/Rain affected recovery moves should heal 50% with Utility Umbrella.
- Solar moves power should halve in sand or hail even with Utility Umbrella.
- Weather Ball should double in power if Magic Room blocks Utility Umbrella.
2019-12-15 04:05:25 +09:00
The Immortal
033d41aff8 Crowned formes change Iron Head to their Behemoth move 2019-12-14 00:07:28 +04:00
The Immortal
fc4c185005 Refactor validateForme 2019-12-12 17:13:45 +04:00
Guangcong Luo
c02ef2f56c Fix Neutralizing Gas faint double-trigger 2019-12-12 18:45:57 +09:00
Guangcong Luo
9abdaa1977 Allow "dynamax" choices when already dynamaxed 2019-12-12 17:09:16 +09:00
Kris Johnson
f1ad861659 Fix Necrozma-Ultra's inheritance (#6176) 2019-12-12 00:13:14 +04:00
Guangcong Luo
65187a9053 Improve Dragon Darts
This is not the best implementation and the animation/messages will be
wrong, but the mechanics should be pretty accurate.

Fixes #6085

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

In addition, Dynamax undisables all moves for its duration.

Fixes #6088
2019-12-11 03:41:38 +09:00
Guangcong Luo
b9fb3e3a0a Refactor test formats
`Dex.installFormat` has been deprecated and removed. Formats are now
directly created and cached by our unit test framework. This should
lead to fewer weird bugs.
2019-12-11 03:41:36 +09:00
420Blazeitt
143ea606fd Fix type-changing moves & abilities while Dynamaxed (#6080) 2019-12-11 03:10:38 +09:00
Kris Johnson
89002124b3 Change inheritsLearnsetFrom to inheritsFrom and fix Necrozma-Ultra's inheritance (#6168) 2019-12-10 08:03:49 +04:00
The Immortal
cb01db1eab Fix Body Press mechanics
It should be affected by abilities and items that modify attack, not defense.
2019-12-10 01:34:22 +04:00
The Immortal
3572be0be8 Update forme validation for gen 8 2019-12-07 17:05:49 +04:00
The Immortal
f1530288e5 Move Keldeo-R validation to Obtainable rule
Keldeo-R is not a battle forme and is possible to hack without Secret Sword, unlike most other formes. It should be restricted by the rule that prevents hacks and not the rule that validates battle formes. This is mostly relevant for Hackmons.
2019-12-05 22:36:20 +04:00
The Immortal
4266000df4 Update forme validation
- In gen 8, Silvally is able to enter battles in different types if it doesn't have RKS System (i.e. it doesn't require a Memory).
- In gen 8, formes that transform in battle are no longer able to start in that forme (relevant to BH).
2019-12-05 07:29:15 +04:00
The Immortal
c7bc102c5a Max happiness in gen 8 is 160 2019-12-05 03:01:59 +04:00
Guangcong Luo
eb614e627f Fix switch order
Fixes #6135
2019-12-04 13:36:39 +09:00
Guangcong Luo
fe0d044d2b Fix tests to run on Gen 8 instead of Gen 7 2019-12-04 13:36:37 +09:00
HoeenHero
fe6ee1339f Sort battle actions by order instead of priority (#6143)
This fixes the issues with priority moves in gen 8.
2019-12-04 12:56:50 +09:00
Guangcong Luo
9b943fb62f Fix Dynamax stat handling
We now track `baseMaxhp`, the pre-Dynamax max HP. We also have a new
function `getUndynamaxedHP` for use by moves that use it (famously,
Endeavor).

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

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

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

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

Fixes #6131

Fixes #6087
2019-12-04 09:25:46 +09:00
The Immortal
a133a5b28b Fix 4b324e536
This reverts the other changes that were related to that commit.
2019-12-02 18:13:08 +04:00
Kris Johnson
953531cb6f Add inheritsLearnsetFrom property (#6133) 2019-12-02 21:15:48 +09:00
Guangcong Luo
d550bb64d8 Support past-gen-only tracking in minPastGen
This adds new properties `isUnreleased: 'Past'` and
`unreleasedHidden: 'Past'`, which mark a Pokémon or Hidden Ability as
released in past gens, but not in the current gen. This allows them
to be banned in present-gen-only formats, but not in past-gen-transfer
formats.
2019-12-01 20:24:52 +13:00
Guangcong Luo
d5b4b7964e Fix mega evolution priority move interaction 2019-12-01 20:08:25 +13:00
Guangcong Luo
2c95b17e98 Improve debugging support
We have a new command:

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

which will extract the omniscient log from an input log.

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

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

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

As a result of this change the pokemon.canDynamax flag is unnessecary
and has been refactored to a side.canDynamax flag. All pokemon specific
dynamax checks should use the battle.canDynamax method.
2019-11-26 13:05:38 -05:00
Guangcong Luo
5364c63e23 Introduce item.itemUser
`item.itemUser` replaces `item.zMoveUser`, and is a new field
representing a list of possible users of an item, for items that are
restricted to specific species.

`item.zMoveUser` is a base forme for items that affect every forme, and
a forme name otherwise (forme name is currently only used for
`forcedForme` uses).

Arceus is a weird case. Both generic Z crystals and Plates, while
having unique effects on Arceus, also have effects on other Pokémon.
For this reason, Arceus isn't listed as an `itemUser` of either of
these item types - use-cases that want this should also check
`item.forcedForme`.

This is mostly intended to be useful to move-searching and custom
rules (like NatDex, which will only allow past-gen items associated
with removed species).
2019-11-25 15:26:36 +13:00
Guangcong Luo
a9e1ec8487 Implement a default zMovePower
Like gmaxPower, Z-move powers mostly follow a formula, which can be
applied to newer moves.

(In the future, we can save some bytes by not listing the powers.)
2019-11-25 15:26:36 +13:00
subash955
bee1be1f45 Validator: Ignore Nature restrictions in Gen 8 (#6048) 2019-11-22 12:47:26 +13:00
whales
9e454e3ea6 Mark double iron bash as gen 7 (#6042) 2019-11-21 13:47:08 +04:00
Guangcong Luo
65b17bc669 Properly fix Speed after Dynamaxing 2019-11-21 11:59:12 +13:00
Kris Johnson
8370c488ce Fix the evolution method of new Pokemon (#5982) 2019-11-20 21:44:16 +13:00
Guangcong Luo
18dab87d6b Fix Dynamax move targeting in Doubles 2019-11-20 21:28:51 +13:00
Guangcong Luo
621d55646a Don't change Ability for temporary forme changes
Fixes #6025
2019-11-20 20:23:05 +13:00
Guangcong Luo
b02e91f393 Lose Choice Scarf Speed on first turn of Dynamax
Fixes #6008
2019-11-20 19:53:32 +13:00
Christopher Monsanto
b90475a257 Don't allow Darmanitan-Zen-Galar in previous gens (#6022) 2019-11-20 04:56:00 +04:00
The Immortal
426c013cae Add Gmax events 2019-11-20 03:04:16 +04:00
420Blazeitt
9ed1dec6bf Fix Max Move effects not activating against substitute (#5997) 2019-11-19 17:17:52 +13:00
The Immortal
e7cece5282 Add minSourceGen field to Formats 2019-11-19 03:12:22 +04:00
HoeenHero
d864c798e2 Fix Giantamax 2019-11-18 07:44:29 -05:00
The Immortal
7a3cd9d078 Restrict SwSh metagames to Galar learnsets 2019-11-18 00:22:36 +04:00
Guangcong Luo
6de97db219 TypeScript event handler types 2019-11-18 07:02:32 +13:00
Guangcong Luo
2601450517 Fix Ice Face 2019-11-18 06:23:24 +13:00
Russell Jones
b2e9336c32 Fix Gmax powers (#5985) 2019-11-17 20:14:10 +04:00
HoeenHero
b65826b94e Gigantamax support 2019-11-17 08:00:22 -05:00
Guangcong Luo
4fc49bc7f9 Fix Body Press
Fixes #5975

Fixes #5979
2019-11-17 18:47:16 +13:00
Guangcong Luo
2b55bde8af Output Dynamax to inputlogs 2019-11-17 13:10:43 +13:00
asgdf
736f357dab Default to gen 8 mod for formats (#5969) 2019-11-16 23:25:37 +04:00
The Immortal
0000c69c44 Fix illegal moves in Hackmons Cup
And re-enable the format
2019-11-16 23:07:08 +04:00
Guangcong Luo
0bb2e58efd Fix Dynamax move base power
Dynamax moves now have the correct base power, and now correctly only
deal 25% usual damage against Protect.
2019-11-17 06:32:17 +13:00
Guangcong Luo
43ef4d9785 Preload data when using Dex.forFormat
This supposedly fixes a bug where old-gen randbats were generating
invalid teams.
2019-11-17 06:32:12 +13:00
HoeenHero
a9f0f752d3 Fix choice lock - dynamax interaction 2019-11-16 08:44:31 -05:00
Guangcong Luo
01f12b3a54 Fix Gigantamax formes being available in past gens
A WIP Gigantamax implementation broke this.

Fixes #5961
2019-11-16 20:00:54 +13:00
HoeenHero
62218ef416 Dynamax is only useable in gen 8 2019-11-15 21:44:44 -05:00
HoeenHero
9ecbcabee9
Dynamaxing (#5946) 2019-11-15 21:33:10 -05:00
Guangcong Luo
10062ece4f Fix Koffing/Weezing Gen 7 Abilities
PS apparently doesn't have gen-accurate Ability data for Pokémon in
Gen 3 that gained Abilities between Gen 3 and Gen 4 (like Pidgeot
still has Tangled Feet in Gen 3), but that will have to be left for
a future commit.
2019-11-16 14:39:14 +13:00
Kirk Scheibelhut
a4698a52cb Reenable ExhaustiveRunner test with workaround 2019-11-15 14:45:38 -08:00
Guangcong Luo
99da82e098 Correctly set Dex mod ID to gen8
This is required for `Dex.mod('gen8')` to not crash.
2019-11-16 07:00:49 +13:00
Guangcong Luo
801af59b98 Fix remaining build errors
- Centiskorch was misspelled in formats-data, causing a crash in the
  egg validator

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

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

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

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

- Inverse Mod suddenly stopped working; its implementation was a huge
  hack and I can't figure out what went wrong, so I've switched it to
	using the same system the other mod tests use. It's still a huge
	hack, but I don't have the free time to fix it right now.
2019-11-16 06:08:48 +13:00
Kris Johnson
a19ad51a20 Fix one part of the build (#5945) 2019-11-16 00:08:28 +13:00
HoeenHero
5144fc32d7 Add Gen 8 Abilities 2019-11-15 22:01:54 +13:00
Kris Johnson
46ad0bccd7 Add Gen 8 Pokemon 2019-11-15 22:01:36 +13:00
Guangcong Luo
7a90fa7622 Fix DW and baby-only move compatibility checking
PS already tracks which evolution level an egg move or event pokemon
learns a move from, but apparently this was not tracked for DW moves.

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

- Staravia egg moves are now properly supported
  (9742ecf62f was a hack that caused the Tyranitar problem)

- Some Pokemon evolve by having a move in their learnset (like Piloswine
  with Ancient Power). These can only carry three other moves from their
  prevo, because the fourth move must be the evo move. This restriction
  doesn't apply to gen 6+ eggs, which can get around the restriction with
  the relearner.

Fixes #2287

(Except Shiftry and friends, but those are already tracked in
`rulesets:obtainablemoves`.)
2019-10-10 06:33:33 +11:00
Guangcong Luo
a750cd1d7a Fix crash when validating LC egg moves
I put in this `throw` because I thought this condition was impossible,
but it turns out it's possible! Good to know.
2019-10-09 06:50:45 -04:00
Guangcong Luo
5f1f230bde Fix forme validation in Hackmons
In formats without Obtainable Formes, we no longer validate bans as
if they were enabled.
2019-10-09 06:50:44 -04:00
Guangcong Luo
2adc80efe4
Improve egg validator (#5854)
Previously, we split gen 2-5 egg move validation into two phases,
`checkLearnset` where we searched for a valid father, and
`reconcileLearnset` where we made sure the father could learn the move
combination.

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

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

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

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

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

This also improves some baby-only move validation, specifically fixing
the issue with Seismic Toss Charm Chansey.
2019-10-09 00:59:24 +11:00
urkerab
e717abe802 Require normal targets to be adjacent in Triples battles (#5852) 2019-10-09 00:56:51 +11:00
Guangcong Luo
3ddaebd181 Fix Let's Go Eevee/Pikachu-Starter validation 2019-10-07 01:58:56 +11:00
Guangcong Luo
bb9bfb8fcd Make validator bans/unbans apply in order
(Fixes an issue with RU's unban of Drought overriding NU's ban of
Drought.)
2019-10-06 17:54:28 +11:00
Guangcong Luo
c1ecbc6522 Fix misc validator bugs
- Repealing rules now always works, regardless of rule order
  (Fixes AAA validation)
- Fix a check for egg move hidden ability validation
  (Fixes a Gen 4 Dragon Dance Charizard set)
- Always ban AG when banning Uber
  (Fixes allowing Rayquaza-Mega in lower tiers)
- Fix ability validation in Let's Go
- Fix valid-move-combo dexsearch
2019-10-06 17:21:01 +11:00
Kirk Scheibelhut
691cf76de7 Fix EBC for external staleness via consumed Leppa 2019-10-05 15:41:18 -07:00
Guangcong Luo
2a93e9e05e Fix forme validator 2019-10-06 08:00:02 +11:00
Guangcong Luo
7a023746ba
Refactor battle.dex out of battle (#5851)
In most other similar systems, like TeamValidator, we use `thing.dex` instead of having it extend `ModdedDex`. Battle has always extended `ModdedDex`, though. This changes Battle to match the others.

This should fix an issue with `Battle.data` not being cached.

This also frees up Battle to extend ObjectReadWriteStream<string> in a future update.
2019-10-06 07:38:08 +11:00
Guangcong Luo
555bd9cdb8 Fix mega evolution ability validation 2019-10-06 07:34:51 +11:00
Guangcong Luo
70b1de52ec Fix egg move validator
`limitedEgg` shouldn't exist, but this is a stopgap for the new way
it works.
2019-10-06 07:17:18 +11:00
Guangcong Luo
3cd04c349e Fix missed conversions of validate -> obtainable 2019-10-06 04:32:23 +11:00
Guangcong Luo
71498d451d
New validator (#5840)
* Refactor validator

This is a major refactor intended to make the default rules easier to
understand, and also easier for OMs to bypass.

Removed rules:
- `Pokemon`: This is now `-Nonexistent`. Its previous name was intended
  to be interpreted as "simulate the Pokémon games exactly, and only
  allow what they allow". The new name should make it clearer that it
  mainly bans CAPs and other nonexistent Pokémon and functionality.
- `-Illegal`: This is now `Obtainable` (see below).
- `Allow CAP`: This is now `+CAP`. Instead of having a hardcoded rule,
  OMs can now be manually whitelist any pokemon/item/etc or group of
  them, overriding `-Nonexistent`.
- `Ignore Illegal Abilities`: This is now `!Obtainable Abilities` (see
  below).

`Obtainable` was previously `-Illegal`, and does the same thing: Makes
sure you have a regular Pokémon game with only Pokémon that can be
obtained without hacking.

But instead of being a ban, it's now a rule that does nothing by
itself, except contain more rules:
- `Obtainable Moves`
- `Obtainable Abilities`
- `Obtainable Formes`
- `Obtainable Misc`
- `-Nonexistent`
- `-Unreleased`

This allows OMs to piecemeal repeal and unban any of these individual
rules, instead of the previous approach of unbanning them all and
manually reimplementing every single validation you wanted to keep.

* Refactor PokemonSources into a class

This mostly just makes a lot of the weirder checks in the validator
substantially more readable.

This also renames `lsetData` to `setSources`, which should also help
readability.

* Validate Bottle Cap HP types

Fixes an issue reported here:

https://github.com/Zarel/Pokemon-Showdown/issues/5742#issuecomment-533850288

* Fix several move validation issues

Fixes #5742

We have a new MoveSource type: R for Restricted. R moves work like
level-up/tutor/TM moves, except you're limited to one R move.

- Shedinja move stolen from Ninjask in Gen 3-4 are now R moves instead
  of event moves. This allows them to coexist with Nincada egg moves.

- Necrozma-DW/DM now inherit moves/events from Necrozma (like Rotom,
  but with event validation). This allows them to be shiny.

- Pokemon can now get egg moves from their own evolutions. This fixes
  some Tyrogue, Charmander, and Treecko sets mentioned in #5742

- Some more C moves were added, fixing some Hitmontop and Chatot sets
  mentioned in #5742

* Improve ability/move compatibility validator
2019-10-06 04:21:30 +11:00
Waleed Hassan
da4b887054 Rename Room#id -> Room#roomid, User#userid -> User#id (#5826)
These should make it clearer that userids are IDs but roomids aren't.
2019-10-03 18:57:38 +10:00
urkerab
948257cce7 Change weight units to hectograms (#5765) 2019-10-03 14:00:16 +10:00
HoeenHero
3445da848a Move support for overwritting custom terrains to client.
This didnt work anymore anyways since setTerrain was moved from battle to field.
2019-09-27 22:53:49 -04:00
HoeenHero
7f7c2d9a95
Super Staff Bros Brawl Update (#5764) 2019-09-22 14:47:33 -04:00
Guangcong Luo
23a4b6ed66 Correctly ban illegal pokemon
Also support individual nonstandard bans in rule tables.

Fixes #5770
2019-09-11 20:49:29 -07:00
Guangcong Luo
c03499e037 Mark Pikachu/Eevee-Starter as Gen 7 2019-09-11 20:49:29 -07:00
Nol
a60dd6fb11 Fix typo (#5767) 2019-09-09 00:09:06 -05:00
Kirk Scheibelhut
4f70c022d6 Correct EBC switch condition to match the spec
"at least one team does not have the option of switching to a
non-stale Pokémon"
2019-09-01 16:17:36 -07:00
The Immortal
26dfe8fd9e Revamp Random Battle
- New ability ratings
- Improve move pools
- Allow non-status moves to be re-rolled if rejected (this fixes all undesired move set combinations)
- Update move & ability rejections
- New item possibilities
2019-09-01 19:40:53 +04:00
TheJetOU
20ced3f073 Fix linter warning in TeamValidator (#5700) 2019-08-13 17:25:54 +02:00
Kirk Scheibelhut
9ab3f5a668
Make /hotpatch fail if git history hasn't changed (#5688)
/forcehotpatch can be used to perform the hotpatch regardless.
2019-08-12 10:23:24 +02:00
Marty-D
7ed137dffd
Validator: Fix HA Raikou/Entei/Suicune legality in pentagon formats 2019-08-11 16:11:26 -04:00
Kirk Scheibelhut
25cea76a08
Change packed encoding of ability and gender
0|1|H|S saves minimal space over the ability ID and requires parsers have the data files, in addition to limiting the ability to search abilities in the teambuilder. Similar, gender can be elided most of the time and just chosen randomly if not specified.
2019-08-06 09:55:07 +02:00
Cole French
e3890fdae6 Prevent locked users from having Pokemon nicknames hidden in Cross Evolution (#5669) 2019-08-03 12:19:51 -05:00
Guangcong Luo
bf37e6a5fa Fix onModifyTemplate signature
This will intentionally fail CI. It's my hope that #5664 will pass it.
2019-08-01 16:13:08 -05:00
Kirk Scheibelhut
57dd3b527f Add isPokeball field to Items data (#5644) 2019-07-22 16:20:09 -05:00
Guangcong Luo
3db1d9916c Deduplicate Template definition
It turns out Template is the only remotely-easy type to merge the class
and interface for.

The others all have a bunch of event methods which would need to be
redefined on the class.
2019-07-19 18:20:42 -05:00
Guangcong Luo
516084d6a2 Deprecate and remove canUseRandomTeam
`canUseRandomTeam` was a feature intended to allow random teams to be
generated in custom games. I never added a UI for it, and nowadays we
have more than one Random Battle format anyway, so this flag no longer
makes any sense.

The new plan is to support "random team" custom rules, which should be
easier to implement and easier for users to understand.
2019-07-19 13:52:44 -05:00
Kirk Scheibelhut
875b02c816 Make Blitz/VGC Timer 'Rule' instead of 'ValidatorRule' 2019-07-17 12:14:35 -07:00
Guangcong Luo
0cc534092a Support timer rules 2019-07-16 16:03:02 -05:00
TheJetOU
ade29349c6 Send Elo rating in rated battles (#5595) 2019-07-11 02:38:49 -05:00
Guangcong Luo
413bf26d0d Correct .tier/.isNonstandard for future gens
Fixes #5243
2019-07-09 06:31:42 -05:00
Kirk Scheibelhut
df083d7528 Remove Object.assign(function) pattern from TeamValidator{Async} 2019-07-01 08:20:51 -07:00
Kirk Scheibelhut
79f34441f2 Include a >version-origin hash if different from >version (#5542) 2019-06-16 13:24:11 +09:00
Kirk Scheibelhut
8e85ab34fb Only hint about /offertie if Config.allowrequestingties 2019-06-14 21:50:53 -07:00
Kirk Scheibelhut
f0e3d22957 Tweak cases how/when base power is included in required (#5527) 2019-06-05 16:40:47 -05:00
Kirk Scheibelhut
51d390900d Include BP in |request| for Frustration/Return (#5519) 2019-06-04 11:35:40 -05:00
Kirk Scheibelhut
be19918c49 Fix incorrect ability message from Gen 1 Transform (#5518) 2019-06-02 17:05:41 -05:00
Kirk Scheibelhut
df3df362be Provide a hint regarding '/offertie' in EBC situations (#5513) 2019-06-01 21:54:36 -05:00
Kirk Scheibelhut
db66195c26 Remove additional toID calls (#5503) 2019-05-23 18:11:26 +01: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
Konrad Borowski
f2ef0b62ab Remove TODO from flatMap implementation
Closes #5369
2019-05-13 19:58:20 +02:00
Kirk Scheibelhut
3d24166cdf toId -> toID
Closes #5479
2019-05-12 17:53:01 -07:00
Jacob McLemore
a1f18f0290 Chat-Plugins: Fix regression in weakness command (#5484) 2019-05-07 18:42:53 +09:30
Kirk Scheibelhut
3f1fa344b9 Change EBC cast to use 'as' 2019-05-06 19:48:23 -07:00
Guangcong Luo
2cd150d1da
Merge EBC and ID changes 2019-05-07 12:07:41 +09:30
Kirk Scheibelhut
a0734bde6f Redo Endless Battle Clause with a new specification (#5472) 2019-05-07 11:18:06 +09:30
Kirk Scheibelhut
49403556d1 getEffectByID (#5475) 2019-05-06 13:05:12 +09:30
Kirk Scheibelhut
10c744f733 Introduce an ID type to sim (#5468) 2019-05-04 13:13:12 +12:00
urkerab
508e58575e Other Metagames of the Month May 2019 (#5470) 2019-05-01 18:24:56 +04:00
Kirk Scheibelhut
df3d9b91ef Battle toJSON/fromJSON (#5427) 2019-04-30 14:48:27 +12:00
Kirk Scheibelhut
7e4929a39f Change protocol for '|split' message type (#5331) (#5332) 2019-04-22 09:20:47 +09:30
Marty-D
9428d274cc Gen III: Improve Truant implementation 2019-04-17 16:36:25 -04:00
Kirk Scheibelhut
6fea91ee56 Split dev-tools/globals* into sim and server (#5450) 2019-04-18 04:17:54 +09:30
Kirk Scheibelhut
4975f1902b Move simulator harness to sim/tools (#5451) 2019-04-18 04:17:07 +09:30
Marty-D
9b28525f4e Gen III: Correct Truant mechanics 2019-04-15 17:15:51 -04:00
urkerab
0133ba9bd6 Make Pokemon.moves a read only array (#5433) 2019-04-14 23:57:42 +09:30
Guangcong Luo
a33fc11d26 Refactor Actions, RandomTeamsTypes to namespace
They were previously some weird interface where their actual types
were properties. I guess whoever wrote this was unaware that TypeScript
namespaces were designed for this exact use-case.
2019-04-10 19:58:56 +09:30
Kirk Scheibelhut
f9164d4d59 Pull out non-sim code into RoomBattleStream (#5428) 2019-04-09 17:58:07 +08:00
Kirk Scheibelhut
b2777f9bf6 Remove |callback| in favor of |error| (#5418) 2019-04-09 03:33:32 +08:00
Guangcong Luo
df4d16cc20
Update RQID documentation 2019-04-08 01:51:52 +08:00
Kirk Scheibelhut
32a457c808
Add a smoke test runner to dev-tools (#5405) 2019-04-07 08:34:43 -07:00
Guangcong Luo
e459fce4c6 Fix crit calculation 2019-04-07 16:44:20 +08:00
Guangcong Luo
4c47af28aa Refactor moveHitData
This is actually three refactors:

- swap around thing:slot for slot:thing in MoveHitData
- add Pokemon#getSlot
- remove the ActiveMove class; it's back to being an interface
2019-04-06 19:10:45 +08: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
Kirk Scheibelhut
812e4efb57 Document |-sethp| 2019-04-05 20:09:44 -07:00
MacChaeger
fe1613797f Fix Z Moves breaking Protect (#5413) 2019-04-06 01:06:22 +08:00
Kirk Scheibelhut
3bdd4b95c6
Make RandomPlayerAI capable of playing VGC (#5410) 2019-04-05 08:21:57 -07:00
MacChaeger
d3f1161b62 Fix Weakness Policy and Clangorous Soulblaze in doubles (#5389) 2019-04-04 18:51:27 +08:00
Ivo Julca
121c4a3b24 Sim: Abort parsing choices if any is invalid
Fixes #5399
2019-04-03 02:08:59 -05: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
Kirk Scheibelhut
915dd3f4a0 Stop returning default from RandomPlayerAI (#5394)
`default` papers over AI logic errors. This change fixes those
errors instead:

  - handle maybeDisabled/maybeTrapped properly
  - use 0 PP and ally-less 'adjacentAlly' moves if necessary.
2019-04-03 11:53:02 +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
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