Commit Graph

28 Commits

Author SHA1 Message Date
asgdf
1a922d9ea4 Don't allow locked users to roompromote (#2986) 2016-12-04 10:10:56 -06:00
QuiteQuiet
17a18e7a2a Tests: Update TeamValidator tests and add new ones (#2855)
* Tests: Add TeamValidator nature and happiness test

* Tests: Make TeamValidator test synchronous
2016-10-27 13:01:35 -05:00
Guangcong Luo
87c41eb67c Rename simulator.js to room-battle.js
simulator.js doesn't actually contain the simulator, but is really just
an implementation of battles in the RoomGame interface.

Renames:
`Simulator.Battle` -> `Rooms.RoomBattle`
`Simulator.BattlePlayer` -> `Rooms.RoomBattlePlayer`
`Simulator.SimulatorManager` -> `Rooms.SimulatorManager`
`Simulator.SimulatorProcess` -> `Rooms.SimulatorProcess`
`Simulator.create` -> no longer exists, use `new Rooms.RoomBattle(...)`
2016-10-21 13:21:12 -05:00
Guangcong Luo
d6f5404e7e Rename CommandParser to Chat
We had a lot of discussion in Dev and a somewhat-close poll, but in
the end "Chat" was a better name than "Messages", and also has the
advantage of being shorter (which is nice for Chat.html and
Chat.plural which should be short).
2016-09-30 18:31:15 -07:00
Ivo Julca
ce9cdecafd Drop commands sent to rooms from outside 2016-09-17 19:42:15 -05:00
Ben Davies
d9c6fe54b2 ProcessManager: subclass to extend ProcessManager, unit tests setup (#2739)
Before, an options object containing properties and values to be used
was how decorated instances of the class would be created. This meant
the constructor could assign anything you feel like to `this`. Rather
than that, the constructor now assigns a strict set of values, and
methods are redefined in subclasses.

Basic unit tests were added to test if they could be written for after
the final refactor to fix the other memory leak here.
2016-09-09 15:51:49 -05:00
Taylor Everding
1a1f64fe95 Remove .js extension from requires (#2725) 2016-08-30 00:04:40 -05:00
Guangcong Luo
1a1530f4ff Refactor Connection#rooms to Set
Connection#rooms, previously a null-prototype roomid:room Object,
is now Connection#inRooms, a roomid Set.

This, incidentally, makes it stop retaining rooms, which may make the
GC's job easier and may also lead to unexpected bugs if we get
inconsistent state (we often do get inconsistent state, so look
forward to that!)

The rename is mostly to put it in line with the new User#inRooms,
and for ease of greppability without running into Rooms.rooms.
2016-08-22 03:57:52 -05:00
Ben Davies
5c4834f3fd Tests: tweak user mocks, add Connection tests, fix Trivia tests (#2682)
Worker mocks now have proper ids. Trivia tests now dispose of user objects
rather than letting them stay in memory for the rest of the tests.
2016-08-09 04:02:27 -05:00
Guangcong Luo
34650dd455 Refactor Rooms.rooms and Rooms.aliases to Map 2016-08-08 16:46:11 -05:00
Konrad Borowski
bb3acda351 Copy auth from tournament room to tournament battle (#2608)
This allows room staff to perform moderation in tournament battles.
2016-07-06 07:28:47 -05:00
Ivo Julca
9d5e0e78a7 Resolve tournament matches on battle room expiry 2016-07-01 10:07:03 -05:00
Quinton Lee
e08f7ef4c0 Test: add TeamValidator tests (#2546) 2016-05-04 16:33:16 -07:00
Bär Halberkamp
b450b0617f Move things relating to punishments to punishments.js (#2540) 2016-05-02 12:16:25 -07: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
Guangcong Luo
c7bb5b5315 Add RoomGame support for /joingame, /leavegame
The old commands /joinbattle, /leavebattle are now /joingame and
/leavegame, and can be implemented by any RoomGame.
2016-01-19 01:47:26 -08:00
Ivo Julca
1673f1fd9b Test: make player name sync regression test more robust
If Custom Game was configured as never rated (in order to e.g. give it an unrated ladder), it would yield bogus failures.
2015-12-20 00:18:23 -05:00
Guangcong Luo
332a65f9c0 Convert some Users tables to ES6 Maps
Specifically, Users.users, Users.connections, and Users.pastUsers
are now ES6 Maps. In theory, this should be a minor performance
upgrade, but we still need to profile to make sure.
2015-12-10 11:52:26 -05:00
Ivo Julca
50c3f8f8aa Fix test for battle player identifier consistency after rename 2015-12-03 20:45:13 -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
Ivo Julca
9a52fe337f Parse all numerical user input as base 10
Also took the chance to commit some style fixes missed in 90973d5 and 04c64c1.
2015-11-07 20:08:01 -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
Ivo Julca
47263c8749 Fix players of rated battles getting out of sync on rename
- 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).
2015-07-29 15:18:17 -05:00
Ivo Julca
43e20ebf24 Add regression test for issue described in b3b435c 2015-07-07 03:11:49 -05:00
Ivo Julca
b441375b5a Test: move utility functions to dev-tools/ 2015-07-07 03:08:18 -05:00
Guangcong Luo
e35ed8ebd5 Refactor login
finishRename was a really huge function. This splits it into three
much more manageable functions with more useful names.
2015-06-25 04:43:34 -04:00
Ivo Julca
68aaa48974 Gulpfile: no files are exempt from style checks
- Streams are merged to make sure that all errors and warnings are reported.
- Adds dev dependencies: `merge-stream` and `lazypipe`.
- Tracks a fork of `gulp-jshint` to fix https://github.com/spalger/gulp-jshint/issues/88
2015-02-18 19:51:15 -05:00
Ivo Julca
18ee206833 Add some basic application tests 2015-02-15 13:28:03 -05:00