`battle.tour` is now just a reference to the tour.
`battle.rated` is now just the minimum Elo rating of the two players
in the battle.
With the new RoomGame battles, neither of their old values are
necessary anymore.
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.
onUpdateConnection is called when a user in a room merges with
another user. There are various corner cases when one might want
to handle this situation differently from onConnect
Also document the events in room-game.js in more detail, and fix
up simulator.js's RoomGame implementation a bit.
This is a huge refactor that's a half-scratch rewrite of simulator.js.
Everything seems to be working so far, but with such a huge change,
I wouldn't be surprised if something went wrong.
ResourceMonitor has been moved from app.js into monitor.js and
renamed to simply Monitor. It also gains the ability to fine-
grained control the log level, although in a pretty crude way.
Monitor.debug - bugs in PS's engine that we need to fix
someday - by default, these aren't reported
Monitor.warn - issues that suggest an attacker or poorly
coded custom client - these should probably be looked at
Monitor.notice - issues that staff probably want to know.
These are usually also written to the Staff room.
JSHint is now a fair bit stricter, and is now correctly checking
files in `mods/`.
The code has been fixed to match the new stricter standards.
JSHint has now caught its second actual bug: Gen 5 Pinap Berry
was Ice instead of Grass.
I used a hack to make the multiple declaration errors go away,
so all that remained in jsHint were actual errors, which I've
now mostly fixed.
All this linting ended up uncovering one actual bug: Uproar's
message not showing. It's a very minor bug in a move no one uses,
so I'm going to fold it into this commit.
The main process no longer does any JSON parsing/stringifying of
teams. The communication protocol with validator processes has
been changed from JSON to a string protocol delimited by pipes.
A variety of more minor optimizations have also been done.