`makeLoadTracker` is deprecated in favor of `PSObservable` in the new
client, and has no reason to remain in battle-dex, which is now has a
specific role rather than its previous role as "random useful
functions".
Instead of needing to support old protocol messages, we now introduce
BattleTextParser.upgradeArgs, which automatically upgrades them to new
protocol messages.
Fixes#1199
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.
Template, Item, Move, and Ability are now classes. This guarantees that
`getTemplate`, `getItem` etc return objects that implement their
interfaces (they didn't before).
As of their current implementation, they require trusted resource
files. The plan is, whenever we support custom resource files, to pass
all their strings through `sanitizeName`. This won't prevent servers
from causing the client to behave unexpectedly, but it should prevent
any actual vulnerabilities.
In addition, pokemon forme icon index tables have been moved to
`battle-dex-data.ts`.
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.
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.