Commit Graph

122 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
Kris Johnson
89128dee97
Utils#Multiset: Redefine get to remove undefined return (#10329) 2024-06-06 17:16:59 -06: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
dot-Comfey
01e35f4f2d
Add Pokemon GO support (#9646) 2023-07-31 19:27:06 -05:00
Mia
b11177d530
Migrate to esbuild for compilation (#9203) 2022-12-22 15:19:29 -06:00
Kris Johnson
d50c8c249b
Add Gen 9 (#8997) 2022-11-17 20:46:29 -05:00
Annika
9c5d654b89
Revert "Improved typing for utils.ts, and for iterating over base stats (#8919)" (#8938)
This reverts commit c589fb5a5a.
2022-10-16 18:27:25 -07:00
GregLyons
c589fb5a5a
Improved typing for utils.ts, and for iterating over base stats (#8919) 2022-10-16 18:08:11 -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
Annika
e530cee6f1 Fix bugs with Sucrase build process 2021-07-11 11:54:22 -07:00
Annika
c134195915
Use ts-node instead of Sucrase (#8369) 2021-07-09 19:59:22 -07: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
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
5233559183 Refactor Dex types 2021-04-08 07:08:56 -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
Kris Johnson
5e6c259dec
Gen 3/4: Remove HAs in getSpecies (#8134) 2021-03-23 10:19:50 -07:00
Mia
76c10841ea
Lib: Add an index file for all exports (#7972) 2021-01-31 18:00:19 -08:00
The Immortal
3ae56399bd Label Pokemon banned from LC as NFE 2021-01-11 00:29:18 +04:00
Guangcong Luo
6b3a3070c9 Refactor team validator for readability
`checkLearnset` has been renamed `checkCanLearn`.

`reconcileLearnset` has been replaced with `validateMoves`, which
bundles the actual `checkCanLearn` calls with the old
`reconcileLearnset`, making for a better name.
2021-01-03 23:26:20 -08:00
Kris Johnson
890b4d9f59
Refactor text files (#7680) 2020-11-11 14:40:55 -08: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
Guangcong Luo
e90658c038 Validate Natures in tests
(There's no need to validate natures somewhere that has an actual
performance impact.)
2020-10-29 16:19:07 +00:00
Kris Johnson
ab6e173e24
Move natures into their own file (#7601) 2020-10-29 08:38:03 -07:00
Guangcong Luo
3b4a3ba7e0 Improve custom rule validation
Stray spaces are now consistently allowed in `/tour rules` and
`/challenge`, but are not allowed in `formats.ts`.

Improves #6811
2020-10-28 02:18:52 +00:00
PartMan
062e42402d
Fix Custom Rules Error (#6811)
`/challenge [Gen 8] OU @@@ +Reshiram` failed earlier, since the rule wasn't trimmed.
2020-10-27 19:00:05 -07:00
Guangcong Luo
a38f0597f8 Remove last vestiges of tslint 2020-10-27 22:49:00 +00:00
Guangcong Luo
7eafea8ee1 Add client text data
This syncs data/text to exactly match the client's data/text, in
preparation for them to be merged. The server's data/text will be
canonical, moving forward:

Relevant changes:

- A new file `data/text/default` has been added, for battle messages
  not associated with a move/item/ability.

- As One (Glastrier) and As One (Spectrier) should not have a start
  message; only As One itself.

- Hidden Power's `realMove` property does not belong in data/text
  and has been removed (it's still in data/moves where it belongs).
2020-10-27 16:56:08 +00:00
urkerab
b90f03b77e
Calculate natures with 16-bit truncation (#7540)
Also fixes Let's Go! which wanted to override these but couldn't.
2020-10-25 16:54:43 -07:00
Guangcong Luo
d6c650d545 Properly fix HP type corruption crash 2020-10-19 17:18:28 +01:00
Guangcong Luo
9d87616176
Add more style linting rules (#7537)
* Lint arrow-body-style

* Lint prefer-object-spread

Object spread is faster _and_ more readable.

This also fixes a few unnecessary object clones.

* Enable no-parameter-properties

This isn't currently used, but this makes clear that it shouldn't be.

* Refactor more Promises to async/await

* Remove unnecessary code from getDataMoveHTML etc

* Lint prefer-string-starts-ends-with

* Stop using no-undef

According to the typescript-eslint FAQ, this is redundant with
TypeScript, and they're not wrong. This will save us from needing to
specify globals in two different places which will be nice.
2020-10-19 02:42:28 -07:00
Kris Johnson
7ebc4411e9
Fix Allowing Hidden Power with an undefined hpType (#7541) 2020-10-18 22:52:25 -04:00
Guangcong Luo
1c0c77ff6b
Update to TypeScript 4.0 (#7504) 2020-10-10 14:43:32 -07:00
Mia
fb23fc8733
/showteam: Properly handle nick/form names (#7489) 2020-10-08 13:31:29 -07:00
Mia
aba5dd1119
/showteam: Support nicknames (#7464) 2020-10-03 08:25:14 -07:00
Guangcong Luo
3d68248efa Update to latest eslint
We're skipping two major typescript-eslint versions, so there are a
bunch of changes here, including:

- it's catching a lot of things it didn't catch in the past, for
  reasons unclear to me

- no-unused-vars has to be explicitly disabled in global-types now

- a lot of `ts-ignore`s were never necessary and have been fixed

- Crashlogger can now handle being thrown things that aren't errors.
  This has never been a problem in the past, but to satisfy TypeScript
	we might as well not die in a fire on the off chance someone tries to
	`throw null` or something.
2020-09-29 15:28:08 -07:00
urkerab
5d714fbb56
Replace @ts-ignore with type assertions or other less unsafe constructs (#7390) 2020-09-19 02:07:48 -07:00
Leonard Craft III
302d6ff6fb
Add hidestats arg to showteam and improve output (#7357) 2020-09-14 16:33:34 -07:00
EvGym
b57b527f1c
Support custom-formats file (#7240) 2020-09-07 23:31:01 -07:00
urkerab
1bf873018c
Remove outdated getAwakeningValues function (#7331) 2020-09-07 17:00:53 -07: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
urkerab
7be58f2425
Tweak team stringification (#7250) 2020-08-23 04:24:49 -07:00
Guangcong Luo
8d79bf9725 Rename Dex.deepClone to Utils.deepClone
`this.dex.deepClone` still exists as an alias to `Utils.deepClone` for
use in `data/`. I'll need to spend more time figuring out the correct
solution there.
2020-08-21 04:24:34 -07:00
Mia
fa7a0025e5
/showteam: Fix bugs (#7206) 2020-08-12 16:12:45 -07:00
Kris Johnson
5e255012bc
Add a 'bst' property to Species (#7138) 2020-08-12 12:06:09 -07:00
Marty-D
479ea5a72b Validator: Fix passing down level up moves
and finish implementing `canHatch`
2020-08-08 17:17:45 -04:00
Mia
deeed6c789
Remove sim/ and data/'s globals (#7091) 2020-08-07 06:44:15 -07:00
Mia
fd0f83ff8d
Add a command to show the user's team in battles (#7068) 2020-08-06 00:36:43 -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