aiannacc/Goko-Salvager — pull request #228 by michaeljb (2014-05-11 08:35:15+00:00)
Title: Always Stack module with no method overrides

This branch is based off my `grunt` branch rather than `beta`, so #227 should be merged before this pull request (after which this pull request should just be one commit, 130ceae4fc368d42810b83dc6aa96c07950e580c). I did this mainly so I could easily develop with `grunt watch:chrome`.

I imagine that getting access to the active game client instance will be something other modules want, so that should probably be split out of `alwaysStack.js` into something more generic and reusable in `utils.js`. I'm not completely sure what the best thing to do for this would be, but I had something like this in mind:

```javascript

// in utils.js
GS.whenGameClientReady = function (callback) {
mtgRoom.conn.bind('gameServerHello', function (msg) {
var gameClient;

gameClient = _.find(mtgRoom.games, function (game) {
return game.gameAddress === msg.data.gameServerAddress;
}, this);

callback(gameClient);
});
};

// in alwaysStack.js, instead of the mtgRoom.conn.bind call
GS.whenGameClientReady(function (client) {
if (GS.get_option('always_stack')) {
client.clientConnection.bind('moveCards', alwaysStack);
}
});

```