Commit Graph

39 Commits

Author SHA1 Message Date
Guangcong Luo
78439b4a02
Update to ESLint 9 (#10926)
ESLint has a whole new config format, so I figure it's a good time to
make the config system saner.

- First, we no longer have separate eslint-no-types configs. Lint
  performance shouldn't be enough of a problem to justify the
  relevant maintenance complexity.

- Second, our base config should work out-of-the-box now. `npx eslint`
  will work as expected, without any CLI flags. You should still use
  `npm run lint` which adds the `--cached` flag for performance.

- Third, whatever updates I did fixed style linting, which apparently
  has been bugged for quite some time, considering all the obvious
  mixed-tabs-and-spaces issues I found in the upgrade.

Also here are some changes to our style rules. In particular:

- Curly brackets (for objects etc) now have spaces inside them. Sorry
  for the huge change. ESLint doesn't support our old style, and most
  projects use Prettier style, so we might as well match them in this way.
  See https://github.com/eslint-stylistic/eslint-stylistic/issues/415

- String + number concatenation is no longer allowed. We now
  consistently use template strings for this.
2025-02-25 20:03:46 -08:00
pyuk-bot
7bb2fd1869
Overhaul 'SwitchIn' event for more accurate effect resolution order (#10766) 2025-01-28 16:51:17 -06:00
Leonard Craft III
27557e5fdc
Convert noSketch to move flag (#10407) 2024-07-14 23:45:10 -05:00
Guangcong Luo
88be8d7b3c
Refactor types for Lowercase<string> (#10377)
TypeScript 4.8+ supports Lowercase for lowercase strings, which isn't
exactly what ID is, but can be used to type IDs in object keys and data
entries that previously required string. I'm calling it IDEntry in places
where it should be an ID but TypeScript doesn't support that.

Very conveniently, no additional casts will be needed when using ID
where IDEntry is expected.

It's caught at least a few bugs, which is also why I'm PRing: I didn't
write the code for the bugs it found, and don't know if it's the right
way to fix them.

This ballooned into several other type refactors.
2024-07-01 15:57:14 -07:00
Karthik
d99f4bc978
Fix Flail/Reversal BP modifier in Gen 2-3 (#10315) 2024-05-23 21:47:17 -05:00
Karthik
73041e4137
Refactor noMetronome lists to metronome flag (#10110) 2024-01-13 14:00:19 -06:00
Leonard Craft III
156a39405f
Refactor some move lists to move flags (#9396) 2023-03-18 22:21:00 -05:00
livid washed
04e2401688
Gens 2-3: Fix accuracy of moves (#9143)
* Gen 2: Lock-On and Pain Split have 100% accuracy and check for accuracy

* Gen 3: Moves that don't check accuracy should be listed as true accuracy

* Gen 3: Nightmare doesn't check for accuracy

* Gen 3: Foresight and Odor Sleuth check accuracy

* Gen 3: Memento does not accuracy check

* Gen 3: Mind Reader checks accuracy

* Gen 2: Nightmare doesn't check accuracy
2022-12-08 16:06:03 -08:00
Leonard Craft III
59b7a04ae8
Add more debug messages for moves with custom base power (#8977) 2022-11-14 19:58:07 -06:00
Kris Johnson
2648a467f3 ADV: Ensure certain 100% accuracy moves never miss 2022-09-30 21:42:52 -06:00
Karthik
a77de95784
Gen 3: Fix Sleep Talk interaction with Encore/Choice Item (#8762) 2022-05-12 18:57:13 -04:00
Marty
450da1638b Gens II-IV: Correct Encore duration 2022-05-04 17:51:29 -04:00
Marty-D
675b393796 Gen II-IV: Hide Beat Up message
As per https://www.smogon.com/forums/posts/8992145/
2021-10-26 18:47:32 -04:00
Karthik
4f791ef852
Gen III-IV: Fix Uproar duration (#8450) 2021-09-05 12:46:11 -04:00
pacmanboss256
23b35498f6
Rename the "mystery" and "authentic" move flags (#8445)
* mystery -> allyanim
* authentic -> bypasssub
2021-08-30 23:07:50 -07:00
Marty-D
5281f3bac3
Gen III: Fix Beat Up fix 2021-08-15 09:35:34 -04:00
Marty-D
6e25dc78cd
Gen III: Fix Beat Up category 2021-08-14 15:24:08 -04:00
Marty-D
a5929b3076 Gen III: Make Follow Me a slot condition
Thanks, xzern!
2021-06-23 11:32:43 -04:00
Karthik
7988f15526
Gen 3: Always break the opponent's screens with Brick Break (#8325) 2021-05-25 15:39:40 -04:00
pacmanboss256
91f86530c5
Fix Gen 3 Weather Ball and Gen 4 Trick (#8314) 2021-05-24 15:07:37 -04:00
Leonard Craft III
d946308900
Fix the order of many end-turn resolution effects (#8307)
Co-authored-by: Marty-D <Marty-D@users.noreply.github.com>
2021-05-17 11:53:52 -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
Marty-D
94840470c3 Make sure Bide actually ends 2021-04-12 10:52:46 -04: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
Guangcong Luo
3b5e8cbfc2
Refactor for multi battles (#8152) 2021-03-31 20:27:07 -07: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
c2e97aaaed
Use optional chaining in more places (#8063) 2021-02-22 11:42:05 -08:00
Marty-D
1ed4d58b7e
Gen III: Fix Weather Ball
I realize this isn't actually correct, but at least it's less incorrect for now.
2020-11-20 18:24:29 -05:00
Marty-D
2d0e06e497 Past Gens: Fix Fury Cutter 2020-11-09 18:10:05 -05:00
urkerab
bcc6fddff5
Remove duplicate fail message from Encore (#7339) 2020-09-09 04:32:28 +04:00
Guangcong Luo
ea8f52ce97
Move descriptions to data/text/ files (#7036)
This adds some new `data/text/` files, which are the new home for
item/move/ability descriptions, as well as in-game messages, in one
place for ease of translation.
2020-09-06 22:00:11 -07:00
Kris Johnson
324ad0425a
Fix various GSC/ADV mechanics (#7247) 2020-08-22 01:29:41 -07:00
Guangcong Luo
4d09f7acde Rename more instances of Effect to Condition 2020-07-26 11:26:23 -07:00
Guangcong Luo
2f805c93a2
Remove "Battle" prefix from data exports (#7039)
`BattlePokedex` is now `Pokedex`, `BattleItems` is now `Items`, etc.

I also renamed `Movedex` to `Moves` and `Statuses` to `Conditions`.

`TypeChart` isn't `Types` yet, because unlike the others, it's not
indexed by ID. That should probably be fixed one day.
2020-07-24 12:42:26 -07:00
Mia
6839a1f4db
Add a library for utility functions (#6817) 2020-06-09 22:06:43 -07:00
Guangcong Luo
549ef7edb1 Fix MoveData interface definition
For historical reasons, move property definitions have been very blurry
across `EffectData`. Fortunately, recent refactors have made it
possible to put them all where they're supposed to be.
2020-04-25 12:57:46 -07:00
Guangcong Luo
31a81a91a2 Fix @type in .ts files
Some JSDoc type assertions failed to get converted during various .ts
refactors. This commit takes care of them.
2020-04-24 14:19:08 -07:00
Marty-D
e03d6e9020
Gen III: Remove obsolete code 2020-04-24 15:03:04 -04:00
Kris Johnson
28bf388b98
Typescript data (#6553) 2020-04-23 09:16:09 -07:00