Commit Graph

4314 Commits

Author SHA1 Message Date
Guangcong Luo
aa2eecb7cc Add script for testing the new battle parser
(Run `./test/parse` and pipe protocol messages to stdin.)
2018-11-15 18:52:53 -06:00
Guangcong Luo
f6c03e0370 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:53 -06:00
Guangcong Luo
5f05adc856 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:53 -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
Ridaz
3cccd571bb Correct Solar Blade animation 2018-09-08 16:02:28 +01:00
Ridaz
aade9ef11e Fix misc animation errors 2018-09-07 19:24:59 +01:00
Guangcong Luo
11b3022250 Clean up more unused variables 2018-09-06 05:35:18 -05:00
Guangcong Luo
31b0fb4460 Stop using document.write in replay-embed.js
I absolutely refuse to believe there's any risk at all to using
document.write with a constant string.

But it's fair that it's non-standard, and won't work if the script
is loaded dynamically/asynchronously, so let's switch to the standard
way to dynamically load scripts and styles.

I'm still using `.src = foo` instead of `.setAttribute('src', foo)`
because there's no reason to write modern code when old-school code
works and is arguably more readable.
2018-09-06 05:35:18 -05:00
Guangcong Luo
b207be59a6 Comment out unused variables in battle.ts
I know, I know, unused code should be removed, not commented out. In
my defense:

1. This kind of code is really annoying to dig out of Git.

2. This kind of code will be used when this is refactored for use for
   an external messages file, which is planned (and necessary for
   translation support.)
2018-09-06 02:57:01 -05:00