Unless we want to change the syntax for data tables like pokedex.js,
'constructor' will always exist as a table key.
These changes represent the bare minimum to prevent this from
causing too-weird behavior.
An external dependency is kind of overkill when the only
implementation we need is three lines.
This also lets us write a more performant implementation that
omits the parts irrelevant to us.
The callback code in TeamValidator and the functions that use it have
been refactored to use Promises.
Pretty much all signatures have been changed, for instance:
TeamValidator.validateTeamSync(format, team)
-> TeamValidator(format).validateTeam(team)
TeamValidator.validateTeam(format, team, callback)
-> TeamValidator(format).prepTeam(team) // returns a Promise
Validators are no longer cached since they're really lightweight. They
contain a format and a Tools instance, and Tools instances are already
cached in Tools anyway. This saves a tiny bit of RAM in exchange for a
tiny bit of CPU time, but more importantly makes the code more
readable.
I'm introducing a new pattern/API for managing the parts of code with
child processes - their process managers are now at .PM and are now
opt-in, so you can use them synchronously without needing to spawn
any processes.
Fixes#2448
Now that nodejs/node#3072 is mostly fixed, we can finally start using
Node 4+ features.
This refactor:
- uses arrow functions where appropriate
Note that arrow functions still aren't used in Mocha, where `this`
is sometimes meaningful.
This also removes the need for .bind() nearly everywhere, as well
as the `self = this` trick.
- refactors Validator and Connection into ES6 classes
- no longer uses Array#forEach for iterating arrays
We strongly prefer for (let i = 0; i < arr.length; i++) because of
performance reasons. Most forEaches have been replaced with for..of,
though, which is 5x slower than the long-form loop but 2x faster
than forEach, which is good enough outside of most inner loops.
The only exception is tournaments, which is due for a more invasive
refactor soon anyway.
Crashlogger now supports passing in a dictionary of additional
information to report, so we no longer need to resort to making fake
errors.
The hadException parameter has now been removed entirely. I don't know
of a use case for it to be false.
The old code told me Tyranitar with Dragon Dance + Outrage needed to
have Guts (which is Larvitar's ability), which is clearly wrong.
The new code figures out the correct ability for the corresponding
ability slot.
There's no need to push individual move sources if sourcesBefore covers
it.
Unfortunately, 5M and 5T come after 5E, so it's not nearly as optimal
as it could be...
Joim's previous code apparently already did, but this implementation
does it correctly with the set-intersect system.
As an added bonus of correctly using the set-intersect system, it now
shows up properly in /gsclearn
The old code had a number of huge logical errors, which led to various
ridiculous bugs like how gen 2 moves had to be in a certain order to
validate correctly.
The new code is rewritten from scratch and fixes all known problems in
the old code, and also applies it to all gens. Preliminary testing
hasn't revealed any flaws, so we'll see how this does in prod.
Previous check was requiring Latias-Mega to have 3 perfect IVs because
Latias-Mega is a gen 6 pokemon even though Latias itself isn't.
This also gives clearer error messages in the remaining situations.