Commit Graph

45 Commits

Author SHA1 Message Date
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
tofa
3b974a4ede
Ladder: Move tighter search restrictions to latest gen (#10210) 2024-03-21 21:11:29 -05: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
Mia
5052a2a797 Team-validator: Log userids in debug info 2023-10-03 11:27:39 -05:00
Mia
d488841400 Ladders: Add an onChallenge chat hook 2023-09-29 14:42:23 -05:00
Alexander B
618b8a0ea0
Fix /blockchallenges friends (#8689) 2022-03-16 13:29:18 -05:00
Annika
9c08822cff Revert Multi Battle changes 2021-10-24 17:13:10 -04:00
Mia
ce6adc6b42 Ladders: Clear teammates after matchmaking 2021-10-24 16:03:11 -05:00
Mia
0f5c9c133b
Support searching multi formats (#8172) 2021-10-24 12:04:57 -07:00
Mia
24e1dcbe24 Ladders: Add timestamps to challenge notifications 2021-09-19 14:13:36 -05:00
Mia
7811795344
Handle new TypeScript version (#8449)
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
2021-08-30 20:11:44 -07:00
Mia
bdeb9c538a Support /blockchallenges friends 2021-07-22 21:18:52 -05:00
Distrib
e9a5bc9332
/blockchallenges: Support allowing challenges from certain groups (#8362) 2021-06-26 17:28:03 -07:00
Guangcong Luo
c695620e58
Refactor to new challenge system (#8303)
See PR for full details:

https://github.com/smogon/pokemon-showdown/pull/8303
2021-05-17 07:15:01 -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
Guangcong Luo
8f001cc2ae Support challenges in 4-player games 2021-04-02 23:00:30 -07:00
Guangcong Luo
44ef998ecc Implement free-for-all
This involves a huge refactor for how battles are constructed, but
it's totally worth it.

Currently, tournaments, challenges, and laddering are unsupported; only
unrated searches work. But it does work, and it's beautiful.
2021-04-01 04:44:16 -07:00
Annika
c2e97aaaed
Use optional chaining in more places (#8063) 2021-02-22 11:42:05 -08:00
Guangcong Luo
da30a71706 Revert "Remove User#inRooms and User#games (#7815)"
This reverts commit 5c9c84c415.

This also reverts commit 1fc92ef977.
2021-01-30 15:55:55 -05:00
Guangcong Luo
f4abf52f61 Fix QueryProcessManager type signatures 2021-01-30 11:35:35 -08:00
Mia
5c9c84c415
Remove User#inRooms and User#games (#7815) 2021-01-28 10:41:35 -08:00
Mia
186677239d
Nicknamefilter: Support hiding nicks from filters (#7751) 2020-12-01 06:21:17 -08:00
Mia
71dbb2f466
Support Config.nothrottle (#7637) 2020-11-05 04:52:04 -08:00
Mia
67ee30f2fd
Introduce Config.noipchecks (#7626) 2020-11-04 15:14:30 -08:00
Guangcong Luo
c9759954b9 Remove sim/global-variables.d.ts
The sim no longer uses any global variables, so this can and should be
removed.

`server/global-variables` has also been cleaned up, since I'm working
on this.
2020-10-27 22:03:14 +00: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
Annika
1cbab7162c
Filter Pokémon nicknames after team validation (#7283)
This will prevent the staff room from getting spammed when people do things like nickname their Pokémon 10,000 n-slurs in a row.
2020-08-31 06:21:58 -07:00
Guangcong Luo
a315c93836 Switch to using import type
We were previously using `type Foo = import('bar').Foo` which works
actually equally well, because sucrase didn't support `import type`,
but now it does!
2020-08-09 08:07:00 -05:00
Mia
5ca45205db
Add a throttle for pending challenges (#7045) 2020-07-24 12:04:29 -07:00
Kirk Scheibelhut
2691b91062
Fix tour challenges (#6972) 2020-07-06 22:58:12 -07:00
Kirk Scheibelhut
eea2196280
Server side changes to support persistent user settings and privacy changes (#6947)
NOTE: This is changes the semantics of `hidenext`/`ionext` from
applying to the next created *battle* to applying to the next
created *search*/*challenge*.
2020-07-06 21:18:38 -07:00
Guangcong Luo
2b83a5ed51 Support Unown formes
This adds Unown formes as true cosmetic formes, and also applies word
filters to them.
2020-04-30 14:16:56 -07:00
Kirk Scheibelhut
17501fc001
Remove restrictions on concurrent battle searches (#6462)
https://www.smogon.com/forums/threads/improve-searching-for-concurrent-ladder-battles.3660989/
2020-03-16 21:17:34 -07:00
Guangcong Luo
125fe31d06 Improve eslintrc
Fixed some more code style, allowing these rules to be enabled:

- `comma-dangle`
- `function-paren-newline`
- `member-delimiter-style`
- `no-eval`
- `no-fallthrough`
- `no-misused-promises`
- `no-unused-vars`
- `operator-linebreak`
2020-03-06 22:35:55 -08:00
Waleed Hassan
8aa4f053bb
Use optional chaining and linter improvements (#6422)
This is mostly just a follow up to #6342.

`prefer-optional-chaining` was turned on and fixed in every location it
complained in. The transformed function [0] looks expensive from a
glance but from skimming through the replaced sites it doesn't appear
to be ran in any important place, so it should be OK.

The linter improvements are:
- Increase linter performance
	- Make `full-lint` and `lint` write to different caches so we
	  avoid overwriting their caches since they're different configs
	- Change husky's hook to `npm run lint` so as to write to the
	  same cache
	- Remove `@typescript-eslint/eslint-plugin-tslint` which is
	  essentially a wrapper to TSLint because the rules aren't worth
	  running another linter
- Convert `.eslintrc.json` and `.eslintrc-syntax.json` to two spaces
  rather than four tabs to respect PS' `.editorconfig`
- Rename `fulllint` to `full-lint` to ease spelling it

[0] - https://pastie.io/mmtxpf.js (prettified)
2020-03-06 11:44:32 -08:00
Guangcong Luo
b21c9047e2
Migrate to typescript-eslint (#6342) 2020-03-05 08:33:06 -08:00
Waleed Hassan
df14f875ec Add a RoomBattle#challengeType property (#5940)
This commit adds a `challengeType` property to `RoomBattle` of
type `rated | unrated | challenge | tour`.

Previously, there was no way to programatically differ an unrated
battle from a challenge, which is useful in places like filters.
2019-12-12 19:09:43 +09:00
HoeenHero
e092caf2d2
Ladders: Delete rating cache if no response. (#6132)
If the remote ladder's update rating method dosen't receive
a response from the login server, it will not change the user's
mmrCache for the format, resulting in future ladder matches using
an outdated ELO until the server receives a response at the end of
a future match.

This is the cause of issues such as users with 1400 ELO being matched
with users with 1000 ELO with a 10 second wait time in current gen OU.

Ensuring the rating is up to date was discussed, but for cases such as
a user searching for a new match before a response is received (or an
error occurs) we decided to accept the mmrCache being at most 1 game
behind, which this change.
2019-12-01 21:47:52 -05:00
Waleed Hassan
28e870c4fb Server: Use readonly where appropriate (#5902) 2019-10-21 16:12:32 +10:30
Waleed Hassan
da4b887054 Rename Room#id -> Room#roomid, User#userid -> User#id (#5826)
These should make it clearer that userids are IDs but roomids aren't.
2019-10-03 18:57:38 +10:00
TheJetOU
2b28c9fd6b Refactor Rooms(), Users() to Rooms.get(), Users.get() (#5725) 2019-08-25 06:33:56 -07:00
Guangcong Luo
e0a2cf07e1 Correctly define global types for .ts files
Global types are defined differently for `.ts` files than for `.js`
files, leading to some confusion for past refactors.

This commit defines them correctly.

I'm also considering making certain global types only available under
namespaces, but I don't want to do that to `User` or `Room`, so for
now, there are no changes there, besides putting streams in the
`Streams` namespace (so `WriteStream` is now `Streams.WriteStream`).
2019-08-23 09:33:49 -07:00
Kirk Scheibelhut
8c49d0c164 Auto-accept challenges from challenge target (#5706) 2019-08-14 13:38:22 -07:00
TheJetOU
f586e88326 Simplify Map declarations (#5702) 2019-08-13 17:23:27 +02:00
TheJetOU
4f7ad0132b TypeScript Ladders (#5696) 2019-08-12 09:48:18 +02:00