DoSomething/ds-mdata-responder — pull request #355 by tongxiang (2014-12-08 22:35:00+00:00)
Title: Auto-start functionality

#### What's this PR do?
This PR incorporates auto-start functionality. What does this mean?

Once a game is created, a timer is set (currently set for five minutes). Once the delay runs out, if no betas have joined the game, a solo game is created automatically for the alpha. If any betas have joined the game, a multiplayer game is created automatically with those betas.

#### Where should the reviewer start?
There are a number of things to note with this PR:
1. We've refactored the `.gameStart()` function formerly attached to the SGCompetitiveStoryController's prototype. We've changed it to only take one parameter (gameDoc), and moved it into its own file--`logicGameStart.js`.

2. We've created a new module, `gameAutoStart.js`, which handles the main logic for checking the game state at a certain time interval and creating or starting games. Note that this function is required into the main SGCompetitiveStoryController with a flag checking if the game type is "solo"--this is to avoid recursive calling of the `gameAutoStart` function.

#### How should this be manually tested?
After reducing the `AUTO_START_GAME_DELAY` param within `gameAutoStart.js`, this has been tested with Postman for the following two scenarios: 1) when the game is created, but no one joins, and 2) when the game is created, and betas join. In both cases, it's been found to create the requisite state changes.

Additionally, `npm test.`

#### What are the relevant tickets?
Closes #354.

#### Questions:
I moved the `.gameStart()` function into its own file because of circular require() statements. Does it make sense to have a separate file for this? Should I just merge `logicAlphaStart.js` and `gameAutoStart.js` into the same file? It seems like our module structure is ballooning. Tomorrow morning, I'll think critically about this. Maybe write a test for this before refactoring the module structure.