DoSomething/ds-mdata-responder — pull request #62 by jonuy (2014-07-01 18:48:56+00:00)
Title: Logic to start an MP SMS game

#### What's this PR do?
The two start-game scenarios are handled here.
* `/game/beta-join`
When a beta joins the game, one of two things can happen. 1) If all other betas have joined, then the game auto-starts and everyone is sent the first message in the story. 2) Otherwise, the recently joined beta gets a waiting message, and the alpha is given a message where she has the option to manually start anyway.
* `/game/alpha-start`
An alpha choosing to manually start the game will trigger this endpoint. And yea, this endpoint basically just starts the game with whoever's joined so far.

#### Where should the reviewer start?
This PR builds off of #60, so start there if you haven't seen it yet.

`app/router.js` adds the two new endpoints. It's worth noting only SGCompetitiveStoryController has implemented this logic. It's TBD whether or not to move it all up to a base game controller class or something.

`sgCompetitiveStoryController.js` has all the logic for handling the start game scenarios. Because there's a chain of database querying that needs to happen, you'll see both routes go from `betaJoinGame/alphaStartGame` to `onUserFound` to `onGameMappingFound` to `onGameFound`. In that last step is where the `RequestType` comes in to figure out how to handle the request.

#### How should this be manually tested?
A simple frontend will comes soon where this stuff can be tested. Otherwise, I've been manually testing by...

1) Creating a game: `POST localhost:4711/game/create` with parameters -
```
type=competitive-story
person[first_name]=
person[phone]=
friends[0][first_name]=friend0
friends[1][first_name]=friend1
friends[2][first_name]=friend2
friends[0][phone]=13015550101
friends[1][phone]=13015550102
friends[2][phone]=13015550103
story_id=1
```
2) Joining a beta to the game: `POST localhost:4711/game/beat-join` with parameters -
```
type=competitive-story
phone=
```
3) Alpha auto-starting the game: `POST localhost:4711/game/alpha-start` with parameters -
```
type=competitive-story
phone=
args=Y
```

#### What are the relevant tickets?
Closes #36
Closes #37
Closes #38