Skip to content

Commit

Permalink
some diagnostic code for heroku database issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo committed Sep 19, 2013
1 parent 854c687 commit 5f3f223
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
36 changes: 20 additions & 16 deletions client.js
Expand Up @@ -622,10 +622,10 @@ if (Meteor.isClient) {
return this.MAX_POINTS - this.points;
};

// Template.deployment.created = defaultMessage;
Template.deployment.created = defaultMessage;

Template.deployment.rendered = function(){
defaultMessage();
defaultMessage(false);
initializeSpinners(this.data);
};

Expand Down Expand Up @@ -867,7 +867,6 @@ if (Meteor.isClient) {
function createGameFromForm(){
var input = formToHash(".new-game-form");

var temp = 1;
Meteor.call("userLookup", input["opponent"], function(err, opponent){
var required = ["name", "faction", "map", "opponent"];
for(var i = 0; i < required.length; i++){
Expand Down Expand Up @@ -905,8 +904,11 @@ if (Meteor.isClient) {
var map = Maps.findOne(input["map"]);
var game = new Game(name, allies, axis, map);
game._id = Games.insert(game);
console.log("inserted game " + game._id);
console.log(Games.findOne(game._id));

location.reload();

// TODO: dump directly into game instead of going back to the list
// initializeGame(game);
return true;
Expand Down Expand Up @@ -959,19 +961,21 @@ if (Meteor.isClient) {
var success = setUnitLocation(unit, hex.getCoords(), board);
if(!success) return false;

if(!game.players.east && allowedEast){
game.players.east = player;
game.players.west = getOpponent();
message("You've chosen the Eastern front!");
} else if(!game.players.west && allowedWest){
game.players.west = player;
game.players.east = getOpponent();
message("You've chosen the Western front!");
} else {
defaultMessage(false);
return true;
}
Games.update(game._id, {$set: {players: game.players} });
// TODO when facing implemented: first player chooses side
// if(!game.players.east && allowedEast){
// game.players.east = player;
// game.players.west = getOpponent();
// message("You've chosen the Eastern front!");
// } else if(!game.players.west && allowedWest){
// game.players.west = player;
// game.players.east = getOpponent();
// message("You've chosen the Western front!");
// } else {
// defaultMessage(false);
// return true;
// }
// Games.update(game._id, {$set: {players: game.players} });
defaultMessage(false);
return true;
}

Expand Down
7 changes: 5 additions & 2 deletions lib/game.js
Expand Up @@ -4,8 +4,11 @@ function _Game(name, alliesPlayer, axisPlayer, map){
this.players = {
allies: alliesPlayer,
axis: axisPlayer,
east: undefined,
west: undefined
east: axisPlayer,
west: alliesPlayer
//TODO when facing implemented:
// east: undefined,
// west: undefined
};
_rollInitiative(this);
this.mapId = map._id;
Expand Down

0 comments on commit 5f3f223

Please sign in to comment.