Commit Graph

114 Commits

Author SHA1 Message Date
André Bastos Dias
684150d9d7
Implement Mega Stones as {key: value} pairs (#11684)
* Implement Mega Stones as pairs {key: value}

* Fix Mega Evolution check

* Add constructor guards to Dex getters

* Update config/formats.ts

---------

Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
2026-01-08 14:59:22 -07:00
Dieter Reinert
561fe5e375
Dex: Update isName signature to match expected inputs (#11172) 2025-06-03 15:22:05 -07:00
Dieter Reinert
fd1c2f1738
Dex: Prevent isName crash on null/undefined (#11167) 2025-06-02 16:00:40 -07:00
Guangcong Luo
e07080ce5c
Support fuzzy searching /dt etc (#11124)
This add's the teambuilder's fuzzy matching to /dt and similar commands.
2025-05-23 00:26:23 -07:00
Guangcong Luo
73a04cdcba TypeScript: Enable noImplicitOverride
Some checks are pending
Publish to npm / test (push) Waiting to run
Publish to npm / get-version (push) Waiting to run
Publish to npm / npm-publish (push) Blocked by required conditions
Node.js CI / build (18.x) (push) Waiting to run
2025-02-26 14:38:32 -08:00
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
Guangcong Luo
ec7332b498 Import Utils from lib/utils
Some checks are pending
Node.js CI / build (16.x) (push) Waiting to run
This mostly is just a step towards removing sim's dependency on Node's
stdlib.
2025-01-14 23:01:53 -08:00
larry-the-table-guy
ff8c9a0414
Sim: Faster type coercion in toID (#10619) 2024-11-09 19:09:58 -08:00
larry-the-table-guy
12c1614eb5
Dex: Consistent field init order in constructors (#10608)
Some checks are pending
Node.js CI / build (16.x) (push) Waiting to run
2024-10-31 10:05:03 -07:00
larry-the-table-guy
101f6bcc33
Dex*: Cache empty objects (#10607) 2024-10-12 18:43:53 -06: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
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
Annika
ec89fb77b5 Handle new, stricter enforcement of no-this-alias 2022-04-04 16:54:36 -07:00
Guangcong Luo
ddb6010bb9 Support importing teams
We now have a `Teams.import` function. This supports importing teams
in any format, allowing it to be the backbone of a new series of
commandline functions, which support teams in any format.
2021-06-09 22:08:31 -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
Mia
76c10841ea
Lib: Add an index file for all exports (#7972) 2021-01-31 18:00:19 -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
Kris Johnson
909419ca27 Fix /randbats interaction with Gen 2 sets 2020-11-01 14:23:40 -07:00
Kris Johnson
ab6e173e24
Move natures into their own file (#7601) 2020-10-29 08:38:03 -07:00
Guangcong Luo
49743a6a93 Fix crash from bad changesFrom type
Fixes #7544
2020-10-19 17:40:38 +01: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
Guangcong Luo
d429d58bc6 Fix suspect test ladders
We deployed a new suspect test system a few months ago, but we had to
back out of it when it didn't work as expected. This fixes the bug that
made it not work. In the future, setting `rated: "[Gen 8] Format Name"`
in `formats.ts` will cause ladder games in that format to actually
go in the specified format's ladder, instead of its own.
2020-09-27 08:43:08 -07:00
Strahm, Jeffrey S.(S&T-Student)
188426490b Rename FormatsData to FormatData
(The name FormatsData is inconsistent with how we name other things;
especially since it's supposed to be data for a single format. It was
probably originally a typo. -Zarel)
2020-09-07 19:35:14 -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
Kris Johnson
f96ec4fb05
Add strict types to tiers (#7135) 2020-08-06 00:41:42 -07:00
Kris Johnson
70edfaa64c
Add support for more OMs (#7084) 2020-07-30 05:22:21 +04:00
Guangcong Luo
4d09f7acde Rename more instances of Effect to Condition 2020-07-26 11:26:23 -07:00
Kris Johnson
00b88b521d
Handle Gigantamaxing properly (#7001) 2020-07-23 13:27:42 -07:00
urkerab
09350a01bf
Centralise the check for a restricted species (#6973) 2020-07-07 15:30:37 -07:00
ACakeWearingAHat
f9699c1be0
Random Doubles Updates (#6962) 2020-07-06 12:48:48 +04:00
urkerab
6fb5b4e90d
Allow custom formats (e.g. for tours) to modify format restrictions (#6958) 2020-07-05 14:32:30 -07:00
Kris Johnson
28a4a9a91e
Fix STABmons Move Legality (#6918) 2020-06-25 16:12:57 -07:00
Kris Johnson
e20178d69d
Isle of Armor: Pokemon (#6839) 2020-06-17 23:37:14 +04:00
Kris Johnson
5f724397fc
Make Species#nfe work for previous generations (#6776) 2020-05-30 21:36:47 -07:00
Kris Johnson
a7948c7c9c
Typescript config/ (#6760) 2020-05-29 19:34:43 -07:00
Sigmatecture
18b8d019ed
Set Random Battle singles levels by species (#6706) 2020-05-27 00:31:41 +04:00
Kris Johnson
d20f1fbb64
Typescript info (#6670) 2020-05-11 03:08:33 -07:00
Kirk Scheibelhut
fa65ed4979
Add alt form index data to dex (#6669)
AltForm index info obtained from kwsch/PKHeX's FormConverter.cs (thanks Kurt).
Thanks to @Lusamine (Anubis) for help with the peculiarities.
2020-05-10 12:20:40 -07:00
Kirk Scheibelhut
d621a4b670 Don't assign Struggle a zMove.basePower of 100
This check exists for maxMove.basePower but not zMove. Thank you
SadisticMystic for confirming that while "it has an entry of 1 in
the data table, [it]'s a meaningless entry which is impossible
to access"
2020-05-04 21:49:01 -07:00
Kirk Scheibelhut
2af7040270
Group zMove and maxMove attributes (#6652)
This mostly serves to provide cleaner and more consistent field
naming. maxMove currently doesn't have boosts or effects to group
together but who knows what will be thrown at us via DLC, and being
symmetrical with zMoves is a nice.
2020-05-04 20:21:27 -07:00
Kirk Scheibelhut
74e1e3692f
Fix default Max/Z power for isMax/isZ moves (#6634) 2020-05-01 00:35:10 -07:00
Guangcong Luo
e0f6453b60 Refactor data definitions
- `Modded[Effect]Data` are now correctly defined: they must either have
  `inherit: true` and be partial, or not have `inherit: true` and be a
	complete `[Effect]Data` entry

- `id` is no longer allowed; instead, it's calculated directly from
  `toID(name)`. The one exception, Hidden Power, gets a `realMove`
	property to track this (it's still used to set `.id`, though;
	TODO: really fix it properly).

- `num` is still required in `data/pokedex.ts` (dex number),
  `data/moves.ts` (move index number, for Metronome), and
	`data/items.ts` (minisprite sprite-sheet location). It's still not
	required for mod-only items and moves.

- `num` is no longer allowed for PureEffects (in `statuses.ts`) where
  it's always been meaningless.

- `color` and `heightm`, being completely flavor, are still not
  required for `pokedex.ts` in mods. They're still required in the base
	pokedex.
2020-04-30 21:39:29 -07:00
Kris Johnson
979be98574
Refactor inheritsFrom to changesFrom (#6611) 2020-04-26 14:44:25 -07:00
The Immortal
634658a5ba Refactor unreleased Pokemon
Pokemon that are not available in-game are now consolidated into `isNonstandard`. 'Past' indicates that the Pokemon no longer works in the current generation. 'Unobtainable' indicates that the Pokemon works but can only be obtained through hacking.
2020-04-06 20:53:03 +04:00
The Immortal
81891546b9 Rename Missingno. to MissingNo. 2020-03-26 18:37:35 +04:00
Kris Johnson
994fc60aed
Rename Template to Species (#6478) 2020-03-25 23:29:27 -07:00
The Immortal
1765d9fbfa Improve bbb4da013 2020-03-19 02:06:10 +04:00