{"size": 869, "ext": "js", "max_stars_repo_path": "client/templates/createGame.js", "max_stars_repo_name": "johngrantuk/topTrumpsEu", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/templates/createGame.js", "max_issues_repo_name": "johngrantuk/topTrumpsEu", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/templates/createGame.js", "max_forks_repo_name": "johngrantuk/topTrumpsEu", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.9666666667, "max_line_length": 118, "alphanum_fraction": 0.5224395857}
Template.createGame.events({
  'submit form': function(e) {

    e.preventDefault();

    var user = {
      username: $(e.target).find('#name').val(),
      password: "test"
    }

    Accounts.createUser(user, function(error){

      var game = {                                              // Once user has been added create a game record.
        name: $(e.target).find('#gameName').val(),
        owner: user,
        ownerId: Meteor.userId(),                             // New user id is owner id.
        isStarted: false,
        playerTurn: 0
      };

      game._id = Games.insert(game);

      Meteor.call('AddPlayerNo', Meteor.userId(), 0);        // Add player number to user.
      Meteor.call('AddGameId', Meteor.userId(), game._id, user.username);            // User will be part of the game.

      Router.go('gameFrontPage', game);
    });
  }
});
