', {
class: "card"
@@ -232,11 +240,10 @@ var Game = {
},
displayCards3: function() {
var self = this;
- if (self.cards1.length == 0) {
+ if (self.cards3.length == 0) {
return false;
}
-
$.each(self.cards3, function(index, card){
var cardNode = $('
', {
class: "card"
@@ -270,7 +277,7 @@ var Game = {
},
displayCards4: function() {
var self = this;
- if (self.cards1.length == 0) {
+ if (self.cards4.length == 0) {
return false;
}
@@ -308,6 +315,16 @@ var Game = {
},
+
+
+
+
+
+
+
+
+
+
existingSet: function() {
var colors = [];
var shapes =[];
@@ -434,248 +451,1094 @@ var Game = {
this.$nbSets1.html(cpt);
},
- setCardListeners: function() {
+ existingSet2: function() {
+ var colors = [];
+ var shapes =[];
+ var fills= [];
+ var borders = [];
+ var numbers= [];
+ var valid;
var self = this;
+ var cartes = self.cards2;
+ var cartes1 = cartes;
+ var cartes2 = cartes;
+ var cartes3 = cartes;
+ var cpt=0;
- // what happens when a card is clicked:
- this.$board.on('click', '.card', function(e) {
- e.stopImmediatePropagation();
- var card = e.currentTarget;
-
- // if card is new, add it, otherwise remove it
- var ids = $.map(self.selected, function(el) { return $(el).data("id");});
- if (ids.indexOf($(card).data('id')) >= 0) {
- self.deselectCard(card);
- } else {
- self.selectCard(card);
- }
- if (self.selected.length === 3) {
- self.silentSubmission();
- }
- });
- },
+ var carte1;
+ var carte2;
+ var carte3;
+ var carte4;
- setPageListeners: function() {
- var self = this;
+ var i, j, k, l;
- // if the user clicks on the page outside the game board, clear selected
- $(document).on('click', function() {
- self.clearSelections.call(self);
- });
- },
+ for(i=0; i 3) {
- this.clearSelections.call(this);
- }
- },
+ shapes.splice(0, 1, carte1.shape);
+ shapes.splice(1, 1, carte2.shape);
+ shapes.splice(2, 1, carte3.shape);
+ shapes.splice(3, 1, carte4.shape);
- deselectCard: function(card) {
- var self = this;
- var index = self.selected.indexOf(card);
- if (index > -1) {
- self.selected.splice(index, 1);
- }
- $(card).removeClass('selected');
- },
- clearSelections: function() {
- $.each(this.selected, function(index, card) {
- $(card).removeClass('selected');
- });
- this.selected = [];
- },
+ fills.splice(0, 1, carte1.fill);
+ fills.splice(1, 1, carte2.fill);
+ fills.splice(2, 1, carte3.fill);
+ fills.splice(3, 1, carte4.fill);
+ numbers.splice(0, 1, carte1.number);
+ numbers.splice(1, 1, carte2.number);
+ numbers.splice(2, 1, carte3.number);
+ numbers.splice(3, 1, carte4.number);
- validateSet: function() {
- var self = this;
- var colors = $.map(self.selected, function(el) { return $(el).data("color");});
- var shapes = $.map(self.selected, function(el) { return $(el).data("shape"); });
- var fills= $.map(self.selected, function(el) { return $(el).data("fill"); });
- var numbers = $.map(self.selected, function(el) { return $(el).data("number"); });
+ valid = self.isSet4(colors) && self.isSet4(shapes) && self.isSet4(fills) && self.isSet4(numbers);
- return (self.isSet(colors) && self.isSet(shapes) && self.isSet(fills) && self.isSet(numbers));
+ if (valid) {
+ cpt = cpt + 1;
+ }
+ }
+ }
+ }
+ }
+ this.$nbSets2.html(cpt);
},
- validateSet35: function() {
+ existingSet3: function() {
+ var colors = [];
+ var shapes =[];
+ var fills= [];
+ var borders = [];
+ var numbers= [];
+ var valid;
var self = this;
+ var cartes = self.cards3;
+ var cartes1 = cartes;
+ var cartes2 = cartes;
+ var cartes3 = cartes;
+ var cpt=0;
- var colors = $.map(self.selected, function(el) { return $(el).data("color");});
- var shapes = $.map(self.selected, function(el) { return $(el).data("shape"); });
- var fills= $.map(self.selected, function(el) { return $(el).data("fill"); });
- var borders= $.map(self.selected, function(el) { return $(el).data("border"); });
- var numbers = $.map(self.selected, function(el) { return $(el).data("number"); });
+ var carte1;
+ var carte2;
+ var carte3;
+ var carte4;
- return (self.isSet(colors) && self.isSet(shapes) && self.isSet(fills) && self.isSet(borders) && self.isSet(numbers));
- },
+ var i, j, k,l;
- validateSet44: function() {
- var self = this;
- var colors = $.map(self.selected, function(el) { return $(el).data("color");});
- var shapes = $.map(self.selected, function(el) { return $(el).data("shape"); });
- var fills= $.map(self.selected, function(el) { return $(el).data("fill"); });
- var numbers = $.map(self.selected, function(el) { return $(el).data("number"); });
+ for(i=0; i -1) {
- cardIds.splice(location, 1);
- self.cards.splice(location, 1);
- }
- });
- },
- updateCards: function(newCards) {
- this.cards = this.cards.concat(newCards);
- this.displayCards();
- },
+ colors.splice(0, 1, carte1.color);
+ colors.splice(1, 1, carte2.color);
+ colors.splice(2, 1, carte3.color);
+ colors.splice(3, 1, carte4.color);
+ colors.splice(4, 1, carte5.color);
- increaseScore: function() {
- this.$score.html(++this.score);
- },
- startRound: function() {
- // todo
- // reset timer to 30 seconds
- },
+ shapes.splice(0, 1, carte1.shape);
+ shapes.splice(1, 1, carte2.shape);
+ shapes.splice(2, 1, carte3.shape);
+ shapes.splice(3, 1, carte4.shape);
+ shapes.splice(4, 1, carte5.shape);
- gameWon: function() {
- alert("you won!");
- },
- gameLost: function() {
- alert("you lost :(");
- }
+ fills.splice(0, 1, carte1.fill);
+ fills.splice(1, 1, carte2.fill);
+ fills.splice(2, 1, carte3.fill);
+ fills.splice(3, 1, carte4.fill);
+ fills.splice(4, 1, carte5.fill);
+ borders.splice(0, 1, carte1.border);
+ borders.splice(1, 1, carte2.border);
+ borders.splice(2, 1, carte3.border);
+ borders.splice(3, 1, carte4.border);
+ borders.splice(4, 1, carte5.border);
-};
+ numbers.splice(0, 1, carte1.number);
+ numbers.splice(1, 1, carte2.number);
+ numbers.splice(2, 1, carte3.number);
+ numbers.splice(3, 1, carte4.number);
+ numbers.splice(4, 1, carte5.number);
+
+
+ valid = self.isSet5(colors) && self.isSet5(shapes) && self.isSet5(fills) && self.isSet5(borders) && self.isSet5(numbers) ;
+
+
+ if (valid) {
+ cpt = cpt + 1;
+ }
+
+
+ }
+
+ }
+ }
+ }
+ }
+ this.$nbSets4.html(cpt);
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ setCardListeners: function() {
+ var self = this;
+
+ // what happens when a card is clicked:
+ this.$board.on('click', '.card', function(e) {
+ e.stopImmediatePropagation();
+ var card = e.currentTarget;
+
+ // if card is new, add it, otherwise remove it
+ var ids = $.map(self.selected, function(el) { return $(el).data("id");});
+ if (ids.indexOf($(card).data('id')) >= 0) {
+ self.deselectCard(card);
+ } else {
+ self.selectCard(card);
+ }
+
+ if (self.selected.length === 3) {
+ self.silentSubmission();
+ }
+ });
+ },
+
+ setCardListeners1: function() {
+ var self = this;
+
+ // what happens when a card is clicked:
+ this.$board1.on('click', '.card', function(e) {
+ e.stopImmediatePropagation();
+ var card = e.currentTarget;
+
+ // if card is new, add it, otherwise remove it
+ var ids = $.map(self.selected1, function(el) { return $(el).data("id");});
+ if (ids.indexOf($(card).data('id')) >= 0) {
+ self.deselectCard1(card);
+ } else {
+ self.selectCard1(card);
+ }
+
+ if (self.selected1.length === 3) {
+ self.silentSubmission1();
+ }
+ });
+ },
+ setCardListeners2: function() {
+ var self = this;
+
+ // what happens when a card is clicked:
+ this.$board2.on('click', '.card', function(e) {
+ e.stopImmediatePropagation();
+ var card = e.currentTarget;
+
+ // if card is new, add it, otherwise remove it
+ var ids = $.map(self.selected2, function(el) { return $(el).data("id");});
+ if (ids.indexOf($(card).data('id')) >= 0) {
+ self.deselectCard2(card);
+ } else {
+ self.selectCard2(card);
+ }
+
+ if (self.selected2.length === 4) {
+ self.silentSubmission2();
+ }
+ });
+ },
+ setCardListeners3: function() {
+ var self = this;
+
+ // what happens when a card is clicked:
+ this.$board3.on('click', '.card', function(e) {
+ e.stopImmediatePropagation();
+ var card = e.currentTarget;
+
+ // if card is new, add it, otherwise remove it
+ var ids = $.map(self.selected3, function(el) { return $(el).data("id");});
+ if (ids.indexOf($(card).data('id')) >= 0) {
+ self.deselectCard3(card);
+ } else {
+ self.selectCard3(card);
+ }
+
+ if (self.selected3.length === 4) {
+ self.silentSubmission3();
+ }
+ });
+ },
+ setCardListeners4: function() {
+ var self = this;
+
+ // what happens when a card is clicked:
+ this.$board4.on('click', '.card', function(e) {
+ e.stopImmediatePropagation();
+ var card = e.currentTarget;
+
+ // if card is new, add it, otherwise remove it
+ var ids = $.map(self.selected4, function(el) { return $(el).data("id");});
+ if (ids.indexOf($(card).data('id')) >= 0) {
+ self.deselectCard4(card);
+ } else {
+ self.selectCard4(card);
+ }
+
+ if (self.selected4.length === 5) {
+ self.silentSubmission4();
+ }
+ });
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ setPageListeners: function() {
+ var self = this;
+
+ // if the user clicks on the page outside the game board, clear selected
+ $(document).on('click', function() {
+ self.clearSelections.call(self);
+ });
+ },
+
+ setPageListeners1: function() {
+ var self = this;
+
+ // if the user clicks on the page outside the game board, clear selected
+ $(document).on('click', function() {
+ self.clearSelections1.call(self);
+ });
+ },
+
+ setPageListeners2: function() {
+ var self = this;
+
+ // if the user clicks on the page outside the game board, clear selected
+ $(document).on('click', function() {
+ self.clearSelections2.call(self);
+ });
+ },
+
+ setPageListeners3: function() {
+ var self = this;
+
+ // if the user clicks on the page outside the game board, clear selected
+ $(document).on('click', function() {
+ self.clearSelections3.call(self);
+ });
+ },
+
+ setPageListeners4: function() {
+ var self = this;
+
+ // if the user clicks on the page outside the game board, clear selected
+ $(document).on('click', function() {
+ self.clearSelections4.call(self);
+ });
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+ selectCard: function(card) {
+ $(card).addClass('selected');
+ this.selected.push(card);
+
+ if (this.selected.length > 3) {
+ this.clearSelections.call(this);
+ }
+
+ },
+
+ selectCard1: function(card) {
+ $(card).addClass('selected');
+ this.selected1.push(card);
+
+ if (this.selected1.length > 3) {
+ this.clearSelections1.call(this);
+ }
+
+ },
+
+ selectCard2: function(card) {
+ $(card).addClass('selected');
+ this.selected2.push(card);
+
+ if (this.selected2.length > 4) {
+ this.clearSelections2.call(this);
+ }
+
+ },
+
+ selectCard3: function(card) {
+ $(card).addClass('selected');
+ this.selected3.push(card);
+
+ if (this.selected3.length > 4) {
+ this.clearSelections3.call(this);
+ }
+
+ },
+
+ selectCard4: function(card) {
+ $(card).addClass('selected');
+ this.selected4.push(card);
+
+ if (this.selected4.length > 5) {
+ this.clearSelections4.call(this);
+ }
+
+ },
+
+
+
+
+
+
+
+
+
+
+
+ deselectCard: function(card) {
+ var self = this;
+ var index = self.selected.indexOf(card);
+ if (index > -1) {
+ self.selected.splice(index, 1);
+ }
+ $(card).removeClass('selected');
+ },
+ deselectCard1: function(card) {
+ var self = this;
+ var index = self.selected1.indexOf(card);
+ if (index > -1) {
+ self.selected1.splice(index, 1);
+ }
+ $(card).removeClass('selected');
+ },
+ deselectCard2: function(card) {
+ var self = this;
+ var index = self.selected2.indexOf(card);
+ if (index > -1) {
+ self.selected2.splice(index, 1);
+ }
+ $(card).removeClass('selected');
+ },
+ deselectCard3: function(card) {
+ var self = this;
+ var index = self.selected3.indexOf(card);
+ if (index > -1) {
+ self.selected3.splice(index, 1);
+ }
+ $(card).removeClass('selected');
+ },
+ deselectCard4: function(card) {
+ var self = this;
+ var index = self.selected4.indexOf(card);
+ if (index > -1) {
+ self.selected4.splice(index, 1);
+ }
+ $(card).removeClass('selected');
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+
+ clearSelections: function() {
+ $.each(this.selected, function(index, card) {
+ $(card).removeClass('selected');
+ });
+ this.selected = [];
+ },
+ clearSelections1: function() {
+ $.each(this.selected1, function(index, card) {
+ $(card).removeClass('selected');
+ });
+ this.selected1 = [];
+ },
+ clearSelections2: function() {
+ $.each(this.selected2, function(index, card) {
+ $(card).removeClass('selected');
+ });
+ this.selected2 = [];
+ },
+ clearSelections3: function() {
+ $.each(this.selected3, function(index, card) {
+ $(card).removeClass('selected');
+ });
+ this.selected3 = [];
+ },
+ clearSelections4: function() {
+ $.each(this.selected4, function(index, card) {
+ $(card).removeClass('selected');
+ });
+ this.selected4 = [];
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ validateSet: function() {
+ var self = this;
+
+ var colors = $.map(self.selected, function(el) { return $(el).data("color");});
+ var shapes = $.map(self.selected, function(el) { return $(el).data("shape"); });
+ var fills= $.map(self.selected, function(el) { return $(el).data("fill"); });
+ var numbers = $.map(self.selected, function(el) { return $(el).data("number"); });
+
+
+ return (self.isSet(colors) && self.isSet(shapes) && self.isSet(fills) && self.isSet(numbers));
+ },
+
+ validateSet35: function() {
+ var self = this;
+
+ var colors = $.map(self.selected, function(el) { return $(el).data("color");});
+ var shapes = $.map(self.selected, function(el) { return $(el).data("shape"); });
+ var fills= $.map(self.selected, function(el) { return $(el).data("fill"); });
+ var borders= $.map(self.selected, function(el) { return $(el).data("border"); });
+ var numbers = $.map(self.selected, function(el) { return $(el).data("number"); });
+
+
+ return (self.isSet(colors) && self.isSet(shapes) && self.isSet(fills) && self.isSet(borders) && self.isSet(numbers));
+ },
+
+ validateSet44: function() {
+ var self = this;
+
+ var colors = $.map(self.selected, function(el) { return $(el).data("color");});
+ var shapes = $.map(self.selected, function(el) { return $(el).data("shape"); });
+ var fills= $.map(self.selected, function(el) { return $(el).data("fill"); });
+ var numbers = $.map(self.selected, function(el) { return $(el).data("number"); });
+
+
+ return (self.isSet4(colors) && self.isSet4(shapes) && self.isSet4(fills) && self.isSet4(numbers));
+ },
+
+ validateSet45: function() {
+ var self = this;
+
+ var colors = $.map(self.selected, function(el) { return $(el).data("color");});
+ var shapes = $.map(self.selected, function(el) { return $(el).data("shape"); });
+ var fills= $.map(self.selected, function(el) { return $(el).data("fill"); });
+ var borders= $.map(self.selected, function(el) { return $(el).data("border"); });
+ var numbers = $.map(self.selected, function(el) { return $(el).data("number"); });
+
+
+ return (self.isSet4(colors) && self.isSet4(shapes) && self.isSet4(borders) && self.isSet4(fills) && self.isSet4(numbers));
+ },
+
+ validateSet55: function() {
+ var self = this;
+
+ var colors = $.map(self.selected, function(el) { return $(el).data("color");});
+ var shapes = $.map(self.selected, function(el) { return $(el).data("shape"); });
+ var fills= $.map(self.selected, function(el) { return $(el).data("fill"); });
+ var borders= $.map(self.selected, function(el) { return $(el).data("border"); });
+ var numbers = $.map(self.selected, function(el) { return $(el).data("number"); });
+
+
+ return (self.isSet5(colors) && self.isSet5(shapes) && self.isSet5(fills) && self.isSet5(borders) && self.isSet5(numbers));
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ isSet: function(arr) {
+ var unique = [];
+ $.each(arr, function(i, el){
+ if($.inArray(el, unique) === -1) unique.push(el);
+ });
+
+
+ //console.log(unique);
+ return unique.length === 1 || unique.length === 3;
+
+ },
+
+ isSet4: function(arr) {
+ var unique = [];
+ $.each(arr, function(i, el){
+ if($.inArray(el, unique) === -1) unique.push(el);
+ });
+
+
+
+ //console.log(unique);
+ return unique.length === 1 || unique.length === 4;
+
+ },
+
+ isSet5: function(arr) {
+ var unique = [];
+ $.each(arr, function(i, el){
+ if($.inArray(el, unique) === -1) unique.push(el);
+ });
+
+
+ //console.log(unique);
+ return unique.length === 1 || unique.length === 5;
+
+ },
+
+
+
+
+
+
+
+
+
+
+
+ silentSubmission: function() {
+ var valid = this.validateSet();
+ if (valid) {
+ this.submitSet();
+ }
+ },
+ silentSubmission1: function() {
+ var valid = this.validateSet35();
+ if (valid) {
+ this.submitSet1();
+ }
+ },
+ silentSubmission2: function() {
+ var valid = this.validateSet44();
+ if (valid) {
+ this.submitSet2();
+ }
+ },
+ silentSubmission3: function() {
+ var valid = this.validateSet45();
+ if (valid) {
+ this.submitSet3();
+ }
+ },
+ silentSubmission4: function() {
+ var valid = this.validateSet55();
+ if (valid) {
+ this.submitSet4();
+ }
+ },
+
+
+
+
+
+
+
+
+ submitSet: function() {
+ var self = this;
+ var ids = $.map(self.selected, function(el) { return $(el).data("id");});
+
+ // ajax request to get initial set of cards
+ var newCardRequest = $.ajax({
+ url: 'set.php?action=submit',
+ type: 'GET',
+ dataType: 'json',
+ success: function(data) {
+ self.clearCards(ids);
+ // to do - implement game complete check on server
+ if (!data.gameComplete) {
+ self.updateCards(data);
+ self.existingSet();
+ self.increaseScore();
+ } else {
+ self.gameWon();
+ }
+ },
+ error: function() {
+ console.log(arguments);
+ }
+ });
+
+ this.clearSelections();
+ },
+
+ submitSet1: function() {
+ var self = this;
+ var ids = $.map(self.selected1, function(el) { return $(el).data("id");});
+
+ // ajax request to get initial set of cards
+ var newCardRequest = $.ajax({
+ url: 'set.php?action=submit',
+ type: 'GET',
+ dataType: 'json',
+ success: function(data) {
+ self.clearCards1(ids);
+ // to do - implement game complete check on server
+ if (!data.gameComplete) {
+ self.updateCards1(data);
+ self.existingSet1();
+ self.increaseScore1();
+ } else {
+ self.gameWon();
+ }
+ },
+ error: function() {
+ console.log(arguments);
+ }
+ });
+
+ this.clearSelections1();
+ },
+
+
+ submitSet2: function() {
+ var self = this;
+ var ids = $.map(self.selected2, function(el) { return $(el).data("id");});
+
+ // ajax request to get initial set of cards
+ var newCardRequest = $.ajax({
+ url: 'set.php?action=submit',
+ type: 'GET',
+ dataType: 'json',
+ success: function(data) {
+ self.clearCards2(ids);
+ // to do - implement game complete check on server
+ if (!data.gameComplete) {
+ self.updateCards2(data);
+ self.existingSet2();
+ self.increaseScore2();
+ } else {
+ self.gameWon();
+ }
+ },
+ error: function() {
+ console.log(arguments);
+ }
+ });
+
+ this.clearSelections2();
+ },
+
+
+ submitSet3: function() {
+ var self = this;
+ var ids = $.map(self.selected3, function(el) { return $(el).data("id");});
+
+ // ajax request to get initial set of cards
+ var newCardRequest = $.ajax({
+ url: 'set.php?action=submit',
+ type: 'GET',
+ dataType: 'json',
+ success: function(data) {
+ self.clearCards3(ids);
+ // to do - implement game complete check on server
+ if (!data.gameComplete) {
+ self.updateCards3(data);
+ self.existingSet3();
+ self.increaseScore3();
+ } else {
+ self.gameWon();
+ }
+ },
+ error: function() {
+ console.log(arguments);
+ }
+ });
+
+ this.clearSelections3();
+ },
+
+
+
+ submitSet4: function() {
+ var self = this;
+ var ids = $.map(self.selected4, function(el) { return $(el).data("id");});
+
+ // ajax request to get initial set of cards
+ var newCardRequest = $.ajax({
+ url: 'set.php?action=submit',
+ type: 'GET',
+ dataType: 'json',
+ success: function(data) {
+ self.clearCards4(ids);
+ // to do - implement game complete check on server
+ if (!data.gameComplete) {
+ self.updateCards4(data);
+ self.existingSet4();
+ self.increaseScore4();
+ } else {
+ self.gameWon();
+ }
+ },
+ error: function() {
+ console.log(arguments);
+ }
+ });
+
+ this.clearSelections4();
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+
+ clearCards: function(ids) {
+ // remove submitted cards game's card array and clear the board
+ var self = this;
+ this.selected = [];
+ this.$board.empty();
+ var cardIds = $.map(self.cards, function(card) { return card.id; });
+ $.each(ids, function(idx, id) {
+ var location = cardIds.indexOf(id);
+ if (location > -1) {
+ cardIds.splice(location, 1);
+ self.cards.splice(location, 1);
+ }
+ });
+ },
+
+ clearCards1: function(ids) {
+ // remove submitted cards game's card array and clear the board
+ var self = this;
+ this.selected1 = [];
+ this.$board1.empty();
+ var cardIds = $.map(self.cards1, function(card) { return card.id; });
+ $.each(ids, function(idx, id) {
+ var location = cardIds.indexOf(id);
+ if (location > -1) {
+ cardIds.splice(location, 1);
+ self.cards1.splice(location, 1);
+ }
+ });
+ },
+ clearCards2: function(ids) {
+ // remove submitted cards game's card array and clear the board
+ var self = this;
+ this.selected2 = [];
+ this.$board2.empty();
+ var cardIds = $.map(self.cards2, function(card) { return card.id; });
+ $.each(ids, function(idx, id) {
+ var location = cardIds.indexOf(id);
+ if (location > -1) {
+ cardIds.splice(location, 1);
+ self.cards2.splice(location, 1);
+ }
+ });
+ },
+ clearCards3: function(ids) {
+ // remove submitted cards game's card array and clear the board
+ var self = this;
+ this.selected3 = [];
+ this.$board3.empty();
+ var cardIds = $.map(self.cards3, function(card) { return card.id; });
+ $.each(ids, function(idx, id) {
+ var location = cardIds.indexOf(id);
+ if (location > -1) {
+ cardIds.splice(location, 1);
+ self.cards3.splice(location, 1);
+ }
+ });
+ },
+ clearCards4: function(ids) {
+ // remove submitted cards game's card array and clear the board
+ var self = this;
+ this.selected4 = [];
+ this.$board4.empty();
+ var cardIds = $.map(self.cards4, function(card) { return card.id; });
+ $.each(ids, function(idx, id) {
+ var location = cardIds.indexOf(id);
+ if (location > -1) {
+ cardIds.splice(location, 1);
+ self.cards4.splice(location, 1);
+ }
+ });
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ updateCards: function(newCards) {
+ this.cards = this.cards.concat(newCards);
+ this.displayCards();
+ },
+
+ updateCards1: function(newCards) {
+ this.cards1 = this.cards1.concat(newCards);
+ this.displayCards1();
+ },
+
+ updateCards2: function(newCards) {
+ this.cards2 = this.cards2.concat(newCards);
+ this.displayCards2();
+ },
+
+ updateCards3: function(newCards) {
+ this.cards3 = this.cards3.concat(newCards);
+ this.displayCards3();
+ },
+
+ updateCards4: function(newCards) {
+ this.cards4 = this.cards4.concat(newCards);
+ this.displayCards4();
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+
+ increaseScore: function() {
+ this.$score.html(++this.score);
+ },
+ increaseScore1: function() {
+ this.$score1.html(++this.score1);
+ },
+
+ increaseScore2: function() {
+ this.$score2.html(++this.score2);
+ },
+
+ increaseScore3: function() {
+ this.$score3.html(++this.score3);
+ },
+
+ increaseScore4: function() {
+ this.$score4.html(++this.score4);
+ },
+
+
+
+
+ startRound: function() {
+ // todo
+ // reset timer to 30 seconds
+ },
+
+ gameWon: function() {
+ alert("you won!");
+ },
+
+ gameLost: function() {
+ alert("you lost :(");
+ }
+
+
+
+};
+
+
+
+Game.deal();
+
+
+
+var canvases = document.getElementsByClassName(' red solid');
+
+console.log(canvases);
+for (let canvas of canvases) {
+ console.log(canvas);
+
+}
-Game.deal();
/*
var canvases = $('.red');
console.log(canvases);