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()`
This optimizes JavaScript parsing performance. V8 developers
recommend applying this optimization for objects of 10 kB or
larger, see <https://v8.dev/blog/cost-of-javascript-2019#json>
for more details. Teambuilder tables are 3.5 MBs which is much
more than 10 kB.
We can't share code because the client uses XHR and the server uses Node's
HTTP/HTTPS libraries, but we're now sharing a lot of the API, which should
make it more familiar.
* Add /battlerules for help challenge
I added the /battlerules for the help challenge and an alias for help (h)
https://www.smogon.com/forums/threads/add-custom-rules-page-to-help-challenge.3674780/
* Update js/client-chat.js
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
* Update js/client-chat.js
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
Ig infobox-limited class is in room intros and in the event box. On mobile phones, it is hard to check the whole room intro or event and you can slide because overflow for the x axis is hidden. So just removing overflow-x: hidden.
Normally, replay-embed expects the full file structure provided
from downloaded replay files.
This new version will create it, so it only needs
<!DOCTYPE html>
<script type="text/plain" class="battle-log-data">
The DOCTYPE is unfortunately still needed to force strict mode.