This abstracts matchmaking logic from the global room away to its own
module, allowing the two to be decoupled from each other entirely with
some refactoring.
Related to #3361
* Sockets: fix Sockets.killWorker not disconnecting connections
* Sockets: fix unit tests
- Fix crash when constructing mock sockets in certain cases
- Properly prevent workers from writing to stdout
- Fix race conditions in workers-related tests that were causing false
positives
* Tests: mock workers now more closely imitate sockets' workers
This helps catch cases where messages are being sent in the wrong order
to the workers, e.g. messages sent to sockets that no longer exist.
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.
- This removes one of the reasons of `sendFor` calls' sometimes failing.
- This also fixes battle logs so that they register the proper end type (forfeit).