Skip to content

Instantly share code, notes, and snippets.

@joshuacrowley
Last active August 29, 2015 14:23
Show Gist options
  • Save joshuacrowley/3604b7750ca9fbc54b6f to your computer and use it in GitHub Desktop.
Save joshuacrowley/3604b7750ca9fbc54b6f to your computer and use it in GitHub Desktop.
addTiles : function(gameToken, playerToken, tiles){
var unplayed = Tiles.find({
"gameToken": gameToken,
tileState: "unplayed",
"owner": "none",
}).fetch();
if (unplayed.length > 0){
var selected = _.first(unplayed, tiles);
selected.forEach(function (tile) {
Tiles.update({_id : tile._id}, {$set: {owner: playerToken}});
});
console.log(selected.length + "given to " + playerToken);
}else{
console.log("none left");
};
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment