Commit Graph

64 Commits

Author SHA1 Message Date
Karthik Bandagonda
4425ec2719
Add onChooseTeam event for formats (#11476)
* Add onChooseTeam event for formats

* Fix VGC 2010 autochoose

* Use custom validation instead of Limit One Restricted

* cleaner code

* clean up chooseTeam code
2025-10-06 02:20:44 -06:00
André Bastos Dias
e473be87d1
Refactor Let's Go Normal Rules (#11324)
* Allow AVs should take happiness into account

* Default happiness is already set in pokemon.ts

* Default happiness in the validator

natureModify only receives the set, not the actual Pokemon :/

* Implement Let's Go Normal Rules

* Fixes

* Remove EV limit

* Remove condition

* Add EV Limit = 0

Avoid "Pokemon has exactly 0 EVs - did you forget to EV it?"

* Final fix

* Happiness is fixed to 70

* Revert changes

* Rename Let's Go to LGPE

* Re-add comment
2025-08-04 20:48:27 -06: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
d6e17ebc9e Fix -All Pokemon overriding Min Source Gen
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run
2025-03-06 20:16:57 -08:00
Guangcong Luo
d9557375a0
Introduce "NatDex Mod" (#10939)
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run
"Standard NatDex" is very weird compared to how OMs usually work.

See "TierShift Mod" and "Godly Gift Mod". NatDex now gets its own mod,
which can be mixed into any other format, instead of needing to start
with NatDex.

This would make Min Source Gen overriding annoying, so it now defaults
to the current gen in Gen 9+, if Obtainable is set and +Past isn't. So
now you don't need to manually set Min Source Gen to enforce Obtainable
in Gen 9.
2025-03-06 03:40:36 -08:00
Guangcong Luo
0cb51158aa
Make "All Pokemon" rules more convenient (#10932)
Some checks are pending
Node.js CI / build (18.x) (push) Waiting to run
* Make "All Pokemon" rules more convenient

Previously, "+All Pokemon" did nothing except override "-All Pokemon",
which switched from a default-allow to default-deny system.

They still do that, but they now also override all previous pokemon
bans/unbans. This makes it easier to replace a banlist/whitelist
from an inherited ruleset without needing to reverse every previous
ban/unban.

This also adds an error if you use `+All Pokemon` in a ruleset where
it doesn't do anything.

Fixes #10772
2025-03-02 14:47:30 -08: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
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