Commit Graph

228 Commits

Author SHA1 Message Date
Karthik
3115cfa9da
Properly replace Iron Head with Behemoth moves (#8765) 2022-05-09 13:13:31 -07:00
Karthik
49149ea8fb
Properly handle Zacian/Zamazenta Crowned forms (#8753) 2022-05-09 14:23:15 -05:00
Karthik
37eaeb735e
Fix Dynamax not starting in order of most recent speed (#8744) 2022-05-04 17:30:26 -04:00
Karthik
dfdb6e3876
Fix normal move target resolution in Triple Battles (#8735) 2022-05-04 17:29:03 -04:00
Hisuian Zoroark
e5568e5bff
Add Crazyhouse Rule (#8708)
* Add Crazyhouse Rule

* Make Pokemon import top-level, correct HP in post.

* Remove unnecessary code, improve comment
2022-04-28 18:50:48 -06:00
Alexander B
0fc554466a
Fix Choice lock after Dynamax ends (#8741) 2022-04-28 14:16:35 -05:00
Karthik
cfff8b85aa
Fix Focus Punch/Beak Blast/Shell Trap charge timing (#8733) 2022-04-25 16:35:36 -04:00
Karthik
70acfb1d0e
End Dynamax before start of 4th turn (#8719) 2022-04-18 12:15:31 -04:00
Karthik
58456cc185
Gen 1: Fix Endless Battle Clause (#8690) 2022-03-20 14:01:59 -04:00
Alexander B
7da0d43b2f
Fix battle not ending after faint from future move (#8688) 2022-03-20 14:01:36 -04:00
Andrew Werner
33dd6f4fae Gen 1: Allow EBC to stop battles that cannot progress before turn 100 2022-01-31 14:05:06 -05:00
Leonard Craft III
7cf60606c5
Fix paralysis modifier application (#8478) 2021-11-06 15:52:39 -04:00
Karthik
a95d0f38fe
Add Neutralizing Gas to ignoringAbility debug message (#8416) 2021-08-06 18:21:37 -04: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
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
Guangcong Luo
ea8e9df4e6 Further improve documentation 2021-06-10 09:17:58 -07: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
Marty-D
b830ceb818 Gen II, III: Implement Quick Claw properly 2021-06-07 12:26:50 -04: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
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
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
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
880a5d9c06 Suppress crash when forfeiting after crash 2021-05-07 00:44:15 -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
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
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
Marty-D
658b122ca8 Don't check for a winner mid-attack 2021-05-01 18:21:34 -04: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
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
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
Guangcong Luo
9ee76d7415 Fix crash in FFA forfeiting before Team Preview 2021-04-09 06:13:20 -07:00
Guangcong Luo
fc2c43e1ea Fix crash when forfeiting before battle start 2021-04-08 07:13:31 -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
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
912a2c6677
Send ally request data in multi battles (#8175) 2021-04-03 23:02:44 -07:00
Guangcong Luo
7072a87010 Fix canceling in 4-player games 2021-04-03 19:14:09 -07:00
pyuk-bot
2b9bb1c4c4
Multi Battle: Run residuals on p3 and p4 (#8170) 2021-04-03 02:44:38 -07:00
Guangcong Luo
ef16d0f4d4 Fix FFA games not ending on some forfeits 2021-04-03 02:02:40 -04:00
Guangcong Luo
694e79eea8 Add form for inviting players
(This makes it so you don't need to use console commands)
2021-04-02 23:00:30 -07:00
Guangcong Luo
1acffa98b3 Fix forfeiting in FFA 2021-04-01 14:46:00 -07:00
Guangcong Luo
86df524adc Support forfeiting in free-for-all battles
I honestly don't understand HOW it works, but it definitely works.
2021-04-01 04:44:16 -07:00
Guangcong Luo
44ef998ecc Implement free-for-all
This involves a huge refactor for how battles are constructed, but
it's totally worth it.

Currently, tournaments, challenges, and laddering are unsupported; only
unrated searches work. But it does work, and it's beautiful.
2021-04-01 04:44:16 -07:00
Spandan Punwatkar
b77d6cb20f
Add simulator support for multi battle (#7929)
This doesn't include matchmaking support (which had to be removed
for reworking), but it includes everything else.

Co-authored-by: Spandamn <spandan.punwatkar@gmail.com>
Co-authored-by: MacChaeger <msaimrkon@gmail.com>
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
2021-03-31 22:22:25 -07:00
Guangcong Luo
3b5e8cbfc2
Refactor for multi battles (#8152) 2021-03-31 20:27:07 -07:00