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...)
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.
Honestly, the CSS solution was really cool. It was just incompatible
with the new system. It also had enough other flaws (like, bad
accessibility) that I don't feel _too_ bad about ripping it out.
The new version is less code, anyway, although it does have the flaw of
needing to replay the battle if you turn nicknames on or off.
Fortunately, that should be a rare enough occurrence not to be a big
deal.
Default start messages do two things:
1. Remind us that we don't have a real message coded for an effect.
2. Support showing any kind of start message by default for custom
modded games. (It's of course still an option to pass `[silent]` and
then add a custom message with `|-message|`.)
All battle text messages have been moved out of `src/battle.ts` and
into its own file `data/text.js`.
Code for handling this is in the new files `src/battle-log.ts` and
`src/battle-text-parser.ts`.
`data/text.js` is now extremely self-contained, and nearly ready for
translation support!
This is a significant modernization of battle.ts. In addition to moving
messages out:
Functions for getting names (`pokemon.getLowerName()` etc) have been
removed.
`battle.minorQueue` has been removed. Minor lines are now processed
directly on the main queue, with a new `battle.waitForAnimations`
flag to decide whether or not the main queue should wait for animations
to finish before moving on to the next line.
`battle.waitForResult()` and `battle.endPrevAction()` have been
removed. These confusingly-named functions closed the messagebar (and
flush the minor queue). They've been replaced with
`scene.maybeCloseMessagebar()`.
`pokemon.markMove()` and `pokemon.markAbility()` have been renamed
`pokemon.rememberMove()` and `pokemon.rememberAbility()`.
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.
POSTing JSON data is now supported, since apparently Axios does that by
default: #1160
In addition, error messages should be more informative, for anyone else
trying to write a third-party client.
In the old days, we used to have a white wisp if someone used an
unrecognized move. Apparently the current behavior is to crash?
Shameful! This defaults to the Tackle animation, which is probably
sensible. For self targeting moves, it'll just look like some jumping
around, which is workable.
This makes how classes are defined in the client less consistent
than before, but the new client, which doesn't have this problem, is
well underway, so this isn't a big deal in the long term.
PS the server will ignore all messages above ~150 KB. To protect against
DoS attacks, this is done silently, with no response at all.
Note that this is is not at all a problem for normal teams with 6
Pokemon, which come in at around 1KB.
Users sometimes make a mistake and send corrupt teams above this limit,
such as an import error causing a team with 1000 Pokemon or whatever.
This used to happen silently, confusing users and causing them to retry,
but this change gives it an error message.
I really do have to investigate more closely exactly what this code is
doing, but I remember the last time I tried to simplify this, it broke
Unicode support.
The username on the password field is now a visible read-only textbox,
instead of a hidden textbox.
This is apparently required for Chrome to realize that it's a username
field for the purposes of its password manager.
We now just use JSON.parse and JSON.stringify - it's supported by all
browsers supported by the client.
Tools.safeJSON has also been moved to Storage.safeJSON, since it's not
used in replays at all.
The Toxic turn tracker is now 1 off from previously; it now counts the
previous Toxic turn rather than the next one. This makes "0" more
intuitively represent the state before any Toxic damage is taken.
This fix mainly just fixes the type issue by removing the need for a
null value at all.
This doesn't change debuggability and saves a bit of bandwidth.
But most importantly, it might help Windows users who are having
trouble compiling because Babel runs out of memory.
Restoring a backup previously required all teams to be packed, or all
teams to be unpacked. Now, we support pasting a mix of packed and
unpacked teams.