Commit Graph

4319 Commits

Author SHA1 Message Date
Guangcong Luo
884dfee923 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:36 -06:00
Guangcong Luo
2721c0b8a0 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:36 -06:00
Guangcong Luo
bec475e602 Reimplement "ignore nicknames" without CSS
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.
2018-11-15 18:52:36 -06:00
Guangcong Luo
32a16d3879 Add default start messages
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|`.)
2018-11-15 18:52:36 -06:00
Guangcong Luo
38a033ac4e Remove weather ability-start messages
These _are_ real messages from Gen 3, but since it's not like we
otherwise accurately simulate Gen 3 messages, it's a bit weird to
keep these around.
2018-11-15 18:52:36 -06:00
Guangcong Luo
d4a73e74d4 Add script for testing the new battle parser
(Run `./test/parse` and pipe protocol messages to stdin.)
2018-11-15 18:52:36 -06:00
Guangcong Luo
fd89a66510 Implement new battle-text-parser
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()`.
2018-11-15 18:52:36 -06:00
Guangcong Luo
bf002f9450 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:36 -06:00
Guangcong Luo
368ee06bcc Fix freeze when transforming into self in Gen 1 2018-11-15 19:09:53 -05:00
Guangcong Luo
5b21cce99a Improve action.php
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.
2018-11-14 21:49:40 -05:00
Guangcong Luo
d9f7d903e0 Add autofill hints for login forms
Apparently this is necessary for Chrome to correctly identify which
passwords to save for which usernames.
2018-11-14 21:47:35 -05:00
Guangcong Luo
f75cc7c493 Use Tackle as default move animation
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.
2018-11-14 21:45:47 -05:00
LegoFigure11
09dd5f92ae Add teambuilder support for Battle Spot Special 13 (#1161) 2018-11-08 22:47:52 -06:00
Kris Johnson
273076a88a Add teambuilder support for Fortemons (#1159) 2018-11-01 15:22:40 +04:00
Guangcong Luo
25712419c7 Dex: Support multi-word article titles 2018-10-29 01:50:25 -04:00
Guangcong Luo
0e5b3aa84c Stop reporting failed assertions
We had a great run, but honestly I don't have anything particularly
interesting to do with this data, so I'm turning it off now.
2018-10-28 14:54:12 -04:00
Guangcong Luo
ba4c512166 Remove local class definitions for LGTM
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.
2018-10-28 14:54:12 -04:00
Guangcong Luo
5f8bb7a92e Suppress LGTM warnings
Neither of these warnings are actually incorrect sanitization, but
unfortunately there's no way for any automated tool to know that.
2018-10-28 14:54:12 -04:00
Guangcong Luo
654abc3162 Fix errors caught by LGTM 2018-10-27 04:32:11 -05:00
Guangcong Luo
bbf8306bac Intercept large teams
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.
2018-10-27 03:22:29 -04:00
Guangcong Luo
95adb434f4 Document /debug 2018-10-27 02:49:27 -04:00
Guangcong Luo
622a350009 Tooltips: Rephrase "Not blocked by Protect" flag
It was previously "Bypasses Protect", but "Not blocked by Protect" is
more accurate.
2018-10-26 20:00:31 -04:00
Guangcong Luo
dff666fe81 TypeScript: Suppress depreated 'unescape' complaint
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.
2018-10-26 19:59:06 -04:00
Guangcong Luo
9666fd30d2 Fix Chrome password manager to track username
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.
2018-10-26 19:57:20 -04:00
Guangcong Luo
76805f9068 Add TypeScript to npm test 2018-10-16 21:45:18 -05:00
Guangcong Luo
aa7ea99281 Fix attribution line in search.js 2018-10-16 15:17:58 -05:00
Guangcong Luo
26f78dcce6 Add Preact dependency
Preact is currently unused in the client, but will be used in an
upcoming rewrite. This adds the foundation to support `.tsx` files in
`src/`.
2018-10-16 14:53:27 -05:00
HoeenHero
a094cb7982 Move Mythical pokemon down in VGC teambuilder (#1144) 2018-10-16 14:22:43 -05:00
Guangcong Luo
83b6edc995 Add "Report" button 2018-10-16 04:55:42 -05:00
Guangcong Luo
1a3e03bff6 Bump Node version requirement to 10
Apparently assert.strict doesn't exist on Node 8.
2018-10-16 03:52:16 -05:00
Guangcong Luo
6e8e112b24 Update Babel version
I'm not sure why Travis tests are failing, but this is a common
recommendation when googling the error message...
2018-10-16 03:45:08 -05:00
Guangcong Luo
f86245febb Add mocha tests to npm test 2018-10-16 03:31:27 -05:00
Guangcong Luo
9019543dc1 Don't build graphics.js by default
graphics.js will still be built by `./build full`, and once it already
exists, `./build` will rebuild it when it's modified.

Fixes #1150
2018-10-16 03:26:51 -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
f09d917110 Support incremental builds
`./build` should run a lot faster now.
2018-10-16 00:31:07 -05:00
Guangcong Luo
b6dcc4da35 Remove jQuery-JSON dependency
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.
2018-10-14 22:07:55 -05:00
Guangcong Luo
2aa13ed10c Update CONTRIBUTING.md for new polyfills 2018-10-14 22:05:10 -05:00
Guangcong Luo
8133c8fd3f Battles: Move more jQuery stuff to BattleScene 2018-10-14 21:47:03 -05:00
Guangcong Luo
42d6c0d164 Battles: Use polyfills over jQuery
We were previously using jQuery's $.trim() and Array.isArray(), but
we're now trying to remove the jQuery dependency from battle.ts.
2018-10-14 21:46:36 -05:00
Guangcong Luo
2c43954c41 Fix Toxic turn tracking
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.
2018-10-14 21:14:48 -05:00
Guangcong Luo
7df9e5a7ea Make Babel output compact
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.
2018-10-14 04:36:58 -05:00
Alvin Ho
06621ba2f7 Fix Forme Change and Autotomize Interaction (Client Side) (#1153) 2018-10-08 16:35:17 -05:00
Alvin Ho
ce14663c25 Fix Toxic Orb and 'Next Damage' toolbox interaction (#1155) 2018-10-08 16:32:46 -05:00
Kris Johnson
22aedd4471 Support ZU in the teambuilder (#1152) 2018-10-07 15:52:42 +04:00
Guangcong Luo
a05669b754 Support importing teams in mixed format
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.
2018-09-27 21:44:27 -04:00
Guangcong Luo
24ed8577bf Battles: Fix weather state when switching sides 2018-09-27 20:28:47 -05:00
The Immortal
73030656bb Ladder: Hide sections without any formats
And fix Unrated Random Battle being displayed.
2018-09-19 00:28:34 +04:00
asgdf
8e9c95b509 Tooltips: Properly show shortdesc for moves without long desc (#1146) 2018-09-09 23:52:41 -05:00
asgdf
8dafd449c0 Tooltips: Show status Z-move effects (#1145) 2018-09-09 03:25:28 -05:00