Commit Graph

31 Commits

Author SHA1 Message Date
Guangcong Luo
e9ec82327f Rename files in data for consistency
- rulesets.ts -> format-rules.ts
- formats-data.ts -> pokedex-tiers.ts

Variable names were updated to match.
2024-07-02 03:06:33 -07: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
06d88748a5
Refactor STAB (again) (#10099) 2024-01-13 23:48:47 -06:00
Guangcong Luo
7a5ced456d Fix crash in getRuleTable
We made one too many things immutable.
2023-12-08 23:29:54 -05:00
Guangcong Luo
9cd64cba15 Freeze cached Sim objects
We're hunting ~~wabbits~~ validator bugs.

Honestly, this has been a long time coming, but Object.freeze perf
used to not be good enough for us to use it here. Here's hoping!
2023-12-07 01:26:51 -05:00
pyuk-bot
4e0abbe246
Sharing is Caring: Fix Big Root + healing berry (#9817) 2023-10-03 12:03:38 -06:00
pyuk-bot
e3b791f310
Fix changing, blocking, and reacting to stat boosts (#9322) 2023-01-21 12:17:22 -05:00
pyuk-bot
e68346e702
Add an 'End' event for items (#9124) 2022-12-09 19:18:16 -06:00
pyuk-bot
7a6a8441cc
Fix Protosynthesis/Quark Drive/Booster Energy (#9118) 2022-12-04 16:20:21 -05:00
pyuk-bot
ba920c135d
Update Ability Shield with new research (#9081) 2022-11-29 13:27:39 -05:00
Kris Johnson
d50c8c249b
Add Gen 9 (#8997) 2022-11-17 20:46:29 -05:00
Leonard Craft III
ff4e51f728
Correct Room Service event timing (#8959) 2022-10-30 17:42:03 -05:00
acasualmemelord
3353944ed6
Add Pet Mods of the Season (#8859) 2022-08-24 20:34:01 -07:00
Annika
0f71e42f96 Revert "Add new Pet Mods of the Season (#8848)"
This reverts commit 7dccd069c0.
2022-08-07 14:57:55 -07:00
acasualmemelord
7dccd069c0
Add new Pet Mods of the Season (#8848)
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
Co-authored-by: Annika <56906084+AnnikaCodes@users.noreply.github.com>
2022-08-07 14:46:57 -07:00
Alexander B
56f8c3144d
Proc hazards in the order they were set (#8730) 2022-05-19 19:05:32 -05:00
Alexander B
11acef88ad
Fix extraneous failure messages (#8727) 2022-04-24 19:26:09 -05:00
Annika
ec89fb77b5 Handle new, stricter enforcement of no-this-alias 2022-04-04 16:54:36 -07:00
Marty-D
131b9b81ef
Fix build 2021-08-15 09:47:07 -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
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
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
HematiteH2O
111ab3788f
Add Megas For All and Double Trouble (#7893)
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
2021-01-09 00:41:06 -08:00
urkerab
2c0bd53966
Grassy Terrain should heal before Leftovers (#7882) 2021-01-07 19:17:48 -05:00
The Immortal
d9c2ee8d39 Lum Berry activates after Synchronize
Thanks @DaWoblefet!
2020-12-31 21:58:36 +04:00
Adam Tran
d6e05d0a98
Fix Metal Burst interaction with called moves (#7835) 2020-12-30 14:36:06 -05:00
urkerab
74ae95a91c
Update accuracy calculation for latest Gen 7 research (#7806) 2020-12-15 18:37:24 -05:00
urkerab
6daa05781b
Protean should affect the victim of Snatch rather than the user (#7768) 2020-12-07 09:43:55 +04:00
Guangcong Luo
9b5217ab70
Split up dex-data into more files (#7634)
* Split up dex-data over individual files

This commit introduces:
- `dex-abilities.ts`
- `dex-conditions.ts`
- `dex-formats.ts`
- `dex-items.ts`
- `dex-moves.ts`
- `dex-species.ts`

These files centralize definitions from `dex-data` and `global-types`.

* Inherit ItemData from Item etc

Previously, Condition inherited from ConditionData. Now, ConditionData
inherits from Condition. The advantage of the new approach is that now,
Condition and DataCondition no longer need to be separate types, and
there should be much less duplication of type definitions in general.

This has also been done for

- ItemData/Item/DataItem
- AbilityData/Ability/DataAbility
- FormatData/Format/DataFormat

Species and DataSpecies was already merged, but this also reverses
their inheritance (saving a lot of duplicated definitions in the
process!)

The only one left is MoveData, which is just super complicated and
will need its own commit.
2020-11-05 05:00:13 -08:00