Commit Graph

938 Commits

Author SHA1 Message Date
Leonard Craft III
d49a40feb2 Tests: Improve G-Max Volcalith Sea of Fire test 2021-04-26 22:52:59 -05: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
urkerab
9a18ada1f9
Grassy Terrain should only weaken moves against grounded targets (#8224) 2021-04-24 18:04:31 -05:00
Leonard Craft III
7c89412d9a Remove accidental .only 2021-04-24 16:24:45 -05:00
Leonard Craft III
ab0cb0d29e Improve Grassy Terrain tests 2021-04-24 16:24:01 -05:00
Guangcong Luo
486f292904
Refactor everything to use Utils.sortBy (#8220)
A few uses of `array.sort()` have been left alone:

- sorting in `data/` because they aren't supposed to import anything

- `set-importer` because I still have no clue what that's for and what
  dependencies it is/isn't allowed to have

- `sort()` with no arguments used as a lexical sort (at which point
  `sortBy` offers no benefits)

All other cases have been replaced with `Utils.sortBy`, which should
be a massive increase in readability.

Sort orders should be much more readable now, without needing to puzzle
through sign issues. The order is always low-to-high, A-to-Z,
true-to-false.
2021-04-23 22:41:00 -07:00
Kris Johnson
a1bdafbfe8
Add room sections (#8205) 2021-04-23 22:39:56 -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
Karthik
adb164ad51
Fix Magician activation timing (#8202)
Use onAfterMoveSecondarySelf so Weakness Policy happens first
Fixes #8104
2021-04-17 12:26:29 -04:00
Kris Johnson
d0fd8ac8e0 Fix build 2021-04-16 21:47:38 -06:00
Kris Johnson
f4fda49201 Update Battle Factory tests and command 2021-04-16 17:35:26 -06: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
12670422d0 Remove duplicate test 2021-04-09 23:44:05 -05: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
d858bbda30
Validator: Disallow duplicate moves (#8191) 2021-04-09 20:59:20 -07:00
Guangcong Luo
5cf59da9f0 Add unit test for having valid formats 2021-04-09 18:04:40 -07:00
Annika
b4da54c6da Fix typo in comment 2021-04-09 17:22:25 -07:00
Annika
3ca947225f Random Battles updates 2021-04-09 17:13:18 -07:00
Annika
2baca9339d Random Battles: Fix STAB in 4-player battles 2021-04-09 16:23:23 -07:00
Christopher Monsanto
99fd7b8706
Chat: Implement Discord spoilers (#7948) 2021-04-09 01:39:47 -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
May Evans
1365091eed
Rename OU (Tradeback) to Tradebacks OU (#8185) 2021-04-07 11:27:27 -07:00
Karthik
3b1d3844dd
Negate Unburden while Neutralizing Gas is active (#8182) 2021-04-06 12:13:05 -04:00
Leonard Craft III
54ebad4d2f Improve Thousand Arrows tests 2021-04-05 22:49:32 -05:00
Guangcong Luo
77d231eee5 Fix Disguise vs Steelsurge 2021-04-03 18:30:19 -07:00
Leonard Craft III
897a798db6 Expand G-Max Steelsurge test 2021-04-03 19:02:50 -05:00
pyuk-bot
817addfd62
Fix Follow Me, etc. in FFA (#8173) 2021-04-03 15:16:27 -07:00
HoeenHero
47d8bd4d82
Fix hazards not applying if the target side is fainted (#8171)
Co-authored-by: pyuk-bot <msaimrkon@gmail.com>
2021-04-03 15:15:13 -07:00
pyuk-bot
19111bda58
FFA: Don't retarget from a fainted target (#8166) 2021-04-03 01:50:00 -07:00
pyuk-bot
956daf89b6
FFA: Properly set hazards against all foes' sides (#8165) 2021-04-02 23:15:19 -07:00
Guangcong Luo
caf46800ee Rename format from "4 Player" to "Free-For-All"
Users seem to find the latter clearer.
2021-04-02 23:00:29 -07:00
urkerab
d4e6fb227c
Fix Aromatherapy failing if the right slot has a Substitute (#8151) 2021-04-02 17:35:04 -04:00
Karthik
19ae4f693f
Check for Berserk before eating Berries (#8147) 2021-04-02 17:30:34 -04:00
Guangcong Luo
791ded0aa2 Rename FFA to "4 Player" for clarity 2021-04-01 23:37:47 -07:00
Guangcong Luo
ff141e3f80 Fix tests 2021-04-01 23:11:15 -07:00
Guangcong Luo
1acffa98b3 Fix forfeiting in FFA 2021-04-01 14:46:00 -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
Guangcong Luo
39f5717c25 Fix repeate mega evolution bug 2021-03-31 22:16:06 -07:00
Karthik
258269348c
Allow Berries to be used between Unnerve switching to Unnerve (#8145) 2021-03-31 10:07:36 -04:00
Guangcong Luo
ed454ef76a
Refactor scripts to battle-actions (#8138)
This introduces a new class, BattleActions, available as `battle.actions`,
moving all functions from `data/scripts.ts` to `sim/battle-actions.ts`.

This makes it so that "go to definition" will now work correctly for
functions previously in scripts; we no longer need UnimplementedError,
and there's now a clean conceptual separation between `battle` and
`battle-actions` (whereas the previous distinction between `battle` and
`scripts` was basically nonexistent).

This will be a difficult migration if you maintain a fork with custom
scripted mods. I'm sorry! Migration instructions are here:

https://github.com/smogon/pokemon-showdown/pull/8138
2021-03-28 12:01:38 -07:00
Annika
9e7074572e Random Battles update 2021-03-26 15:45:59 -07:00
Guangcong Luo
619a1e228d
Stadium: Apply BRN Atk drop once instead of 5x (#8139) 2021-03-25 23:38:55 -07:00
urkerab
d395d18591
End Uproar if the user is under the effect of Throat Chop (#8135)
SadisticMystic confirmed that the user of Uproar simply calms down at the end of the current turn.
2021-03-23 17:42:41 -04:00
Annika
c1fa436e35 Trivia: Implement a /trivia unrankednew command
This enables the creation of Trivia officials that do not reward points.
2021-03-20 12:30:46 -07:00
Leonard Craft III
9db5e91afa Improve Thick Fat tests 2021-03-19 21:46:54 -05:00
Annika
ff56f7e503 Random Battles update 2021-03-19 18:28:08 -07:00
Annika
ffd0092bfb Random Battles: Add basic unit test framework
This will save me a lot of time typing in `/eval`s on localhost to test, and also hopefully catch regressions!
2021-03-18 18:17:25 -07:00
Marty-D
d1c80dc60f Validator: Fix Diancie exception
Thanks Anubis!
2021-03-08 12:57:53 -05:00