Commit Graph

1124 Commits

Author SHA1 Message Date
Kris Johnson
ec01ee46c4 Multibility: Fix more bugs 2021-10-14 14:52:46 -06:00
Kris Johnson
d92665cd3e
Fix validating Pokemon with event-only prevolutions (#8495) 2021-10-13 19:55:29 -07:00
En Passant
21dfd5470d
Add "Sketch Gen 8 Moves" rule (#8431) 2021-10-09 19:05:05 -07:00
Karthik
f542c0d347
Support banning specific Gigantamax formes (#8492) 2021-10-09 12:59:53 -07:00
Marty-D
573e2b26bb Fix Natural Cure implementation 2021-10-06 19:23:34 -04:00
Kris Johnson
3d21b252f9 Fix parts of Multibility 2021-10-01 14:34:05 -06:00
Kris Johnson
0aa3877f3f Add October 2021 OMotM and RoA Spotlight 2021-10-01 14:12:53 -06:00
Leonard Craft III
62efd9225c
Gen 1: Correct minimum level validator logic (#8455) 2021-09-07 19:40:33 -05:00
Karthik
d33bbfeba5
Use |-swapsideconditions| for Court Change (#8287) 2021-09-01 11:57:16 -04:00
pacmanboss256
23b35498f6
Rename the "mystery" and "authentic" move flags (#8445)
* mystery -> allyanim
* authentic -> bypasssub
2021-08-30 23:07:50 -07:00
Mia
7811795344
Handle new TypeScript version (#8449)
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
2021-08-30 20:11:44 -07:00
Mia
472f349799 Fix build 2021-08-27 22:04:20 -05:00
Karthik
faa37924ee
Fix Emergency Exit not activating after recoil damage (#8441) 2021-08-21 13:17:23 -05:00
Marty-D
131b9b81ef
Fix build 2021-08-15 09:47:07 -04:00
Karthik
a95d0f38fe
Add Neutralizing Gas to ignoringAbility debug message (#8416) 2021-08-06 18:21:37 -04:00
TheSupervillain
77bcaf4e33
Ignore 10000 speed upper limit in Custom Game (#8392) 2021-07-11 18:58:51 -07:00
Annika
e530cee6f1 Fix bugs with Sucrase build process 2021-07-11 11:54:22 -07:00
Annika
a499393c12 Fix build 2021-07-10 17:19:39 -07:00
Annika
491ce58234 Fix dex-formats in Sucrase build 2021-07-10 14:37:16 -07:00
Annika
c134195915
Use ts-node instead of Sucrase (#8369) 2021-07-09 19:59:22 -07:00
Kris Johnson
598ac409e8 Rename Let's Go! mod to 'gen7letsgo' 2021-07-06 23:07:51 -06:00
Guangcong Luo
3a4300e757 Always have a 1000-turn limit
Previously, you would need to opt into Endless Battle Clause to
have a 1000-turn limit. It is now enforced for all battles always.
2021-07-03 15:22:25 -05:00
Kris Johnson
9e217d34c2 Add July 2021 OMotM, LCotM, and RoA Spotlight 2021-07-01 10:47:55 -06:00
TheSupervillain
bfe92102c8
Gen 1: Fix Transform and Endless Battle Clause (#8372)
Gen 1 Endless Battle Clause now accounts for:

- frozen pokemon
- Struggle against Ghosts
- Ditto transforming into Ditto

Gen 1 Stadium now correctly simulates Transform failing in Transform-vs-Transform situations.
2021-06-28 22:42:16 -07:00
Marty-D
18446f02cc
Gen IV: Fix multi-hit behaviour while asleep 2021-06-14 17:18:45 -04:00
Guangcong Luo
8f87b6b84b Move packed team docs out of PROTOCOL.md
Packed team docs are now standardiszed in sim/TEAMS.md

(Also a bunch of smaller documentation improvements.)
2021-06-10 15:04:25 -07:00
Guangcong Luo
ea8e9df4e6 Further improve documentation 2021-06-10 09:17:58 -07:00
Guangcong Luo
ddb6010bb9 Support importing teams
We now have a `Teams.import` function. This supports importing teams
in any format, allowing it to be the backbone of a new series of
commandline functions, which support teams in any format.
2021-06-09 22:08:31 -07:00
Guangcong Luo
5d3b758564 Fix documentation 2021-06-09 19:19:43 -07:00
Guangcong Luo
a813a55679 Document changes and Dex
With Dex now having basic documentation, all our API documentation is
now inter-linked.
2021-06-09 17:51:49 -05:00
Guangcong Luo
f47e38c5ad Support building TS declarations
`./build decl` now builds TS declarations for everything exported by
`sim/`. Unfortunately, the built TS declarations still refer to global
types, so some things still have `any` type, but it's much better than
nothing.
2021-06-09 17:51:49 -05:00
Guangcong Luo
147b7e01c9 Export lib/ from sim/
This is a dumb hack, but it allows everyone to use PS's lib files
with `require('pokemon-showdown')`.

This is EXTREMELY unsupported and I make ZERO guarantees about API
stability.
2021-06-09 16:16:05 -05:00
Adam Tran
be2210f881
Fix Future Sight Life Orb interactions (#8357) 2021-06-08 11:48:10 -04:00
Marty-D
b830ceb818 Gen II, III: Implement Quick Claw properly 2021-06-07 12:26:50 -04:00
Guangcong Luo
da8f77ee4f Document Sim.Teams for NPM package 2021-06-06 10:29:40 -05:00
Guangcong Luo
74211859c9 Update to TypeScript 4.3
Changes relevant to our codebase:

- TypeScript now knows that `typeof id === 'string'`! A bunch of casts
  on `User | ID` or `Room | RoomID` are no longer necessary!!!

- `override` will protect against certain typoes, and we'll adopt it
  (and `--noImplicitOverride`) as soon as sucrase comes in

- `declare` is now required for properties we want to narrow the type
  of without directly overwriting - a good thing to use going forward,
	but very annoying to fix all our old code for
2021-05-26 14:16:54 -07:00
Guangcong Luo
743153ac32 Fix defaultLevel
defaultLevel should not be set to maxLevel if this would make teams break
maxTotalLevel.

Fixes a bug where level 100 pokemon were automatically set to higher
levels in cases where it didn't make sense.
2021-05-26 12:44:44 -04:00
Guangcong Luo
d555f6fe0d Fix max-len for long regexes
We use eslint-disable for max-len in a lot of places where we don't
actually need it. This fixes that.
2021-05-23 20:48:31 -07:00
Instruct
7143939f1c
Gen 6 Hackmons: Fix EV limit and comment (#8329) 2021-05-23 18:25:12 -07:00
Guangcong Luo
4a2d386c55 Fix VGC EV validation 2021-05-23 17:16:13 -07:00
Guangcong Luo
e511d5c646 Fix EV validation 2021-05-23 16:55:00 -07:00
Guangcong Luo
9c98ae5c87 Rules: Split "EV Limit" out from "Obtainable Misc"
"EV Limit = 510" is now its own rule which can be changed separately
from the rest of Obtainable Misc.

The rest of Obtainable Misc doesn't seem useful to break up, so I
haven't bothered.
2021-05-23 15:14:00 -07:00
Guangcong Luo
570d3d3d29 Fix Weezing-Galar from VC Koffing validation
This fixes an issue where a Weezing-Galar evolved from a Koffing
gotten from a Virtual Console transfer from RBY/GSC should be able
to have a non-Hidden Ability, but couldn't.

Thanks @Karthik99999 for bringing this to my attention.

Fixes #8327
2021-05-23 11:29:17 -07:00
Marty-D
008cfec4c3 Run events on future moves even while the user is not active
Fixes a regression in 16d078265b
2021-05-20 13:20:12 -04:00
Marty-D
866b5b7bb2 Check for a winner when Destiny Bond knocks out a Pokemon 2021-05-20 12:22:37 -04:00
Guangcong Luo
2936c55439 Rules: Add -no item and fix -all items
`no item` is now a fake item meaning "not holding an item", for the
purposes of the team validator. This means that `-no item` will force
all pokemon to carry items.

`all items` no longer includes not holding an item, so `-all items`
will now work as expected.
2021-05-17 04:22:24 -07:00
Leonard Craft III
f7465fd369
Gen I-II: Cap initial max PP at 61 (#8309) 2021-05-15 21:42:25 -07:00
Leonard Craft III
5a129fd1d7
Gen VII: Ignore user's Ability with Mold Breaker moves (#8306) 2021-05-15 14:38:21 -04:00
Marty-D
0a9aeb8fcd
Fix faint check mid-attack (#8297)
Only bother checking for a winner if the move's user is also fainted at the time, and check for a winner after the move completes.
2021-05-14 13:36:56 -04:00
pacmanboss256
4186ef5f4f
Refactor Mold Breaker effect (#8291) 2021-05-14 08:32:41 -04:00
Guangcong Luo
518ac11520 Validate Max Team Size
Fixes #8286
2021-05-13 23:45:55 -07:00
Karthik
ec2df7ceb4
Fix validator message for LGPE Pokemon (#8298) 2021-05-12 14:15:59 -04:00
Annika
62571c4907
Validator: Improve Gen 1 level validation (#8294) 2021-05-12 02:59:12 -07:00
Guangcong Luo
7e965b41a7 Revert timing for adding rules to field in #8274
It turns out rules need to be added before sides are initialized,
so that they can hook `ModifySpecies` during side initialization.

The proper way to fix this is pretty complex so this is just a hack.
2021-05-11 23:02:01 -07:00
Guangcong Luo
638c1e3ae8 Add "Max Move Count" value rule
Also stop enforcing 4 moves limit and 6 pokemon limit in `-Nonstandard`,
for the same reason we stopped enforcing the level 100 limit; any format
that explicitly wants it higher should automatically override it.
2021-05-07 02:16:24 -07:00
Guangcong Luo
880a5d9c06 Suppress crash when forfeiting after crash 2021-05-07 00:44:15 -07:00
Guangcong Luo
df42a795f9 Remove max level check from -Nonexistent
Anyone who sets a max level above 100 is opting in, so there's no
need to add a redundant check on top of that.
2021-05-06 21:19:04 -07:00
Guangcong Luo
36295dc27a
Simplify Team Preview events (#8274)
In format events:

`onFieldTeamPreview` has been renamed back to `onTeamPreview`. It's now
a custom event (like `onBegin`), rather than a field event.

Team Preview data has been entirely moved from `onBegin` into
`onTeamPreview`.

`onFieldStart` for formats/rules now happens after Team Preview, rather
than before. Use `onBegin` for things that happen before Team Preview.
2021-05-06 18:53:58 -07:00
Guangcong Luo
16e9a0eeec Fix bugs in value rule refactor 2021-05-06 07:49:17 -04:00
Guangcong Luo
55980d416c
Support value rules (#8267)
`teamLength`, `maxLevel`, `cupLevelLimit`, and `minSourceGen` no longer
exist as properties of `Format`. Instead, they're value rules that
become properties of `RuleTable`, and can be specified as custom rules
and inherited through rulesets like anything else.

See the PR for a full reckoning of changes:

https://github.com/smogon/pokemon-showdown/pull/8267
2021-05-06 01:16:16 -07:00
Guangcong Luo
1bf172fe7e Refactor: Move getTagRules inside RuleTable 2021-05-06 00:30:07 -07:00
Leonard Craft III
771c60d4b9
Improve self-hit confusion damage (#8264) 2021-05-04 13:44:13 -04:00
Guangcong Luo
edb45ebecc Refactor rule iteration 2021-05-04 04:50:58 -07:00
Guangcong Luo
c11dccb032
Rename and fix maxTeamSize (#8266)
`maxTeamSize` is a bad variable name (not that `teamLength.battle` is
any better, but that'll get fixed in a future refactor).

- Rename `maxTeamSize` to `chosenTeamSize`, to better indicate that
  this is the size after Team Preview, and that it is also the minimum
  size after Team Preview.

- Don't limit team sizes to 6 if `teamLength.battle` isn't specified.
  This removes an unnecessary `teamLength.battle` requirement in all
  Custom Game formats.

- Stop requiring `maxTeamSize` as a parameter for `battle.getRequests`.
  It's not even used except as a hint to the Preact client, and was
  never state in the first place.

- Stop supporting partial `side.chooseTeam`. This is an unused feature
  and removing it massively simplifies the code and fixes a bug in
  `cupLevelLimit` which definitely was not written with the
  understanding that `chooseTeam` could be partial.

- Fix a bug in #7929 which seemed to misunderstand what `teamsize` was
  for.
2021-05-04 00:31:05 -07:00
Marty-D
f853d63653 Revert "Don't check for a winner mid-attack"
This reverts commit 658b122ca8.
2021-05-01 19:25:47 -04:00
Guangcong Luo
f253af89df Fix crash in Sketchmons validator 2021-05-01 15:40:04 -07:00
Marty-D
658b122ca8 Don't check for a winner mid-attack 2021-05-01 18:21:34 -04:00
Guangcong Luo
230a9427c9 Fix crash in isBannedSpecies 2021-05-01 13:56:25 -07:00
Daniel Wan
b58cfbae5d
Fix interaction of Destiny Bond and Red Card (#8219) 2021-05-01 14:02:34 -04:00
Instruct
a9d4374e59
Tag Mythical and Legendary pokemon (#8142) 2021-04-30 21:34:17 -07:00
Guangcong Luo
70bef9b1ae Improve error message for nonexistent pokemon 2021-04-30 20:12:18 -07:00
Guangcong Luo
b82ee0588e Fix bug in ban reason message 2021-04-30 20:07:40 -07:00
Guangcong Luo
4d70b0a46a
Use data/tags for validator (#8218)
Previously, the validator had its own hardcoded tag system. This
removes the hardcoding and makes it so any pokemon tag in `tags.ts`
can be banned or unbanned.
2021-04-30 18:20:30 -07:00
Kris Johnson
5b8dfc7d8e [Gen 1] Japanese OU: Allow Japanese event moves 2021-04-30 01:55:06 -06:00
Guangcong Luo
a1b52d4223 Fix bug in mega-evo speed tie code
(thanks @urkerab for review)
2021-04-29 02:33:49 -07:00
Guangcong Luo
7d235af30f Fix speed ties after mega evolution 2021-04-29 00:23:55 -07:00
pyuk-bot
fa974427ef
Migrate terrains from onTerrain to onResidual (#8232) 2021-04-25 13:00:37 -07:00
Guangcong Luo
f9fdc73133
Support per-pokemon Residual handlers in Side/Field conditions (#8222)
For side conditions, `onStart`/`onRestart`/`onResidual`/`onEnd`
have been renamed `onSideStart`/`onSideRestart`/`onSideResidual`/`onSideEnd`,
with the `onResidualOrder` properties renamed `onSideResidualOrder`.

For field conditions, `onStart`/`onRestart`/`onResidual`/`onEnd`
have been renamed `onFieldStart`/`onFieldRestart`/`onFieldResidual`/`onFieldEnd`,
with the `onResidualOrder` properties renamed `onFieldResidualOrder`.

(The `onField` and `onSide` part helps make it clear to the type system
that the first argument is a Field or Side, not a Pokemon.)

Side and field conditions can now use `onResidual` to tick separately
on each pokemon in Speed order. `onResidualOrder` (the per-pokemon
tick) can be timed separate from `onSideResidualOrder` (the
per-condition tick), allowing conditions to end at a different priority
than they tick per-pokemon.

Relatedly, `onTeamPreview` and `onStart` in formats now need to be
`onFieldTeamPreview` and `onFieldStart`.

Unrelatedly, `effectData` has been renamed `effectState`, and the
corresponding state containers (`pokemon.statusData`,
`pokemon.speciesData`, `pokemon.itemData`, `pokemon.abilityData`,
`field.weatherData`, `field.terrainData`) have been similarly renamed. I
renamed the types a while ago, but I was holding off renaming the fields
because it would be a breaking change. But this is a breaking change
anyway, so we might as well do it now.

Note: `onResidual` will tick even on `onSideEnd` turns, although
`onSideResidual` won't. When refactoring weather, remember to
check `this.state.duration` so you don't deal weather damage on the
ending turn.

Intended as a better fix for #8216
2021-04-25 10:55:54 -07:00
pyuk-bot
66c547432b
Fix Parental Bond to modify damage, not base power (#8226) 2021-04-25 12:06:27 -04:00
InAShellnut
9ab4c86fe3
Add Stadium 2, Nintendo Cup 1997, and Nintendo Cup 2000 (#8195)
An implementation of Nintendo Cup 1997, Nintendo Cup 2000, and Pokemon Stadium 2, for Pokemon Showdown. The only thing which has not been implemented was showing the exact health of both Pokemon in Pokemon Stadium 2, however implementing that requires changes to the showdown client. The Nintendo Cup 1997 code was done by Enigami, and the rest was by myself (Shellnuts).

This should fulfill the requirements asked by the following accepted suggestions:
https://www.smogon.com/forums/threads/please-add-a-pok%C3%A9mon-stadium-2-simulator-in-showdown.3679486/
https://www.smogon.com/forums/threads/add-nintendo-cup-1997-and-2000-as-challenge-only-formats.3653454/
2021-04-22 00:54:14 -07:00
pyuk-bot
3639079d1f
Protective Pads should not apply to Gulp Missile (#8207)
Co-authored-by: Leonard Craft III <leonardcraft64@gmail.com>
2021-04-19 12:39:33 -04:00
Leonard Craft III
4818c50374
Fix Transform source Ability leak (#8204) 2021-04-17 15:06:40 -07:00
Kris Johnson
fc60b76c48 Add new Pet Mod of the Season 2021-04-13 20:55:47 -06:00
Annika
a59296cbbb Fix crash in simulator runner 2021-04-11 23:31:58 -07:00
Guangcong Luo
5c3d0f5eae Fix deterministic speed ties
We have apparently been sorting everything by switch-in order this
entire time, not just move redirection. This appears to be a mistake
in #5216

The actual bug fix is just the single line in `comparePriority`,
everything else is just documentation, and a bit of optimization of
how speed ties are resolved.

Fixes #6319
2021-04-10 09:41:22 -07:00
Leonard Craft III
f8cfe3a242 Validator: Don't enforce 3 IV minimum in Hackmons 2021-04-09 23:40:16 -05:00
Leonard Craft III
ba66ffde0f Validator: Fix Behemoth moves 2021-04-09 21:10:38 -05:00
Guangcong Luo
9ee76d7415 Fix crash in FFA forfeiting before Team Preview 2021-04-09 06:13:20 -07:00
Guangcong Luo
6658d65c40 Properly fix Keldeo-R 2021-04-08 14:48:03 -04:00
Guangcong Luo
1ae9f90393 Possibly fix a format corruption issue 2021-04-08 08:07:30 -07:00
Guangcong Luo
73353990ad Add some safety for formats
A weird bug with OU lacking Team Preview might be caused by this.
2021-04-08 07:23:15 -07:00
Guangcong Luo
fc2c43e1ea Fix crash when forfeiting before battle start 2021-04-08 07:13:31 -07:00
Guangcong Luo
5233559183 Refactor Dex types 2021-04-08 07:08:56 -07:00
Guangcong Luo
34880b65e1 Sim: Revert AfterBoost event change
It turns out I accidentally had whole word matching turned on when
I searched the codebase for `AfterBoost`, so I missed all the
`onAfterBoost` uses. :[
2021-04-08 06:22:31 -07:00
Guangcong Luo
2a5c80e707 Sim: Only run AfterBoost when boosts succeed 2021-04-08 06:08:43 -07:00
Guangcong Luo
05e28925a7 Fix Mega Rayquaza and Keldeo-R validation 2021-04-08 06:02:43 -07:00
Guangcong Luo
53924a9ca5 Fix Pokébilities and Shared Power
This fixes `pokemon.addVolatile('ability:intimidate')` to be able to
add abilities as volatile statuses, for use in OMs that want to have
more than one ability at a time.

Items are now also supported, for instance as
`pokemon.addVolatile('item:choiceband')`.

As usual, abilities and items are not written with this functionality
in mind, so it's the OM's job to fix any crashes caused by
abilities/items not expecting to be used as volatiles.
2021-04-08 05:38:36 -07:00
Guangcong Luo
13189fdb02
Update Dex API (#8181)
This is the change that renames:

- `Dex.getMove` -> `Dex.moves.get`
- `Dex.getAbility` -> `Dex.abilities.get`
- `Dex.getItem` -> `Dex.items.get`
- `Dex.getSpecies` -> `Dex.species.get`
- `Dex.getEffect` -> `Dex.conditions.get`
- `Dex.getNature` -> `Dex.natures.get`
- `Dex.getType` -> `Dex.types.get`
- `Dex.getFormat` -> `Dex.formats.get`

In addition, some other APIs have been updated:

- `getByID` methods have also been added to every other table.
- `Dex.moves.all()` now gets an array of all moves
  - Plus equivalent methods for `abilities`, `items`, `species`, `formats`, `natures`, `types`
  - Note: there's no `Dex.conditions.all()`
- new API: `Dex.stats` for naming/iterating stats
- `Dex.getEffectByID` -> `Dex.conditions.getByID`
- `Dex.getType` -> `Dex.types.get`
- `Dex.data.Formats` -> `Dex.data.Rulesets`
- `Dex.formats` -> now an array `Dex.formats.all()`
- `Dex.getRuleTable` -> `Dex.formats.getRuleTable`
- `Dex.validateFormat` -> `Dex.formats.validate`

Team functions have been split off into a new `sim/teams` package:

- `Dex.packTeam` -> `Teams.pack`
- `Dex.fastUnpackTeam` -> `Teams.unpack`
- `Dex.generateTeam` -> `Teams.generate`
- `Dex.stringifyTeam` -> `Teams.export`

`Teams.export` has also been rewritten to better match how it works in client.

This implements #8178
2021-04-08 03:00:37 -07:00
pyuk-bot
636ebdd7f8
FFA: Apply GMax side conditions to all foes' sides (#8184)
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
2021-04-06 20:55:43 -07:00
pyuk-bot
912a2c6677
Send ally request data in multi battles (#8175) 2021-04-03 23:02:44 -07:00