Commit Graph

15 Commits

Author SHA1 Message Date
Guangcong Luo
54b672fe4e Start refactoring for template strings
This commit introduces Tools.html and Tools.plural, helper functions
for string construction.

Tools.html is a template tag function that escapes HTML inside the
template string.

Tools.plural is a helper function that takes a passed Number, Array,
Set, or Map and returns a string representing whether or not it's
plural.

It also starts doing some refactors of some files to make it clear how
I expect code style for template strings to look.

Previously, we used ' for IDs, " for English text, and ' for code.

We should now be using ' for IDs, ` for English text, and ` for code.
2016-08-28 04:35:43 -05:00
Bär Halberkamp
5b584cdc35 Implement /rank for other servers 2016-03-02 06:03:33 +01:00
Guangcong Luo
b665660608 Refactor for more ES6 features
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.
2016-02-10 17:40:21 -06:00
Konrad Borowski
81f602b8d8 Always use trailing comma for multiline objects 2016-01-01 00:20:07 +01:00
Guangcong Luo
c3874827bd Don't show debug message when loading empty ladder 2015-12-04 15:05:51 -05:00
Guangcong Luo
341ab3b684 Refactor simulator.js to new RoomGame API
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.
2015-12-03 18:30:47 -06:00
Guangcong Luo
66381f1317 Improve commenting 2015-12-02 22:14:23 -06:00
Guangcong Luo
b37d96f2ec Refactor ladders.js for ES6 class syntax
One day, we'll convert all our files, but for now I'm just doing
this one as an example. I chose this one specifically because
it's reasonably small and pretty modern.

While I'm at it, I also improved the commenting a bit.
2015-12-01 15:02:56 -06:00
Ivo Julca
a5f4c85d56 Fix ladders
- TDZ violation in remote ladders.
- Lack of `get` method in local ladders.
2015-11-08 15:52:00 -05:00
Ivo Julca
7dddb66253 Migrate build system to ESLint
JSHint's ES6 support is shaky, and its development has stalled as of late.
Since ESLint can do by itself both JSHint and JSCS' jobs, this commit replaces them.
Gulp and its related dependencies are also hereby removed.
2015-11-07 21:36:49 -05:00
Ivo Julca
04c64c143e Cleanup: remove several unused variables 2015-11-07 17:34:21 -05:00
Ivo Julca
90973d5c0c Style fixes
- Cut down excessive spacing
- Add braces to missing conditionals
2015-11-07 17:08:09 -05:00
Juanma Serrano
c4ac8d6e2f Use strict mode and let and const instead of var
This commit also fixes some duplicated variable declarations.
2015-11-06 21:56:52 -05:00
Guangcong Luo
674a55a405 Fix double logging in new ladder code 2015-09-22 04:58:46 -05:00
Guangcong Luo
b7797ea725 Add basic local ladder support
This initial local ladder support is really basic. Just Elo/W/L/T in
.tsv files. No support for /rank yet.

Servers are encouraged to write and share their own ladder
implementations. The protocol is designed to allow basically any kind
of ladder you want.
2015-09-22 04:52:43 -05:00