43 Commits

Author SHA1 Message Date
Guangcong Luo
253053a8e2 Preact minor updates batch 50
- Fix Disable + Max move interaction
- Users in rooms you moderate can't be ignored
- Fix chat getting dropped when resetting playback
- Fix crash in Tooltips
- Hardcode some room aliases
- Mods can now reveal moderated text
- Fix Teambuilder scrolling when pressing Back from set editor
- Support collapsible Format dropdown sections
- Fix index-test support
- Support changing default client in oldclient
- Fix focus when opening and closing a popup while a mini-window is
  focused
- Fix dragging the EV slider with underleveled pokemon
- Fix teambuilder format detection
- Fix tooltip locking in Safari iOS
- Grab COIL from loginserver
2026-09-26 19:54:15 -07:00
Guangcong Luo
f2faebd689 Fix tests
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled
2026-09-14 23:22:37 -07:00
Guangcong Luo
b83967e980 Preact minor updates batch 48
- Fix parsing of bolded text in battles
- Fix teambuilder result issue
- Fix Register button
- Fix Pursuit activation message grouping
- Fix base species name in Teambuilder
- Fix build error
2026-09-11 22:22:14 -07:00
Guangcong Luo
1e3b209011 Update for new server TL system
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled
Update for https://github.com/smogon/pokemon-showdown/pull/12299
2026-09-09 15:48:10 -07:00
Guangcong Luo
951cc1580b Support translating Preact client (#2742)
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled
Client-side counterpart to https://github.com/smogon/pokemon-showdown/pull/12259

Basically everything important is translatable now.

This involved a ton of refactors for translatability.

This also changes the client so it defaults to the browser's default language,
instead of defaulting to English.

Actual translations coming in a separate PR (for ease of reviewing).
2026-08-31 17:54:11 -07:00
Guangcong Luo
8aac6055f1 Support translated battles (#2740)
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled
2026-08-22 20:34:58 -07:00
Guangcong Luo
daa28cfeb1 Preact minor updates batch 45
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled
- Support new Team Preview choice protocol
- Fix contentEditable cursor reset on blur+refocus
  - (Unfocusing and focusing would reset the textbox cursor position)
- Fix horizontal movement having precedence over selection and sliders
  in mobile
  - (You couldn't modify selections or drag sliders because it would
    slide open the menu instead)
- Fix build error
  - (Replays no longer has a custom build path)
- Don't apply "Zoom out forms" setting to import/export tab
2026-08-15 08:29:35 +00:00
Guangcong Luo
c24f883a5b Preact minor updates batch 45
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled
- Fix unknown sprite orientation
  - Apparently some people care more about the facing direction than
    the backwards question mark. I remember fixing it in the past but
    apparently someone reverted it without telling me, because of
    complaints?
- Fix team dropdown
  - Fix widths
  - Don't show boxes, only real teams
- Fix Revival Blessing UI
- Add tests for the Revival Blessing and earlier choice parsing changes
- Improve battle UI
  - Change "Back" button and `/undo` to go "back one step" instead of
    cancelling everything
  - Improve Team Preview UI
    - now says how many pokemon you need to pick
    - chosen team is shown on one line
    - chosen team isn't disabled (clearer that it's clickable)
  - Fix "Side by side, overlay controls" width
- Consistently use `errorReply` for command errors
2026-07-28 09:25:00 +00:00
Guangcong Luo
8336ed5673 Preact minor updates batch 32
- Refactor notifications
  - Don't notify for things you've seen before the refresh
  - Make tournament notifications work like oldclient
  - Clear notifications on window focus
- Refactor interruptClose
  - It now warns when closing PS, too
- Remove mocha dependency (migrate to node:test)
- Update TypeScript
- Update Preact
- Fix `/afd`
- Fix move targeting under Imprison
  - I'm still not sure what's causing it, but I think Preact is getting
    confused by the nested arrays. I've switched to using a fragment
    and that seems to have fixed it.
- Add error boundaries
- Fix join/leave message location in battles
2026-06-09 17:57:29 +00:00
Guangcong Luo
1f8317aedd Fix EV guesser test
Some checks are pending
Node.js CI / build (22.x) (push) Waiting to run
Thanks to ry for finding this issue
2026-03-19 06:42:33 +00:00
pyuk-bot
e1643c52dc Fix optimizer output when new spread has a 0 (#2241) 2024-04-08 07:36:13 -05:00
Karthik
877bda4378 Teambuilder: Add EV optimization checker (#2240)
---------

Co-authored-by: pyuk-bot <msaimrkon@gmail.com>
2024-04-05 23:33:26 -05:00
Guangcong Luo
5b97740c80 Fix overlooked paths from directory reorg 2023-11-16 22:51:31 +00:00
Guangcong Luo
5d41f3ec93 Reorganize directories (#2187)
Files meant to be served have been moved into
`play.pokemonshowdown.com/` and `pokemonshowdown.com/`.

We now have three directories for the three subdomains handled by this
repo:

- `pokemonshowdown.com/`
- `play.pokemonshowdown.com/`
- `replay.pokemonshowdown.com/`

Naming them after the subdomains will make it much easier to tell where
the files for each go.

The diff is probably useless; it'll be easier if you just look at the
new tree:
https://github.com/smogon/pokemon-showdown-client/tree/reorganize
2023-11-16 03:39:29 -08:00
Mia
a4eef221bd Update to handle esbuild migration (#2064) 2022-12-22 13:25:00 -08:00
Guangcong Luo
3e4b83298c Update Battle class API (#1686)
The client Battle class API has been pretty old and crusty, so this
updates it to be saner.

The constructor now takes an options object. Any setting you'd want to
initialize with is now a constructor option, instead of needing to call
methods after the constructor.

(Deprecated settings `roomid` and `joinButtons` still need to be set
separately.)

The old callback system is removed. It's replaced with a subscription
system vaguely resembling `PSStreamModel`. Any callbacks only intended
to be used by the warstory generator are removed (anyone who wants to
write their own warstory generator should extend `BattleSceneStub`
instead).

Battles no longer start paused. You can still start them paused by
passing `paused: true` as an option.

Playback state tracking had a bunch of rearrangement:

- `playbackState` no longer exists; state should be directly read from
  `paused`, `atQueueEnd`, `turn`, and `seeking`.

- `turn` is now initialized to `-1`. `-1` now means "we haven't reached
  `|teampreview|` or `|start|` yet". Reaching those sets turn to `0`.

- "Fast forwarding" and "seeking" are now consistently named "seeking".
  - `seeking` tracks seek state; changes from `fastForward`:
    - `null` means not seeking (replaces `0`)
    - `0` means seeking the start (replaces `0.5`)
    - `Infinity` means seeking the end (replaces `-1`)
  - `fastForward` deprecated and replaced with `seeking`
  - `fastForwardTo()` deprecated and replaced with `seekTurn()`

- `resultWaiting` is removed (it's unused)

- The "activity queue" has been renamed the "step queue", which means
  some renamed properties:
  - `activityQueue` to `stepQueue`
  - `activityStep` to `currentStep`
  - `nextActivity()` to `nextStep()`

- new property: `atQueueEnd` to track if animation has caught up to the
  end of the step queue (replaces checking `playbackState`)

- new property/option: `isReplay` - will automatically set `ended` when
  reaching the end of a replay (stopping music and showing a message),
  if the replay was saved before the end of the battle

- both replay players (`replay.pokemonshowdown.com` and downloaded
  files) have been rewritten to use an observer system, instead of the
  previous manual updating

- `reset(true)` has been renamed `resetStep()`
2021-01-23 13:17:23 -08:00
Guangcong Luo
7fc87cad1c Build data/text.js from server
text.js is no longer maintained in the client repo; it's now built
directly from the server's data/text/ directory.
2020-10-27 17:09:49 +00:00
Kirk Scheibelhut
d76cd108dd Create test pages for sprites
Similar to styles/STYLING.html and styles/hpbartest.html, test pages
prove to be more robust and convenient for testing than the unit
tests (which are already broken).

These pages are primarily intended to help with delivering #1369,
but can be used to test improvements to sprites across the board.
2020-04-02 11:48:50 -07:00
Kirk Scheibelhut
81c99f66c6 Add getType to ModdedDex and populate correctly (#1478) 2020-03-20 16:06:54 -07:00
Kirk Scheibelhut
9714d936a5 Begin adding sprite tests (#1476) 2020-03-15 22:34:44 -07:00
Guangcong Luo
91f14bd320 Add test/check-filenames script
This script will make sure a directory of sprites (or cries, or
anything else) is in PS `spriteid` format.
2020-02-05 11:30:18 -08:00
The Immortal
e119386e44 Fix build 2020-01-17 13:35:09 +04:00
Kirk Scheibelhut
575bad1cf9 toId -> toID
Zarel/Pokemon-Showdown#5479
2019-05-14 09:54:18 -07:00
Guangcong Luo
a9b8155b5d Implement EV guesser test
Also improve existing battle test.
2019-03-06 13:49:17 -06:00
Guangcong Luo
e489b36856 Fix Confusion message grouping 2019-01-07 21:45:58 -06:00
Guangcong Luo
fd5f54c99c Autoconvert old protocol messages
Instead of needing to support old protocol messages, we now introduce
BattleTextParser.upgradeArgs, which automatically upgrades them to new
protocol messages.

Fixes #1199
2019-01-07 21:12:00 -06:00
Guangcong Luo
2471482fb4 Battle.lineParse -> BattleTextParser.parseLine
BattleTextParser.parseLine -> BattleTextParser.parseArgs

This makes it so Battle depends on BattleTextParser, rather than
BattleTextParser depending on Battle.

This is probably better, because someone is way more likely to want
BattleTextParser standalone, than to want Battle standalone.

...which I'm sure matters to literally no one but me, but whatever. I
think it makes more sense this way.
2019-01-05 05:41:05 -06:00
Guangcong Luo
d05fe62375 Use require instead of eval in ./test/parse
I still don't like how everything's a global in Node, but for now we
don't have a better solution.
2019-01-05 05:15:37 -06:00
Guangcong Luo
dcb3a6f769 Ugly hack to support tests in Node.js
Previously, we used the `eval` hack to "import" our code into test
files. The biggest problem with that approach is that we don't get
line numbers.

Now, we're assigning relevant variables to globals in Node.js for
tests. It's ugly, but it works. There's no simple way to import local
variables only if we're in Node.

Ideally, we'd build this in two different ways: A .mjs file for Node,
and a .js file for the browser. Or maybe use UMD. I'll figure it out
later, I guess.
2019-01-03 03:58:06 -06:00
Guangcong Luo
e186f57f41 Rename .mocha.js -> .test.js
This spec file is, incidentally, Jest-compatible. I benchmarked and
Jest is noticeably slower right now, so I'll stick with Mocha, but
if we ever need Jest features, it'll be useful to be able to easily
switch.
2019-01-03 03:42:13 -06:00
Guangcong Luo
38b66272f2 Fix issues identified by LGTM
Out of 12 issues found:

3 bugs:

- duplicate property - caught a bug in Gen 1 Light Screen
- duplicate property - caught a bug in Gen 1 Reflect
- unused variable - caught a bug in type animations

7 harmless but good for code quality:

- unused variable - harmless but good for code quality
- unused variable - harmless but good for code quality
- unused variable - harmless but good for code quality
- unused variable - harmless but good for code quality
- duplicate case - harmless but important for code quality
- unused variable - harmless but good for code quality
- unused variable - harmless but important for code quality

2 not-bugs that had to be worked around:

- unused variable - used for an `eval` trick, had to use a workaround
- unused variable - used for readable destructuring

I think on balance, LGTM does more good than bad. Catching bugs early
is worth some amount of hassle.

(Also like half these problems are problems tslint could catch if I
actually bothered to set it up...)
2018-11-15 18:52:53 -06:00
Guangcong Luo
80684f698c Drop BattleLog dependency from headless Battles
Mostly, this involves removing `BattleLog.escapeHTML` from `battle.ts`.
All previous use-cases have been replaced with something like
`Tools.sanitizeName`.

Technically, the dependency remains for `|controlshtml|` and
`|fieldhtml|`, but these will be dropped for BattleRoom/GameRoom
separation, to be done in the Preact rewrite.
2018-11-15 18:52:53 -06:00
Guangcong Luo
aa2eecb7cc Add script for testing the new battle parser
(Run `./test/parse` and pipe protocol messages to stdin.)
2018-11-15 18:52:53 -06:00
Guangcong Luo
5f05adc856 Split battle-log.ts off from battle-dex.ts
This splits battle-dex.ts up into:

- `battle-dex.ts`
  - dex data access, misc tools
- `battle-log.ts`
  - manipulating HTML, especially in battle logs

This turned out to be a pretty significant portion of what was
previously battle-dex.
2018-11-15 18:52:53 -06:00
Guangcong Luo
f86245febb Add mocha tests to npm test 2018-10-16 03:31:27 -05:00
Guangcong Luo
fb4f83a580 Remove testcafe dependency
It was unused and vulnerable.
2018-10-16 03:04:52 -05:00
Dan Huang
ee91a72dc6 Support headless client Battle (#1151) 2018-10-16 02:48:59 -05:00
Guangcong Luo
a0421462c8 Comment out VGC teambuilder test 2017-11-23 01:39:06 -06:00
Konrad Borowski
ccf4621c7d Use different Pokemon in tests to avoid failures
I would prefer if the test would still test if a mega gets an item,
which is why Charizard-Mega-Y was picked. It's unlikely to be banned,
but is powerful enough to stay in OU.

A safer choice would be an Arceus, but there is no code yet that
automatically gives a correct item to formes (may be worth fixing).
2017-08-07 22:53:54 +02:00
asgdf
8eb42e83b3 Allow export of the 'uncategorized' format folder (#976) 2017-08-02 20:29:18 -04:00
Konrad Borowski
f41ef9d245 Test if Trump Card has 5 PP (#965)
Test if Trump Card has 5 PP

This I believe was a regression that was fixed by 2fac7642f6.
2017-07-06 20:31:51 -05:00
Konrad Borowski
cfd87a91c1 Add level 50 Pokemon test for VGC (#964) 2017-07-06 15:34:20 +09:00
Konrad Borowski
156b5bf3d5 Add testclient unit tests (#957) 2017-06-27 17:43:54 -07:00