forked from smogon/pokemon-showdown-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Battle class API (smogon#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()`
- Loading branch information
Showing
9 changed files
with
360 additions
and
394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.