Commit Graph

58 Commits

Author SHA1 Message Date
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
Kris Johnson
519fe2eb37 Add February 2025 rotational ladders 2025-02-01 00:27:11 -07: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
Kris Johnson
b37edb2af5 Fix commands that have optional format args
Some checks are pending
Node.js CI / build (16.x) (push) Waiting to run
2024-11-01 11:41:01 -06: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
Slayer95
34c0cb39e3
Fix bugs connected to format.exists (#10647) 2024-10-31 08:25:17 -05:00
Karthik Bandagonda
4ba7f6e8fc
Use value rules for timer (#10194)
* Use value rules for timer

* lint

* fix rule overrides

* fix the "boolean" value rules

* add limits for number based rules

* Realized that you don't need boolean value rules

* oops

* fix checks for lower bounds
2024-09-29 19:10:49 -06:00
urkerab
dbd0ccba19
Use base forme names in banlists where possible (#10515)
* Use base forme names in banlists where possible

This allows you use e.g. 'Arceus-Normal' instead of 'Arceus-Base'.

Also includes some aliases so that all known base forme names actually work.

* Update formats.ts

---------

Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
2024-09-01 14:43:07 -06:00
Mia
ada9f31ef3 Revert "Use base forme names in banlists where possible (#10496)"
This reverts commit 8438ec1890.
2024-08-26 23:15:59 -05:00
urkerab
8438ec1890
Use base forme names in banlists where possible (#10496)
* Use base forme names in banlists where possible

This allows you use e.g. 'Arceus-Normal' instead of 'Arceus-Base'.

Also includes some aliases so that all known base forme names actually work.

* Update formats.ts

* Update config/formats.ts

* Update config/formats.ts

* Update config/formats.ts

* Apply suggestions from code review

---------

Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
2024-08-26 19:20:28 -06:00
Nonexistent-0
185cb4dd85
Server-Side Compatibility for the Tera Type Preview Checkbox (#10483) 2024-08-21 10:53:02 -04: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
André Bastos Dias
d2519c4080
Fix rule EV Limit = 0 (#10251) 2024-04-15 20:18:25 -06:00
Guangcong Luo
3c51f8aa1f
Refactor BestOfGame (#10026)
This replaces some pretty jank code with much cleaner code.
Anything that would be more cleanly implemented by iterating the
players array is now done by iterating the players array.

Some instances of p1/p2 are lying around but we should slowly deprecate
them.
2024-01-07 01:45:23 -08:00
Guangcong Luo
2682db9471 Hard limit format name length to 50 chars
This is mostly to prevent people from accidentally creating formats
too big for the Replays database to handle.
2023-12-19 23:51:10 -06:00
Leonard Craft III
c4e1c0b478
Support defining default best-of formats server-side (#9866) 2023-11-01 23:24:23 -05:00
Kris Johnson
4b1c8987c0 Add October 2023 OM of the Month/RoA Spotlight 2023-10-01 02:25:26 -06:00
Alexander B
283098c982
Fix ruleset interactions with Rayquaza-Mega (#9293)
* Fix ruleset interactions with Rayquaza-Mega

* Improve condition

* DRYify tests more
2023-02-01 15:50:48 -07:00
Kris Johnson
a041d52a27 Remove unused property 2022-12-07 19:39:05 -07:00
Kris Johnson
d50c8c249b
Add Gen 9 (#8997) 2022-11-17 20:46:29 -05:00
Annika
ec89fb77b5 Handle new, stricter enforcement of no-this-alias 2022-04-04 16:54:36 -07:00
WeWuzNidokangz
7097a9ac75
Hackmons Cup: Support custom team bans/unbans (#8607) 2022-01-09 14:46:41 -08:00
pyuk-bot
bf6026fb6e
Rulesets: Fix oversight with cosmetic formes (#8551) 2021-12-07 22:19:11 -08: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
a499393c12 Fix build 2021-07-10 17:19:39 -07:00
Annika
491ce58234 Fix dex-formats in Sucrase build 2021-07-10 14:37:16 -07:00
Annika
c134195915
Use ts-node instead of Sucrase (#8369) 2021-07-09 19:59:22 -07:00
Kris Johnson
598ac409e8 Rename Let's Go! mod to 'gen7letsgo' 2021-07-06 23:07:51 -06: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
Guangcong Luo
743153ac32 Fix defaultLevel
defaultLevel should not be set to maxLevel if this would make teams break
maxTotalLevel.

Fixes a bug where level 100 pokemon were automatically set to higher
levels in cases where it didn't make sense.
2021-05-26 12:44:44 -04:00
Instruct
7143939f1c
Gen 6 Hackmons: Fix EV limit and comment (#8329) 2021-05-23 18:25:12 -07:00
Guangcong Luo
4a2d386c55 Fix VGC EV validation 2021-05-23 17:16:13 -07:00
Guangcong Luo
e511d5c646 Fix EV validation 2021-05-23 16:55:00 -07:00
Guangcong Luo
9c98ae5c87 Rules: Split "EV Limit" out from "Obtainable Misc"
"EV Limit = 510" is now its own rule which can be changed separately
from the rest of Obtainable Misc.

The rest of Obtainable Misc doesn't seem useful to break up, so I
haven't bothered.
2021-05-23 15:14:00 -07:00
Guangcong Luo
2936c55439 Rules: Add -no item and fix -all items
`no item` is now a fake item meaning "not holding an item", for the
purposes of the team validator. This means that `-no item` will force
all pokemon to carry items.

`all items` no longer includes not holding an item, so `-all items`
will now work as expected.
2021-05-17 04:22:24 -07:00
Guangcong Luo
518ac11520 Validate Max Team Size
Fixes #8286
2021-05-13 23:45:55 -07:00
Guangcong Luo
7e965b41a7 Revert timing for adding rules to field in #8274
It turns out rules need to be added before sides are initialized,
so that they can hook `ModifySpecies` during side initialization.

The proper way to fix this is pretty complex so this is just a hack.
2021-05-11 23:02:01 -07:00
Guangcong Luo
638c1e3ae8 Add "Max Move Count" value rule
Also stop enforcing 4 moves limit and 6 pokemon limit in `-Nonstandard`,
for the same reason we stopped enforcing the level 100 limit; any format
that explicitly wants it higher should automatically override it.
2021-05-07 02:16:24 -07:00
Guangcong Luo
36295dc27a
Simplify Team Preview events (#8274)
In format events:

`onFieldTeamPreview` has been renamed back to `onTeamPreview`. It's now
a custom event (like `onBegin`), rather than a field event.

Team Preview data has been entirely moved from `onBegin` into
`onTeamPreview`.

`onFieldStart` for formats/rules now happens after Team Preview, rather
than before. Use `onBegin` for things that happen before Team Preview.
2021-05-06 18:53:58 -07:00
Guangcong Luo
16e9a0eeec Fix bugs in value rule refactor 2021-05-06 07:49:17 -04:00
Guangcong Luo
55980d416c
Support value rules (#8267)
`teamLength`, `maxLevel`, `cupLevelLimit`, and `minSourceGen` no longer
exist as properties of `Format`. Instead, they're value rules that
become properties of `RuleTable`, and can be specified as custom rules
and inherited through rulesets like anything else.

See the PR for a full reckoning of changes:

https://github.com/smogon/pokemon-showdown/pull/8267
2021-05-06 01:16:16 -07:00
Guangcong Luo
1bf172fe7e Refactor: Move getTagRules inside RuleTable 2021-05-06 00:30:07 -07:00
Guangcong Luo
edb45ebecc Refactor rule iteration 2021-05-04 04:50:58 -07:00
Guangcong Luo
c11dccb032
Rename and fix maxTeamSize (#8266)
`maxTeamSize` is a bad variable name (not that `teamLength.battle` is
any better, but that'll get fixed in a future refactor).

- Rename `maxTeamSize` to `chosenTeamSize`, to better indicate that
  this is the size after Team Preview, and that it is also the minimum
  size after Team Preview.

- Don't limit team sizes to 6 if `teamLength.battle` isn't specified.
  This removes an unnecessary `teamLength.battle` requirement in all
  Custom Game formats.

- Stop requiring `maxTeamSize` as a parameter for `battle.getRequests`.
  It's not even used except as a hint to the Preact client, and was
  never state in the first place.

- Stop supporting partial `side.chooseTeam`. This is an unused feature
  and removing it massively simplifies the code and fixes a bug in
  `cupLevelLimit` which definitely was not written with the
  understanding that `chooseTeam` could be partial.

- Fix a bug in #7929 which seemed to misunderstand what `teamsize` was
  for.
2021-05-04 00:31:05 -07:00
Guangcong Luo
230a9427c9 Fix crash in isBannedSpecies 2021-05-01 13:56:25 -07:00
Guangcong Luo
4d70b0a46a
Use data/tags for validator (#8218)
Previously, the validator had its own hardcoded tag system. This
removes the hardcoding and makes it so any pokemon tag in `tags.ts`
can be banned or unbanned.
2021-04-30 18:20:30 -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
InAShellnut
9ab4c86fe3
Add Stadium 2, Nintendo Cup 1997, and Nintendo Cup 2000 (#8195)
An implementation of Nintendo Cup 1997, Nintendo Cup 2000, and Pokemon Stadium 2, for Pokemon Showdown. The only thing which has not been implemented was showing the exact health of both Pokemon in Pokemon Stadium 2, however implementing that requires changes to the showdown client. The Nintendo Cup 1997 code was done by Enigami, and the rest was by myself (Shellnuts).

This should fulfill the requirements asked by the following accepted suggestions:
https://www.smogon.com/forums/threads/please-add-a-pok%C3%A9mon-stadium-2-simulator-in-showdown.3679486/
https://www.smogon.com/forums/threads/add-nintendo-cup-1997-and-2000-as-challenge-only-formats.3653454/
2021-04-22 00:54:14 -07:00
Guangcong Luo
1ae9f90393 Possibly fix a format corruption issue 2021-04-08 08:07:30 -07:00