Commit Graph

298 Commits

Author SHA1 Message Date
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
HoeenHero
8792d7345f Most past gen items should still be illegal (#6066) 2019-11-25 22:00:12 +13:00
The Immortal
d9f3a24462 STABmons: Fix Galar Pokemon 2019-11-25 07:19:59 +04:00
The Immortal
7cccda3b18 Update Other Metagames 2019-11-25 06:53:08 +04:00
The Immortal
eff4d957e7 NatDex: Add ruleset & sort OU banlist 2019-11-25 03:06:31 +04:00
The Immortal
492f5ac7d5 Remove Moody Clause from Doubles ruleset 2019-11-22 22:38:57 +04:00
The Immortal
f46923173a Update OM clauses 2019-11-21 23:54:57 +04:00
The Immortal
97689e931a Add Dynamax Clause 2019-11-20 03:20:00 +04:00
The Immortal
a7f5ba92ca Update formats for gen 8 2019-11-19 08:05:42 +04:00
TheMezStrikes
0c7f04356d Generalize NFE bans into validator rule (#5942) 2019-11-11 17:42:30 +13:00
The Immortal
615f16c94d STABmons: Prevent unreleased moves 2019-11-03 05:36:53 +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
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
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
Marty-D
196983430f Gen 3 OU: Add 3 Baton Pass Clause and ban Baton Pass Smeargle
https://www.smogon.com/forums/posts/8212796/
2019-08-16 21:39:06 -04:00
Guangcong Luo
0cbb632521
Fix Blitz rule description 2019-08-07 10:54:52 -07:00
maxalexandderpi
e42cfac93e Update Blitz's description from 10s to 15s (#5681) 2019-08-07 09:22:21 +02: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
Kirk Scheibelhut
9fb516a2a4 Update reference to EBC spec 2019-05-13 16:25:49 -07:00
Kirk Scheibelhut
3d24166cdf toId -> toID
Closes #5479
2019-05-12 17:53:01 -07:00
Kirk Scheibelhut
a0734bde6f Redo Endless Battle Clause with a new specification (#5472) 2019-05-07 11:18:06 +09:30
Kirk Scheibelhut
10c744f733 Introduce an ID type to sim (#5468) 2019-05-04 13:13:12 +12:00
Marty-D
78cae4c5f3
STABmons: Allow a normally illegal Shiftry move combo 2019-04-26 11:02:06 -04:00
Ivo Julca
ac4b94876b Sim: Refactor to use Battle#getAllPokemon() and Battle#getAllActive() 2019-03-26 23:18:19 -05:00
Kirk Scheibelhut
03b2c92cb1 Make isNonstandard specify reason for non-standardness (#5330) 2019-03-22 01:49:22 +09:00
Marty-D
b94b5038b5 Rulesets: Make Little Cup work for any gen 2019-03-20 08:25:57 -04:00
MacChaeger
cfb1cf1731 Add a notice to the Inverse Mod (#5249) 2019-03-05 03:35:58 -06:00
MacChaeger
d764c52887 Don't add inactive rules as pseudoweathers (#5206) 2019-02-25 01:11:46 -06:00
Guangcong Luo
b498bb222c Require object literal method shorthand 2019-02-11 18:14:09 -06:00
TheMezStrikes
763794a18a 2v2 Doubles: Update banlist (#5116) 2019-01-24 16:28:10 +04:00
Marty-D
4b0c3679de
Copy Chansey's illegal move combos to Blissey 2019-01-08 08:32:29 -05:00
Kris Johnson
5b2d76d75d Add Pokemon Let's Go! (#4967) 2018-11-19 16:19:19 -06:00
Quinton Lee
94016f6218 Update Typescript to 3.1 (#4879) 2018-10-05 04:02:54 -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
Kris Johnson
5813add1e2 Add September RoA Spotlight, LCotM, and OMotM (#4838) 2018-09-01 16:02:05 +04:00
The Immortal
0a10b30674 Add Accuracy Moves Clause 2018-09-01 15:26:11 +04:00
Marty-D
e758f0a2f0 Add Team Preview to the Minimal GBU ruleset 2018-08-26 17:12:28 -04:00
Marty-D
e8b12b263d Gen IV: Allow Arceus with max EVs by default
https://www.smogon.com/forums/threads/changes-to-arceuss-legality-dpp-ubers-revisited.3593683/
This lets people play whichever ruleset they want for custom Ubers tournaments.
2018-08-25 15:19:43 -04:00
MacChaeger
82c792f82c Update to TypeScript 3.0.1 (#4710) 2018-08-07 03:27:28 +09:00
Marty-D
33a90b79e1 Actually make sure SpA and SpD match in Gen 1 2018-08-05 15:29:37 -04:00
Marty-D
88d02ef8b5 Deal with illegal move combinations
Until the validator can handle them
2018-07-29 18:18:29 -04:00
Marty-D
a56f70dada Release Zeraora and Plasma Fists 2018-07-01 13:53:41 -04:00
MacChaeger
af40242e50 Allow Pokestar props in Gen 5 formats lacking '-illegal' (#4671)
For the purpose of making custom tours with Pokestar props allowed possible.
2018-05-15 22:22:03 -05:00
The Immortal
4a2215c53e Fix Nickname Clause 2018-05-01 21:55:37 +08:00
Marty-D
c00918e01b Add Ultra Kalos Classic 2018-04-10 12:01:47 -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
d0a4a689a7 Refactor data/ and mafia.js to for...of (#4490) 2018-03-23 18:51:52 -07:00
KrisXV
ac08f5b38f STABmons: Correctly restrict Wormadam (#4430) 2018-02-22 23:21:36 +09:00
Guangcong Luo
b773b757d2 Unban Z-evasion from Evasion Moves Clause 2018-02-20 21:55:21 +09:00
cant say
7a5f65743e Add Ultra Sinnoh Classic (#4391) 2018-01-31 22:05:58 -05: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
bb0e00e0a8 Fix STABmons move legality checker 2018-01-20 02:07:25 -06:00
Guangcong Luo
aae46ffd46 Support checkLearnset in format rules
Fixes #4356
2018-01-20 02:05:21 -06:00
Guangcong Luo
77e17eedce Add message for Switch Priority Clause Mod 2017-12-29 17:07:43 -06:00
The Immortal
1c6d98664a Fix Baton Pass clause 2017-12-13 05:28:49 +08:00
Guangcong Luo
b14463d632 Ensure SpA and SpD match in Gen 1
I'm not entirely sure why we're maintaining the separation of SpA and
SpD, except for better support of possible OMs or custom games where
they could be different, I guess.

There are probably game mechanics that would be better supported if we
actually just unified SpA and SpD.
2017-12-08 21:17:39 -06:00
Guangcong Luo
bb598ed6c2 Add rule validator for format rules 2017-12-07 22:07:12 -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
The Immortal
00ef15e5a3 Update Standard GBU and various Nintendo formats
- Add Team Preview to the Standard GBU ruleset
- Add Zeraora to the Standard GBU banlist
- Use Standard GBU for VGC 2018
- Move Dragon Cup so it’s not in-between the two Battle Spot formats
2017-11-23 14:54:25 +08:00
Guangcong Luo
aafee4393c Implement Dragon Cup 2017-11-22 13:09:00 -06:00
The Immortal
6bd1c62519 Update Alola Pokedex 2017-11-21 23:57:41 +08:00
Guangcong Luo
34f80a7340
Fix Necrozma check in Same Type Clause 2017-11-18 21:43:40 -06:00
Articuno-I
45308bf20d Account for Ultra Necrozma in Same Type Clause (#4162) 2017-11-18 16:01:48 -06:00
MacChaeger
8a6b93855a Don't default to starting Necrozma-Ultra in its base forme (#4154) 2017-11-17 00:37:44 -06:00
Kris Johnson
f2caefba9b Ultra Sun and Ultra Moon update (#4151) 2017-11-16 20:34:43 -06:00
Kris Johnson
69cc3a7bf8 STABmons: Make ignorestabmoves a ValidatorRule (#4141)
Making `ignorestabmoves` a validator rule allows it to be added to
tournaments.
2017-11-11 13:18:45 +08: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
QuiteQuiet
7f026e7e60 Do not send details about shiny-ness on Team Preview (#3965) 2017-09-06 05:53:25 -04:00
MacChaeger
b113cc9a57 Add command /viewbanlist (#3914)
This command is intended to be a quick-access option for checking banlists and rulesets for formats as well as descriptions of the rules that would get listed in case the user has questions.
2017-08-31 04:51:45 -04:00
HoeenHero
11b93ec467 Alola Pokedex rule: Dont reject alola formes (#3826) 2017-07-24 18:35:23 +04:00
Insist
83e89672a0 Add CAP LC and NFE to the Allow CAP clause (#3823) 2017-07-23 19:40:13 -04: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
Slayer95
ccd5100987 Add Nincada to Hoenn Pokedex 2017-07-13 01:56:14 -05:00
Quinton Lee
5dea359d1d Rulesets: add Gen 6 Same Type Clause
Relevant for custom formats and requested by the Monotype staff.
2017-06-08 20:33:39 -05:00
Insist
06ed00e2af Rulesets: Remove -ate clause (#3548) 2017-05-24 18:33:25 +04: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
MacChaeger
aec8b293e8 Don't tie ability and item legality to a Pokemon's tier (#3484)
Previously, only CAP Pokemon were allowed to hold Crucibellite, even in CAP, and they've apparently been able to hold Berserk Gene and other Gen 2 items this whole time.
2017-04-26 11:19:29 -07:00
MacChaeger
fa9090c38f Rulesets: Fix typo (#3479) 2017-04-24 19:44:26 +04:00
MacChaeger
9da05b8635 Refactor nonstandard banlists into rulesets (#3470) 2017-04-22 03:19:39 -04:00
Guangcong Luo
698fb2ad9a Refactor choices
PS's choice system has now been majorly rewritten!

Battle#parseChoice has been eliminated, and Battle#choose is now a
very lightweight wrapper around the BattleSide#choose* functions, which
now handle validation.

Partial decisions have been mostly removed. You can manually construct
decisions partially with the side.choose* functions, but there's no
other support for them. Partial undo has been removed completely.

Choice tracking has been renamed from side.choiceData to side.choice.
side.choices has been removed and is now autogenerated from side.choice
when needed.

side.choiceData.decisions has been renamed side.choice.actions. In the
future, "decision" is a deprecated term and should be called "action"
wherever it shows up.

side.choiceData.waiting and side.getDecisionsFinished() have been
merged into side.isChoiceDone().

Other values in side.choiceData have either been rendered unnecessary
or renamed to something clearer.

The "skip" and "pass" choices have been merged together. Passes can
still be filled in automatically (so you can just use `/move 1` in
doubles when you have only one Pokémon left).
2017-03-17 23:14:52 -05:00
The Immortal
ea54a424ce Rename Inverse Clause 2017-03-05 02:05:34 +04:00
The Immortal
d7ba9dba3a EV limit is only in gen 6 2017-03-04 12:44:03 +04:00
The Immortal
4e0901f3ea Rename Inverse ruleset
Inverse is currently used as an alias for Inverse Battle.
2017-03-04 00:04:24 +04:00
The Immortal
6a929613bd Add Inverse ruleset
This allows tournaments to add the rule to any format.
2017-03-03 21:54:11 +04:00
Guangcong Luo
eeea7e3ed0 Fix Hidden Power validation 2017-02-24 05:13:44 -06:00
The Immortal
e34318b518 Standard GBU: Fix undefined Pokemon name 2017-02-24 14:23:58 +04:00
The Immortal
f70d3cf1cc Standard GBU: Use format name for Soul Dew message 2017-02-24 13:49:28 +04:00
Guangcong Luo
d9b431b7c2 Stop converting set values to names
Because of the way fastUnpackTeam works, it's currently a reasonable
assumption that all the values in a `set` are IDs, and various parts
of the code have started to rely on that assumption.

Removing some old code to try to guarantee that the values in a `set`
are names allow us to work towards a new guarantee that `set` values
are IDs.

Closes #2553
2017-02-24 01:38:45 -06:00
Guangcong Luo
97b0652b0d Unban Soul Dew in Gen 7 BS/VGC 2017-02-23 18:22:46 -05:00
Spandan Punwatkar
17665eb1e2 Update Ability Clause to also check for Variants (#3269) 2017-02-22 23:48:55 +04:00
Quinton Lee
72236f007f Fix Z-Move validation in Baton Pass Clause (#3213)
A Pokemon can only use 1 Z-Move in battle
2017-02-10 16:07:19 -06:00
The Immortal
53ef401c51 Prevent Spiky-eared Pichu and Cosplay Pikachu in Hackmons 2017-02-01 09:50:13 +04:00
The Immortal
e60f225a7f Update Standard GBU
Only the base needs to be banned now.
2017-01-25 09:05:03 +04:00
DragonWhale
3f7a9d90ab Fix Ash Greninja not being banned on BS formats (#3185) 2017-01-24 03:02:38 -05:00
The Immortal
2762f6623f BH: Add CFZ Clause
Closes #3100
2017-01-17 17:45:35 +04:00