', {
class: "card"
}).appendTo(self.$boardHS);
@@ -440,6 +466,46 @@ var Game = {
},
+ displayCardsHS0: function() {
+ var self = this;
+ if (self.cardsHS0.length == 0) {
+ return false;
+ }
+
+
+ $.each(self.cardsHS0, function(index, card){
+ var cardNode = $('
', {
+ class: "card"
+ }).appendTo(self.$boardHS0);
+
+
+ cardNode.data({
+ 'id': card.id,
+ 'shape': card.shape,
+ 'fill': card.fill,
+ 'color': card.color,
+ 'number': card.number
+ });
+
+ var shapeNode = $("
");
+ shapeNode.addClass('shape ' + card.color + ' ' + card.shape + ' ' + card.fill);
+
+ for (var i = 0; i < card.number; i++) {
+ cardNode.append(shapeNode.clone());
+ }
+ self.$boardHS0.append(cardNode);
+
+ // display 4 cards per row
+ if ((index+1) % 4 === 0) {
+ self.$boardHS0.append($('
'));
+ }
+
+ });
+
+ },
+
+
+
@@ -962,6 +1028,57 @@ var Game = {
});
},
+ setCardListenersHS: function() {
+ var self = this;
+
+ // what happens when a card is clicked:
+ this.$boardHS.on('click', '.card', function(e) {
+ e.stopImmediatePropagation();
+ var card = e.currentTarget;
+
+ // if card is new, add it, otherwise remove it
+ var ids = $.map(self.selectedHS, function(el) { return $(el).data("id");});
+ if (ids.indexOf($(card).data('id')) >= 0) {
+ self.deselectCardHS(card);
+ } else {
+ self.selectCardHS(card);
+ }
+
+ if (self.selectedHS.length === 4) {
+ self.silentSubmissionHS();
+ }
+ });
+ },
+
+ setCardListenersHS0: function() {
+ var self = this;
+
+ // what happens when a card is clicked:
+ this.$boardHS0.on('click', '.card', function(e) {
+ e.stopImmediatePropagation();
+ var card = e.currentTarget;
+
+ // if card is new, add it, otherwise remove it
+ var ids = $.map(self.selectedHS0, function(el) { return $(el).data("id");});
+ if (ids.indexOf($(card).data('id')) >= 0) {
+ self.deselectCardHS0(card);
+ } else {
+ self.selectCardHS0(card);
+ }
+
+ if (self.selectedHS0.length === 4) {
+ self.silentSubmissionHS0();
+ }
+ });
+ },
+
+
+
+
+
+
+
+
@@ -1030,6 +1147,31 @@ var Game = {
},
+ setPageListenersHS: function() {
+ var self = this;
+
+ // if the user clicks on the page outside the game board, clear selected
+ $(document).on('click', function() {
+ self.clearSelectionsHS.call(self);
+ });
+ },
+
+ setPageListenersHS0: function() {
+ var self = this;
+
+ // if the user clicks on the page outside the game board, clear selected
+ $(document).on('click', function() {
+ self.clearSelectionsHS0.call(self);
+ });
+ },
+
+
+
+
+
+
+
+
@@ -1097,6 +1239,26 @@ var Game = {
},
+ selectCardHS: function(card) {
+
+ if (this.selectedHS.length < 4) {
+ $(card).addClass('selected');
+ this.selectedHS.push(card);
+ }
+
+ },
+
+ selectCardHS0: function(card) {
+
+ if (this.selectedHS0.length < 4) {
+ $(card).addClass('selected');
+ this.selectedHS0.push(card);
+ }
+
+ },
+
+
+
@@ -1154,6 +1316,27 @@ var Game = {
}
$(card).removeClass('selected');
},
+ deselectCardHS: function(card) {
+ var self = this;
+ var index = self.selectedHS.indexOf(card);
+ if (index > -1) {
+ self.selectedHS.splice(index, 1);
+ }
+ $(card).removeClass('selected');
+ },
+
+ deselectCardHS0: function(card) {
+ var self = this;
+ var index = self.selectedHS0.indexOf(card);
+ if (index > -1) {
+ self.selectedHS0.splice(index, 1);
+ }
+ $(card).removeClass('selected');
+ },
+
+
+
+
@@ -1204,7 +1387,19 @@ var Game = {
},
+ clearSelectionsHS: function() {
+ $.each(this.selectedHS, function(index, card) {
+ $(card).removeClass('selected');
+ });
+ this.selectedHS = [];
+ },
+ clearSelectionsHS0: function() {
+ $.each(this.selectedHS0, function(index, card) {
+ $(card).removeClass('selected');
+ });
+ this.selectedHS0 = [];
+ },
@@ -1214,118 +1409,1000 @@ var Game = {
- validateSet0: function() {
- var self = this;
-
- var colors = $.map(self.selected0, function(el) { return $(el).data("color");});
- var shapes = $.map(self.selected0, function(el) { return $(el).data("shape"); });
- var numbers= $.map(self.selected0, function(el) { return $(el).data("number"); });
- return (self.isSet(colors) && self.isSet(shapes) && self.isSet(numbers));
- },
- 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));
- },
+ validateHyperSet0: function() {
+ var carteAB = [];
+ var carteCD = [];
+ var carteAC = [];
+ var carteBD = [];
+ var carteAD = [];
+ var carteBC = [];
- validateSet35: function() {
- var self = this;
+ carteAB.splice(0,1,this.selectedHS0[0]);
+ carteAB.splice(1,1,this.selectedHS0[1]);
+ carteCD.splice(0,1,this.selectedHS0[2]);
+ carteCD.splice(1,1,this.selectedHS0[3]);
- var colors = $.map(self.selected1, function(el) { return $(el).data("color");});
- var shapes = $.map(self.selected1, function(el) { return $(el).data("shape"); });
- var fills= $.map(self.selected1, function(el) { return $(el).data("fill"); });
- var borders= $.map(self.selected1, function(el) { return $(el).data("border"); });
- var numbers = $.map(self.selected1, function(el) { return $(el).data("number"); });
+ carteAC.splice(0,1,this.selectedHS0[0]);
+ carteAC.splice(1,1,this.selectedHS0[2]);
+ carteBD.splice(0,1,this.selectedHS0[1]);
+ carteBD.splice(1,1,this.selectedHS0[3]);
+ carteAD.splice(0,1,this.selectedHS0[0]);
+ carteAD.splice(1,1,this.selectedHS0[3]);
+ carteBC.splice(0,1,this.selectedHS0[1]);
+ carteBC.splice(1,1,this.selectedHS0[2]);
- return (self.isSet(colors) && self.isSet(shapes) && self.isSet(fills) && self.isSet(borders) && self.isSet(numbers));
- },
- validateSet44: function() {
- var self = this;
+ // modalité de toutes les 4 cartes
+ var colors1= $.map(this.selectedHS0, function(card) { return card.color;});
+ var shapes1 = $.map(this.selectedHS0, function(card) { return card.shape; });
+ var numbers1 = $.map(this.selectedHS0, function(card) { return card.number });
- var colors = $.map(self.selected2, function(el) { return $(el).data("color");});
- var shapes = $.map(self.selected2, function(el) { return $(el).data("shape"); });
- var fills= $.map(self.selected2, function(el) { return $(el).data("fill"); });
- var numbers = $.map(self.selected2, function(el) { return $(el).data("number"); });
+ // modalité des combinaison de carte (ab ac ad ...) pour verifier si forme un set
+ var colors2= $.map(carteAB, function(card) { return card.color;});
+ var shapes2 = $.map(carteAB, function(card) { return card.shape; });
+ var numbers2 = $.map(carteAB, function(card) { return card.number });
- return (self.isSet4(colors) && self.isSet4(shapes) && self.isSet4(fills) && self.isSet4(numbers));
- },
+ var colors3= $.map(carteCD, function(card) { return card.color;});
+ var shapes3 = $.map(carteCD, function(card) { return card.shape; });
+ var numbers3 = $.map(carteCD, function(card) { return card.number });
- validateSet45: function() {
- var self = this;
+ var colors4= $.map(carteAC, function(card) { return card.color;});
+ var shapes4 = $.map(carteAC, function(card) { return card.shape; });
+ var numbers4 = $.map(carteAC, function(card) { return card.number });
- var colors = $.map(self.selected3, function(el) { return $(el).data("color");});
- var shapes = $.map(self.selected3, function(el) { return $(el).data("shape"); });
- var fills= $.map(self.selected3, function(el) { return $(el).data("fill"); });
- var borders= $.map(self.selected3, function(el) { return $(el).data("border"); });
- var numbers = $.map(self.selected3, function(el) { return $(el).data("number"); });
+ var colors5= $.map(carteBD, function(card) { return card.color;});
+ var shapes5 = $.map(carteBD, function(card) { return card.shape; });
+ var numbers5 = $.map(carteBD, function(card) { return card.number });
+ var colors6= $.map(carteAD, function(card) { return card.color;});
+ var shapes6 = $.map(carteAD, function(card) { return card.shape; });
+ var numbers6 = $.map(carteAD, function(card) { return card.number });
- return (self.isSet4(colors) && self.isSet4(shapes) && self.isSet4(borders) && self.isSet4(fills) && self.isSet4(numbers));
- },
+ var colors7= $.map(carteBC, function(card) { return card.color;});
+ var shapes7 = $.map(carteBC, function(card) { return card.shape; });
+ var numbers7 = $.map(carteBC, function(card) { return card.number });
- validateSet55: function() {
- var self = this;
- var colors = $.map(self.selected4, function(el) { return $(el).data("color");});
- var shapes = $.map(self.selected4, function(el) { return $(el).data("shape"); });
- var fills= $.map(self.selected4, function(el) { return $(el).data("fill"); });
- var borders= $.map(self.selected4, function(el) { return $(el).data("border"); });
- var numbers = $.map(self.selected4, function(el) { return $(el).data("number"); });
+ if(colors1[0] === colors1 [1]){
+ colors2.push(colors1[0]);
+ colors3.push(colors1[0]);
+ }
+ else{
+ if(colors1[0] === 'red' && colors1[1] === 'green'){
+ colors3.push('purple');
+ colors2.push('purple');
+ }
+ if(colors1[0] === 'red' && colors1[1] === 'purple'){
+ colors3.push('green');
+ colors2.push('green');
+ }
- return (self.isSet5(colors) && self.isSet5(shapes) && self.isSet5(fills) && self.isSet5(borders) && self.isSet5(numbers));
- },
+ if(colors1[0] === 'green' && colors1[1] === 'purple'){
+ colors3.push('red');
+ colors2.push('red');
+ }
+ if(colors1[0] === 'green' && colors1[1] === 'red'){
+ colors3.push('purple');
+ colors2.push('purple');
+ }
+ if(colors1[0] === 'purple' && colors1[1] === 'red'){
+ colors3.push('green');
+ colors2.push('green');
+ }
+ if(colors1[0] === 'purple' && colors1[1] === 'green'){
+ colors3.push('red');
+ colors2.push('red');
+ }
+ }
+ if(shapes1[0] === shapes1 [1]){
+ shapes3.push(shapes1[0]);
+ shapes2.push(shapes1[0]);
+ }
+ else{
+ if(shapes1[0] === 'oval' && shapes1[1] === 'diamond'){
+ shapes3.push('wave');
+ shapes2.push('wave');
+ }
+ if(shapes1[0] === 'oval' && shapes1[1] === 'wave'){
+ shapes3.push('diamond');
+ shapes2.push('diamond');
+ }
+ if(shapes1[0] === 'diamond' && shapes1[1] === 'oval'){
+ shapes3.push('wave');
+ shapes2.push('wave');
+ }
+ if(shapes1[0] === 'diamond' && shapes1[1] === 'wave'){
+ shapes3.push('oval');
+ shapes2.push('oval');
+ }
+ if(shapes1[0] === 'wave' && shapes1[1] === 'diamond'){
+ shapes3.push('oval');
+ shapes2.push('oval');
+ }
+ if(shapes1[0] === 'wave' && shapes1[1] === 'oval'){
+ shapes3.push('diamond');
+ shapes2.push('diamond');
+ }
+ }
+ if(numbers1[0] === numbers1[1]){
+ numbers3.push(numbers1[0]);
+ numbers2.push(numbers1[0]);
+ }
+ else{
+ if(numbers1[0] === 1 && numbers1[1] === 2){
+ numbers3.push(3);
+ numbers2.push(3);
+ }
+ if(numbers1[0] === 1 && numbers1[1] === 3){
+ numbers3.push(2);
+ numbers2.push(2);
+ }
+ if(numbers1[0] === 2 && numbers1[1] === 1){
+ numbers3.push(3);
+ numbers2.push(3);
+ }
+ if(numbers1[0] === 2 && numbers1[1] === 3){
+ numbers3.push(1);
+ numbers2.push(1);
+ }
+ if(numbers1[0] === 3 && numbers1[1] === 1){
+ numbers3.push(2);
+ numbers2.push(2);
+ }
+ if(numbers1[0] === 3 && numbers1[1] === 2){
+ numbers3.push(1);
+ numbers2.push(1);
+ }
+ }
+ if(colors1[0] === colors1 [2]){
+ colors4.push(colors1[0]);
+ colors5.push(colors1[0]);
+ }
+ else{
+ if(colors1[0] === 'red' && colors1[2] === 'green'){
+ colors4.push('purple');
+ colors5.push('purple');
+ }
+ if(colors1[0] === 'red' && colors1[2] === 'purple'){
+ colors4.push('green');
+ colors5.push('green');
+ }
+ if(colors1[0] === 'green' && colors1[2] === 'purple'){
+ colors5.push('red');
+ colors4.push('red');
+ }
+ if(colors1[0] === 'green' && colors1[2] === 'red'){
+ colors4.push('purple');
+ colors5.push('purple');
+ }
- isSet: function(arr) {
- var unique = [];
- $.each(arr, function(i, el){
- if($.inArray(el, unique) === -1) unique.push(el);
- });
- return unique.length === 1 || unique.length === 3;
+ if(colors1[0] === 'purple' && colors1[2] === 'red'){
+ colors4.push('green');
+ colors5.push('green');
+ }
+ if(colors1[0]=== 'purple' && colors1[2] === 'green'){
+ colors4.push('red');
+ colors5.push('red');
+ }
+ }
+ if(shapes1[0] === shapes1 [2]){
+ shapes4.push(shapes1[0]);
+ shapes5.push(shapes1[0]);
+ }
+ else{
+ if(shapes1[0] === 'oval' && shapes1[2] === 'diamond'){
+ shapes4.push('wave');
+ shapes5.push('wave');
+ }
- },
+ if(shapes1[0] === 'oval' && shapes1[2] === 'wave'){
+ shapes4.push('diamond');
+ shapes5.push('diamond');
+ }
- isSet4: function(arr) {
- var unique = [];
- $.each(arr, function(i, el){
- if($.inArray(el, unique) === -1) unique.push(el);
- });
+ if(shapes1[0] === 'diamond' && shapes1[2] === 'oval'){
+ shapes4.push('wave');
+ shapes5.push('wave');
+ }
+ if(shapes1[0] === 'diamond' && shapes1[2] === 'wave'){
+ shapes4.push('oval');
+ shapes5.push('oval');
+ }
+ if(shapes1[0] === 'wave' && shapes1[2] === 'diamond'){
+ shapes4.push('oval');
+ shapes5.push('oval');
+ }
+ if(shapes1[0] === 'wave' && shapes1[2] === 'oval'){
+ shapes4.push('diamond');
+ shapes5.push('diamond');
+ }
+ }
+ if(numbers1[0] === numbers1[1]){
+ numbers4.push(numbers1[0]);
+ numbers5.push(numbers1[0]);
+ }
+ else{
+ if(numbers1[0] === 1 && numbers1[2] === 2){
+ numbers4.push(3);
+ numbers5.push(3);
+ }
- //console.log(unique);
- return unique.length === 1 || unique.length === 4;
+ if(numbers1[0] === 1 && numbers1[2] === 3){
+ numbers4.push(2);
+ numbers5.push(2);
+ }
- },
+ if(numbers1[0] === 2 && numbers1[2] === 1){
+ numbers4.push(3);
+ numbers5.push(3);
+ }
+ if(numbers1[0] === 2 && numbers1[2] === 3){
+ numbers4.push(1);
+ numbers5.push(1);
+ }
- isSet5: function(arr) {
- var unique = [];
- $.each(arr, function(i, el){
+ if(numbers1[0] === 3 && numbers1[2] === 1){
+ numbers4.push(2);
+ numbers5.push(2);
+ }
+ if(numbers1[0] === 3 && numbers1[2] === 2){
+ numbers4.push(1);
+ numbers5.push(1);
+ }
+ }
+ if(colors1[0] === colors1 [3]){
+ colors6.push(colors1[0]);
+ colors7.push(colors1[0]);
+ }
+ else{
+ if(colors1[0] === 'red' && colors1[3] === 'green'){
+ colors6.push('purple');
+ colors7.push('purple');
+ }
+
+ if(colors1[0] === 'red' && colors1[3] === 'purple'){
+ colors6.push('green');
+ colors7.push('green');
+ }
+
+ if(colors1[0] === 'green' && colors1[3] === 'purple'){
+ colors6.push('red');
+ colors7.push('red');
+ }
+ if(colors1[0] === 'green' && colors1[3] === 'red'){
+ colors6.push('purple');
+ colors7.push('purple');
+ }
+
+ if(colors1[0] === 'purple' && colors1[3] === 'red'){
+ colors6.push('green');
+ colors7.push('green');
+ }
+ if(colors1[0]=== 'purple' && colors1[3] === 'green'){
+ colors6.push('red');
+ colors7.push('red');
+ }
+ }
+ if(shapes1[0] === shapes1 [3]){
+ shapes6.push(shapes1[0]);
+ shapes7.push(shapes1[0]);
+ }
+ else{
+ if(shapes1[0] === 'oval' && shapes1[3] === 'diamond'){
+ shapes6.push('wave');
+ shapes7.push('wave');
+ }
+
+ if(shapes1[0] === 'oval' && shapes1[3] === 'wave'){
+ shapes6.push('diamond');
+ shapes7.push('diamond');
+ }
+
+ if(shapes1[0] === 'diamond' && shapes1[3] === 'oval'){
+ shapes6.push('wave');
+ shapes7.push('wave');
+ }
+ if(shapes1[0] === 'diamond' && shapes1[3] === 'wave'){
+ shapes6.push('oval');
+ shapes7.push('oval');
+ }
+
+ if(shapes1[0] === 'wave' && shapes1[3] === 'diamond'){
+ shapes6.push('oval');
+ shapes7.push('oval');
+ }
+ if(shapes1[0] === 'wave' && shapes1[3] === 'oval'){
+ shapes6.push('diamond');
+ shapes7.push('diamond');
+ }
+
+ }
+ if(numbers1[0] === numbers1[3]){
+ numbers6.push(numbers1[0]);
+ numbers7.push(numbers1[0]);
+ }
+ else{
+ if(numbers1[0] === 1 && numbers1[3] === 2){
+ numbers6.push(3);
+ numbers7.push(3);
+ }
+
+ if(numbers1[0] === 1 && numbers1[3] === 3){
+ numbers6.push(2);
+ numbers7.push(2);
+ }
+
+ if(numbers1[0] === 2 && numbers1[3] === 1){
+ numbers6.push(3);
+ numbers7.push(3);
+ }
+ if(numbers1[0] === 2 && numbers1[3] === 3){
+ numbers6.push(1);
+ numbers7.push(1);
+ }
+
+ if(numbers1[0] === 3 && numbers1[3] === 1){
+ numbers6.push(2);
+ numbers7.push(2);
+ }
+ if(numbers1[0] === 3 && numbers1[3] === 2){
+ numbers6.push(1);
+ numbers7.push(1);
+ }
+ }
+ if(this.isSet(colors2) && this.isSet(shapes2) && this.isSet(numbers2)) {
+ return this.isSet(colors3) && this.isSet(shapes3) && this.isSet(numbers3)
+ }
+ if(this.isSet(colors4) && this.isSet(shapes4) && this.isSet(numbers4)){
+ return this.isSet(colors5)&& this.isSet(shapes5)&& this.isSet(numbers5)
+ }
+ if(this.isSet(colors6) && this.isSet(shapes6) && this.isSet(fills6) && this.isSet(numbers6)) {
+ return this.isSet(colors7) && this.isSet(shapes7) && this.isSet(numbers7)
+ }
+
+ },
+
+ validateHyperSet: function() {
+ var carteAB = [];
+ var carteCD = [];
+ var carteAC = [];
+ var carteBD = [];
+ var carteAD = [];
+ var carteBC = [];
+
+ carteAB.splice(0,1,this.selectedHS[0]);
+ carteAB.splice(1,1,this.selectedHS[1]);
+ carteCD.splice(0,1,this.selectedHS[2]);
+ carteCD.splice(1,1,this.selectedHS[3]);
+
+ carteAC.splice(0,1,this.selectedHS[0]);
+ carteAC.splice(1,1,this.selectedHS[2]);
+ carteBD.splice(0,1,this.selectedHS[1]);
+ carteBD.splice(1,1,this.selectedHS[3]);
+
+ carteAD.splice(0,1,this.selectedHS[0]);
+ carteAD.splice(1,1,this.selectedHS[3]);
+ carteBC.splice(0,1,this.selectedHS[1]);
+ carteBC.splice(1,1,this.selectedHS[2]);
+
+
+ // modalité de toutes les 4 cartes
+ var colors1= $.map(this.selectedHS, function(card) { return card.color;});
+ var shapes1 = $.map(this.selectedHS, function(card) { return card.shape; });
+ var fills1= $.map(this.selectedHS, function(card) { return card.fill });
+ var numbers1 = $.map(this.selectedHS, function(card) { return card.number });
+
+ // modalité des combinaison de carte (ab ac ad ...) pour verifier si forme un set
+
+ var colors2= $.map(carteAB, function(card) { return card.color;});
+ var shapes2 = $.map(carteAB, function(card) { return card.shape; });
+ var fills2= $.map(carteAB, function(card) { return card.fill });
+ var numbers2 = $.map(carteAB, function(card) { return card.number });
+
+ var colors3= $.map(carteCD, function(card) { return card.color;});
+ var shapes3 = $.map(carteCD, function(card) { return card.shape; });
+ var fills3= $.map(carteCD, function(card) { return card.fill });
+ var numbers3 = $.map(carteCD, function(card) { return card.number });
+
+
+
+ var colors4= $.map(carteAC, function(card) { return card.color;});
+ var shapes4 = $.map(carteAC, function(card) { return card.shape; });
+ var fills4= $.map(carteAC, function(card) { return card.fill });
+ var numbers4 = $.map(carteAC, function(card) { return card.number });
+
+ var colors5= $.map(carteBD, function(card) { return card.color;});
+ var shapes5 = $.map(carteBD, function(card) { return card.shape; });
+ var fills5= $.map(carteBD, function(card) { return card.fill });
+ var numbers5 = $.map(carteBD, function(card) { return card.number });
+
+
+ var colors6= $.map(carteAD, function(card) { return card.color;});
+ var shapes6 = $.map(carteAD, function(card) { return card.shape; });
+ var fills6= $.map(carteAD, function(card) { return card.fill });
+ var numbers6 = $.map(carteAD, function(card) { return card.number });
+
+ var colors7= $.map(carteBC, function(card) { return card.color;});
+ var shapes7 = $.map(carteBC, function(card) { return card.shape; });
+ var fills7= $.map(carteBC, function(card) { return card.fill });
+ var numbers7 = $.map(carteBC, function(card) { return card.number });
+
+
+ if(colors1[0] === colors1 [1]){
+ colors2.push(colors1[0]);
+ colors3.push(colors1[0]);
+ }
+ else{
+ if(colors1[0] === 'red' && colors1[1] === 'green'){
+ colors3.push('purple');
+ colors2.push('purple');
+ }
+
+ if(colors1[0] === 'red' && colors1[1] === 'purple'){
+ colors3.push('green');
+ colors2.push('green');
+ }
+
+ if(colors1[0] === 'green' && colors1[1] === 'purple'){
+ colors3.push('red');
+ colors2.push('red');
+ }
+ if(colors1[0] === 'green' && colors1[1] === 'red'){
+ colors3.push('purple');
+ colors2.push('purple');
+ }
+
+ if(colors1[0] === 'purple' && colors1[1] === 'red'){
+ colors3.push('green');
+ colors2.push('green');
+ }
+ if(colors1[0] === 'purple' && colors1[1] === 'green'){
+ colors3.push('red');
+ colors2.push('red');
+ }
+
+ }
+ if(shapes1[0] === shapes1 [1]){
+ shapes3.push(shapes1[0]);
+ shapes2.push(shapes1[0]);
+ }
+ else{
+ if(shapes1[0] === 'oval' && shapes1[1] === 'diamond'){
+ shapes3.push('wave');
+ shapes2.push('wave');
+ }
+
+ if(shapes1[0] === 'oval' && shapes1[1] === 'wave'){
+ shapes3.push('diamond');
+ shapes2.push('diamond');
+ }
+
+ if(shapes1[0] === 'diamond' && shapes1[1] === 'oval'){
+ shapes3.push('wave');
+ shapes2.push('wave');
+
+ }
+ if(shapes1[0] === 'diamond' && shapes1[1] === 'wave'){
+ shapes3.push('oval');
+ shapes2.push('oval');
+ }
+
+ if(shapes1[0] === 'wave' && shapes1[1] === 'diamond'){
+ shapes3.push('oval');
+ shapes2.push('oval');
+ }
+ if(shapes1[0] === 'wave' && shapes1[1] === 'oval'){
+ shapes3.push('diamond');
+ shapes2.push('diamond');
+ }
+ }
+ if(fills1[0] === fills1 [1]){
+ fills3.push(fills1[0]);
+ fills2.push(fills1[0]);
+ }
+ else{
+ if(fills1[0] === 'solid' && fills1[1] === 'stripped'){
+ fills3.push('open');
+ fills2.push('open');
+ }
+
+ if(fills1[0] === 'solid' && fills1[1] === 'open'){
+ fills3.push('stripped');
+ fills2.push('stripped');
+ }
+
+ if(fills1[0] === 'stripped' && fills1[1] === 'open'){
+ fills3.push('solid');
+ fills2.push('solid');
+ }
+ if(fills1[0] === 'open' && fills1[1] === 'stripped'){
+ fills3.push('solid');
+ fills2.push('solid');
+ }
+
+ if(fills1[0] === 'stripped' && fills1[1] === 'solid'){
+ fills3.push('open');
+ fills2.push('open');
+ }
+ if(fills1[0] === 'open' && fills1[1] === 'solid'){
+ fills3.push('stripped');
+ fills2.push('stripped');
+ }
+ }
+ if(numbers1[0] === numbers1[1]){
+ numbers3.push(numbers1[0]);
+ numbers2.push(numbers1[0]);
+ }
+ else{
+ if(numbers1[0] === 1 && numbers1[1] === 2){
+ numbers3.push(3);
+ numbers2.push(3);
+ }
+
+ if(numbers1[0] === 1 && numbers1[1] === 3){
+ numbers3.push(2);
+ numbers2.push(2);
+ }
+
+ if(numbers1[0] === 2 && numbers1[1] === 1){
+ numbers3.push(3);
+ numbers2.push(3);
+ }
+ if(numbers1[0] === 2 && numbers1[1] === 3){
+ numbers3.push(1);
+ numbers2.push(1);
+ }
+
+ if(numbers1[0] === 3 && numbers1[1] === 1){
+ numbers3.push(2);
+ numbers2.push(2);
+ }
+ if(numbers1[0] === 3 && numbers1[1] === 2){
+ numbers3.push(1);
+ numbers2.push(1);
+ }
+
+ }
+ if(colors1[0] === colors1 [2]){
+ colors4.push(colors1[0]);
+ colors5.push(colors1[0]);
+ }
+ else{
+ if(colors1[0] === 'red' && colors1[2] === 'green'){
+ colors4.push('purple');
+ colors5.push('purple');
+ }
+
+ if(colors1[0] === 'red' && colors1[2] === 'purple'){
+ colors4.push('green');
+ colors5.push('green');
+ }
+
+ if(colors1[0] === 'green' && colors1[2] === 'purple'){
+ colors5.push('red');
+ colors4.push('red');
+ }
+ if(colors1[0] === 'green' && colors1[2] === 'red'){
+ colors4.push('purple');
+ colors5.push('purple');
+ }
+
+ if(colors1[0] === 'purple' && colors1[2] === 'red'){
+ colors4.push('green');
+ colors5.push('green');
+ }
+ if(colors1[0]=== 'purple' && colors1[2] === 'green'){
+ colors4.push('red');
+ colors5.push('red');
+ }
+ }
+ if(shapes1[0] === shapes1 [2]){
+ shapes4.push(shapes1[0]);
+ shapes5.push(shapes1[0]);
+ }
+ else{
+ if(shapes1[0] === 'oval' && shapes1[2] === 'diamond'){
+ shapes4.push('wave');
+ shapes5.push('wave');
+ }
+
+ if(shapes1[0] === 'oval' && shapes1[2] === 'wave'){
+ shapes4.push('diamond');
+ shapes5.push('diamond');
+ }
+
+ if(shapes1[0] === 'diamond' && shapes1[2] === 'oval'){
+ shapes4.push('wave');
+ shapes5.push('wave');
+ }
+ if(shapes1[0] === 'diamond' && shapes1[2] === 'wave'){
+ shapes4.push('oval');
+ shapes5.push('oval');
+ }
+
+ if(shapes1[0] === 'wave' && shapes1[2] === 'diamond'){
+ shapes4.push('oval');
+ shapes5.push('oval');
+ }
+ if(shapes1[0] === 'wave' && shapes1[2] === 'oval'){
+ shapes4.push('diamond');
+ shapes5.push('diamond');
+ }
+
+ }
+ if(fills1[0] === fills1 [2]){
+ fills5.push(fills1[0]);
+ fills4.push(fills1[0]);
+ }
+ else{
+ if(fills1[0] === 'solid' && fills1[2] === 'stripped'){
+ fills4.push('open');
+ fills5.push('open');
+ }
+
+ if(fills1[0] === 'solid' && fills1[2] === 'open'){
+ fills4.push('stripped');
+ fills5.push('stripped');
+ }
+
+ if(fills1[0] === 'stripped' && fills1[2] === 'open'){
+ fills4.push('solid');
+ fills5.push('solid');
+ }
+ if(fills1[0] === 'open' && fills1[2] === 'stripped'){
+ fills4.push('solid');
+ fills5.push('solid');
+ }
+
+ if(fills1[0] === 'stripped' && fills1[2] === 'solid'){
+ fills4.push('open');
+ fills5.push('open');
+ }
+ if(fills1[0] === 'open' && fills1[2] === 'solid'){
+ fills4.push('stripped');
+ fills5.push('stripped');
+ }
+ }
+ if(numbers1[0] === numbers1[1]){
+ numbers4.push(numbers1[0]);
+ numbers5.push(numbers1[0]);
+ }
+ else{
+ if(numbers1[0] === 1 && numbers1[2] === 2){
+ numbers4.push(3);
+ numbers5.push(3);
+ }
+
+ if(numbers1[0] === 1 && numbers1[2] === 3){
+ numbers4.push(2);
+ numbers5.push(2);
+ }
+
+ if(numbers1[0] === 2 && numbers1[2] === 1){
+ numbers4.push(3);
+ numbers5.push(3);
+ }
+ if(numbers1[0] === 2 && numbers1[2] === 3){
+ numbers4.push(1);
+ numbers5.push(1);
+ }
+
+ if(numbers1[0] === 3 && numbers1[2] === 1){
+ numbers4.push(2);
+ numbers5.push(2);
+ }
+ if(numbers1[0] === 3 && numbers1[2] === 2){
+ numbers4.push(1);
+ numbers5.push(1);
+ }
+ }
+ if(colors1[0] === colors1 [3]){
+ colors6.push(colors1[0]);
+ colors7.push(colors1[0]);
+ }
+ else{
+ if(colors1[0] === 'red' && colors1[3] === 'green'){
+ colors6.push('purple');
+ colors7.push('purple');
+ }
+
+ if(colors1[0] === 'red' && colors1[3] === 'purple'){
+ colors6.push('green');
+ colors7.push('green');
+ }
+
+ if(colors1[0] === 'green' && colors1[3] === 'purple'){
+ colors6.push('red');
+ colors7.push('red');
+ }
+ if(colors1[0] === 'green' && colors1[3] === 'red'){
+ colors6.push('purple');
+ colors7.push('purple');
+ }
+
+ if(colors1[0] === 'purple' && colors1[3] === 'red'){
+ colors6.push('green');
+ colors7.push('green');
+ }
+ if(colors1[0]=== 'purple' && colors1[3] === 'green'){
+ colors6.push('red');
+ colors7.push('red');
+ }
+ }
+ if(shapes1[0] === shapes1 [3]){
+ shapes6.push(shapes1[0]);
+ shapes7.push(shapes1[0]);
+ }
+ else{
+ if(shapes1[0] === 'oval' && shapes1[3] === 'diamond'){
+ shapes6.push('wave');
+ shapes7.push('wave');
+ }
+
+ if(shapes1[0] === 'oval' && shapes1[3] === 'wave'){
+ shapes6.push('diamond');
+ shapes7.push('diamond');
+ }
+
+ if(shapes1[0] === 'diamond' && shapes1[3] === 'oval'){
+ shapes6.push('wave');
+ shapes7.push('wave');
+ }
+ if(shapes1[0] === 'diamond' && shapes1[3] === 'wave'){
+ shapes6.push('oval');
+ shapes7.push('oval');
+ }
+
+ if(shapes1[0] === 'wave' && shapes1[3] === 'diamond'){
+ shapes6.push('oval');
+ shapes7.push('oval');
+ }
+ if(shapes1[0] === 'wave' && shapes1[3] === 'oval'){
+ shapes6.push('diamond');
+ shapes7.push('diamond');
+ }
+
+ }
+ if(fills1[0] === fills1 [3]){
+ fills6.push(fills1[0]);
+ fills7.push(fills1[0]);
+ }
+ else{
+ if(fills1[0] === 'solid' && fills1[3] === 'stripped'){
+ fills6.push('open');
+ fills7.push('open');
+ }
+
+ if(fills1[0] === 'solid' && fills1[3] === 'open'){
+ fills6.push('stripped');
+ fills7.push('stripped');
+ }
+
+ if(fills1[0] === 'stripped' && fills1[3] === 'open'){
+ fills6.push('solid');
+ fills7.push('solid');
+ }
+ if(fills1[0] === 'open' && fills1[3] === 'stripped'){
+ fills6.push('solid');
+ fills7.push('solid');
+ }
+
+ if(fills1[0] === 'stripped' && fills1[3] === 'solid'){
+ fills6.push('open');
+ fills7.push('open');
+ }
+ if(fills1[0] === 'open' && fills1[3] === 'solid'){
+ fills6.push('stripped');
+ fills7.push('stripped');
+ }
+
+ }
+ if(numbers1[0] === numbers1[3]){
+ numbers6.push(numbers1[0]);
+ numbers7.push(numbers1[0]);
+ }
+ else{
+ if(numbers1[0] === 1 && numbers1[3] === 2){
+ numbers6.push(3);
+ numbers7.push(3);
+ }
+
+ if(numbers1[0] === 1 && numbers1[3] === 3){
+ numbers6.push(2);
+ numbers7.push(2);
+ }
+
+ if(numbers1[0] === 2 && numbers1[3] === 1){
+ numbers6.push(3);
+ numbers7.push(3);
+ }
+ if(numbers1[0] === 2 && numbers1[3] === 3){
+ numbers6.push(1);
+ numbers7.push(1);
+ }
+
+ if(numbers1[0] === 3 && numbers1[3] === 1){
+ numbers6.push(2);
+ numbers7.push(2);
+ }
+ if(numbers1[0] === 3 && numbers1[3] === 2){
+ numbers6.push(1);
+ numbers7.push(1);
+ }
+ }
+ if(this.isSet(colors2) && this.isSet(shapes2) && this.isSet(fills2) && this.isSet(numbers2)) {
+ return this.isSet(colors3) && this.isSet(shapes3) && this.isSet(fills3) && this.isSet(numbers3)
+ }
+ if(this.isSet(colors4) && this.isSet(shapes4) && this.isSet(fills4) && this.isSet(numbers4)){
+ return this.isSet(colors5)&& this.isSet(shapes5)&& this.isSet(fills5)&& this.isSet(numbers5)
+ }
+ if(this.isSet(colors6) && this.isSet(shapes6) && this.isSet(fills6) && this.isSet(numbers6)) {
+ return this.isSet(colors7) && this.isSet(shapes7) && this.isSet(fills7) && this.isSet(numbers7)
+ }
+
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ validateSet0: function() {
+ var self = this;
+
+ var colors = $.map(self.selected0, function(el) { return $(el).data("color");});
+ var shapes = $.map(self.selected0, function(el) { return $(el).data("shape"); });
+ var numbers= $.map(self.selected0, function(el) { return $(el).data("number"); });
+
+ return (self.isSet(colors) && self.isSet(shapes) && self.isSet(numbers));
+ },
+
+ 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.selected1, function(el) { return $(el).data("color");});
+ var shapes = $.map(self.selected1, function(el) { return $(el).data("shape"); });
+ var fills= $.map(self.selected1, function(el) { return $(el).data("fill"); });
+ var borders= $.map(self.selected1, function(el) { return $(el).data("border"); });
+ var numbers = $.map(self.selected1, 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.selected2, function(el) { return $(el).data("color");});
+ var shapes = $.map(self.selected2, function(el) { return $(el).data("shape"); });
+ var fills= $.map(self.selected2, function(el) { return $(el).data("fill"); });
+ var numbers = $.map(self.selected2, 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.selected3, function(el) { return $(el).data("color");});
+ var shapes = $.map(self.selected3, function(el) { return $(el).data("shape"); });
+ var fills= $.map(self.selected3, function(el) { return $(el).data("fill"); });
+ var borders= $.map(self.selected3, function(el) { return $(el).data("border"); });
+ var numbers = $.map(self.selected3, 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.selected4, function(el) { return $(el).data("color");});
+ var shapes = $.map(self.selected4, function(el) { return $(el).data("shape"); });
+ var fills= $.map(self.selected4, function(el) { return $(el).data("fill"); });
+ var borders= $.map(self.selected4, function(el) { return $(el).data("border"); });
+ var numbers = $.map(self.selected4, 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);
+ });
+ 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);
});
@@ -1385,6 +2462,38 @@ var Game = {
+ silentSubmissionHS: function() {
+ var valid = this.validateHyperSet();
+ if (valid) {
+ console.log(valid);
+ this.submitSetHS();
+ }
+ },
+ silentSubmissionHS0: function() {
+ var valid = this.validateHyperSet0();
+ if (valid) {
+ console.log(valid);
+ this.submitSetHS0();
+ }
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
submitSet0: function() {
var self = this;
@@ -1571,6 +2680,83 @@ var Game = {
+ submitSetHS: function() {
+ var self = this;
+ var ids = $.map(self.selectedHS, function(el) { return $(el).data("id");});
+
+
+ // ajax request to get initial set of cards
+ var newCardRequest = $.ajax({
+ url: 'set.php?action=submitHS',
+ type: 'GET',
+ dataType: 'json',
+ success: function(data) {
+ self.clearCardsHS(ids, data);
+
+ // to do - implement game complete check on server
+ if (!data.gameComplete) {
+ //self.set0 = 0;
+ //self.updateCards(data);
+ //self.existingSet0();
+ self.increaseScoreHS();
+ } else {
+ self.gameWon();
+ }
+ },
+ error: function() {
+ console.log(arguments);
+ }
+ });
+
+ this.clearSelectionsHS();
+ },
+
+
+ submitSetHS0: function() {
+ var self = this;
+ var ids = $.map(self.selectedHS0, function(el) { return $(el).data("id");});
+
+
+ // ajax request to get initial set of cards
+ var newCardRequest = $.ajax({
+ url: 'set.php?action=submitHS0',
+ type: 'GET',
+ dataType: 'json',
+ success: function(data) {
+ self.clearCardsHS0(ids, data);
+
+ // to do - implement game complete check on server
+ if (!data.gameComplete) {
+ //self.set0 = 0;
+ //self.updateCards(data);
+ //self.existingSet0();
+ self.increaseScoreHS0();
+ } else {
+ self.gameWon();
+ }
+ },
+ error: function() {
+ console.log(arguments);
+ }
+ });
+
+ this.clearSelectionsHS0();
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1726,6 +2912,65 @@ var Game = {
}
},
+ clearCardsHS: function(ids,data) {
+ var self = this;
+ this.selectedHS = [];
+ this.$boardHS.empty();
+ var cardIds = $.map(self.cardsHS, function(card) { return card.id; });
+ $.each(ids, function(idx, id) {
+ var location = cardIds.indexOf(id);
+ if (location > -1) {
+ cardIds.splice(location, 1);
+ if(data[idx] != null){
+ self.cardsHS.splice(location, 1, data[idx]);
+ cardIds = $.map(self.cardsHS, function(card) { return card.id; });
+ }
+ else{
+ self.cardsHS.splice(location, 1);
+
+
+ }
+
+ }
+ });
+ this.displayCardsHS();
+ if(self.cardsHS.length === 0){
+ alert("you won!");
+ }
+ },
+
+ clearCardsHS0: function(ids,data) {
+ var self = this;
+ this.selectedHS0 = [];
+ this.$boardHS0.empty();
+ var cardIds = $.map(self.cardsHS0, function(card) { return card.id; });
+ $.each(ids, function(idx, id) {
+ var location = cardIds.indexOf(id);
+ if (location > -1) {
+ cardIds.splice(location, 1);
+ if(data[idx] != null){
+ self.cardsHS0.splice(location, 1, data[idx]);
+ cardIds = $.map(self.cardsHS0, function(card) { return card.id; });
+ }
+ else{
+ self.cardsHS0.splice(location, 1);
+
+ }
+ }
+ });
+ this.displayCardsHS0();
+ if(self.cardsHS0.length === 0){
+ alert("you won!");
+ }
+ },
+
+
+
+
+
+
+
+
@@ -1796,7 +3041,12 @@ var Game = {
increaseScore4: function() {
this.$score4.html(++this.score4);
},
-
+ increaseScoreHS: function() {
+ this.$scoreHS.html(++this.scoreHS);
+ },
+ increaseScoreHS0: function() {
+ this.$scoreHS0.html(++this.scoreHS0);
+ },