+
+
-
+
diff --git a/HyperSet/vues/css/style.css b/HyperSet/vues/css/style.css
index 70d5bbc..5dbb290 100644
--- a/HyperSet/vues/css/style.css
+++ b/HyperSet/vues/css/style.css
@@ -349,8 +349,6 @@ h1 {
border-radius: 40px / 50px;
transform: rotate(0.5deg) skewX(1deg) scaleX(0.8);
width: 38px;
- height: 80px;
-
}
diff --git a/HyperSet/vues/homePage.html b/HyperSet/vues/homePage.html
index 7f552c1..6aa55db 100644
--- a/HyperSet/vues/homePage.html
+++ b/HyperSet/vues/homePage.html
@@ -107,7 +107,7 @@
Nombre de carte = 3; Nombre de critères = 5
- Sets found:
+ Sets found: 0
Number of Sets:
diff --git a/HyperSet/vues/js/set.js b/HyperSet/vues/js/set.js
index ddbad9a..dc6d879 100644
--- a/HyperSet/vues/js/set.js
+++ b/HyperSet/vues/js/set.js
@@ -638,21 +638,6 @@ var Game = {
},
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
// PARLER SUR CET ALGO SUR LE RAPPORT
@@ -726,6 +711,11 @@ var Game = {
var carte1;
var carte2;
+ var card3 = [];
+
+ var tCards =[];
+
+
var i, j, a;
@@ -741,133 +731,38 @@ var Game = {
carte1 = cartes[i];
carte2 = cartes1[j];
+ tCards[0] = carte1;
+ tCards[1]= carte2;
+
+ card3 = this.generateVirtualCard34(tCards);
+
colors1.splice(0,1,carte1.color);
colors1.splice(1,1,carte2.color);
+ colors1.splice(2, 1, card3[0].color);
shapes1.splice(0,1,carte1.shape);
shapes1.splice(1,1,carte2.shape);
+ shapes1.splice(2, 1, card3[0].shape);
+
fills1.splice(0,1,carte1.fill);
fills1.splice(1,1,carte2.fill);
+ fills1.splice(2, 1, card3[0].fill);
numbers1.splice(0,1,carte1.number);
numbers1.splice(1,1,carte2.number);
+ numbers1.splice(2, 1, card3[0].number);
- if(colors1[0] === colors1 [1]){
- colors1.splice(2,1,colors1[0]);
- }
- else{
- if(colors1[0] === 'red' && colors1[1] === 'green'){
- colors1.splice(2,1,'purple');
- }
-
- if(colors1[0] === 'red' && colors1[1] === 'purple'){
- colors1.splice(2,1,'green');
- }
-
- if(colors1[0] === 'green' && colors1[1] === 'purple'){
- colors1.splice(2,1,'red');
- }
- if(colors1[0] === 'green' && colors1[1] === 'red'){
- colors1.splice(2,1,'purple');
- }
-
- if(colors1[0] === 'purple' && colors1[1] === 'red'){
- colors1.splice(2,1,'green');
- }
- if(colors1[0] === 'purple' && colors1[1] === 'green'){
- colors1.splice(2,1,'red');
- }
-
- }
- if(shapes1[0] === shapes1 [1]){
- shapes1.splice(2,1,shapes1[0]);
- }
- else{
- if(shapes1[0] === 'oval' && shapes1[1] === 'diamond'){
- shapes1.splice(2,1,'wave');
- }
-
- if(shapes1[0] === 'oval' && shapes1[1] === 'wave'){
- shapes1.splice(2,1,'diamond');
- }
-
- if(shapes1[0] === 'diamond' && shapes1[1] === 'oval'){
- shapes1.splice(2,1,'wave');
-
- }
- if(shapes1[0] === 'diamond' && shapes1[1] === 'wave'){
- shapes1.splice(2,1,'oval');
- }
-
- if(shapes1[0] === 'wave' && shapes1[1] === 'diamond'){
- shapes1.splice(2,1,'oval');
- }
- if(shapes1[0] === 'wave' && shapes1[1] === 'oval'){
- shapes1.splice(2,1,'diamond');
- }
- }
- if(fills1[0] === fills1 [1]){
- fills1.splice(2,1,fills1[0]);
- }
- else {
- if (fills1[0] === 'solid' && fills1[1] === 'stripped') {
- fills1.splice(2, 1, 'open');
- }
-
- if (fills1[0] === 'solid' && fills1[1] === 'open') {
- fills1.splice(2, 1, 'stripped');
- }
-
- if (fills1[0] === 'stripped' && fills1[1] === 'open') {
- fills1.splice(2, 1, 'solid');
- }
- if (fills1[0] === 'open' && fills1[1] === 'stripped') {
- fills1.splice(2, 1, 'solid');
- }
-
- if (fills1[0] === 'stripped' && fills1[1] === 'solid') {
- fills1.splice(2, 1, 'open');
- }
- if (fills1[0] === 'open' && fills1[1] === 'solid') {
- fills1.splice(2, 1, 'stripped');
- }
- }
- if(numbers1[0] === numbers1[1]){
- numbers1.splice(2,1,numbers1[0]);
- }
- else{
- if(numbers1[0] === 1 && numbers1[1] === 2){
- numbers1.splice(2,1,3);
- }
-
- if(numbers1[0] === 1 && numbers1[1] === 3){
- numbers1.splice(2,1,2);
- }
-
- if(numbers1[0] === 2 && numbers1[1] === 1){
- numbers1.splice(2,1,3);
- }
- if(numbers1[0] === 2 && numbers1[1] === 3){
- numbers1.splice(2,1,1);
- }
-
- if(numbers1[0] === 3 && numbers1[1] === 1){
- numbers1.splice(2,1,2);
- }
- if(numbers1[0] === 3 && numbers1[1] === 2){
- numbers1.splice(2,1,1);
- }
-
- }
for (a = j+1; a= 0) {
- self.deselectCard0(card);
+ self.deselectCard(self.selected0,card);
} else {
- self.selectCard0(card);
+ self.selectCard3(self.selected0,card);
}
if (self.selected0.length === 3) {
@@ -1725,9 +1055,9 @@ var Game = {
// 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);
+ self.deselectCard(self.selected,card);
} else {
- self.selectCard(card);
+ self.selectCard3(self.selected,card);
}
if (self.selected.length === 3) {
@@ -1747,9 +1077,9 @@ var Game = {
// 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);
+ self.deselectCard(self.selected1,card);
} else {
- self.selectCard1(card);
+ self.selectCard3(self.selected1,card);
}
if (self.selected1.length === 3) {
@@ -1768,9 +1098,9 @@ var Game = {
// 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);
+ self.deselectCard(self.selected3,card);
} else {
- self.selectCard2(card);
+ self.selectCard4(self.selected2,card);
}
if (self.selected2.length === 4) {
@@ -1789,9 +1119,9 @@ var Game = {
// 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);
+ self.deselectCard(self.selected3,card);
} else {
- self.selectCard3(card);
+ self.selectCard4(self.selected3,card);
}
if (self.selected3.length === 4) {
@@ -1810,9 +1140,9 @@ var Game = {
// 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);
+ self.deselectCard(self.selected4,card);
} else {
- self.selectCard4(card);
+ self.selectCard5(self.selected4,card);
}
if (self.selected4.length === 5) {
@@ -1832,9 +1162,9 @@ var Game = {
// 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);
+ self.deselectCard(self.selectedHS,card);
} else {
- self.selectCardHS(card);
+ self.selectCard4(self.selectedHS,card);
}
if (self.selectedHS.length === 4) {
@@ -1854,9 +1184,9 @@ var Game = {
// 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);
+ self.deselectCard(self.selectedHS0,card);
} else {
- self.selectCardHS0(card);
+ self.selectCard4(self.selectedHS0,card);
}
if (self.selectedHS0.length === 4) {
@@ -1877,9 +1207,9 @@ var Game = {
// if card is new, add it, otherwise remove it
var ids = $.map(self.selectedHS1, function(el) { return $(el).data("id");});
if (ids.indexOf($(card).data('id')) >= 0) {
- self.deselectCardHS1(card);
+ self.deselectCard(self.selectedHS1,card);
} else {
- self.selectCardHS1(card);
+ self.selectCard4(self.selectedHS1,card);
}
if (self.selectedHS1.length === 4) {
@@ -1898,9 +1228,9 @@ var Game = {
// if card is new, add it, otherwise remove it
var ids = $.map(self.selectedHS2, function(el) { return $(el).data("id");});
if (ids.indexOf($(card).data('id')) >= 0) {
- self.deselectCardHS2(card);
+ self.deselectCard(self.selectedHS2,card);
} else {
- self.selectCardHS2(card);
+ self.selectCard6(self.selectedHS2,card);
}
if (self.selectedHS2.length === 6) {
@@ -1915,397 +1245,64 @@ var Game = {
+ selectCard3: function(selectedCard, card) {
+ if (selectedCard.length < 3) {
+ $(card).addClass('selected');
+ selectedCard.push(card);
+
+ }
+ },
+ selectCard4: function(selectedCard, card) {
+ if (selectedCard.length < 4) {
+ $(card).addClass('selected');
+ selectedCard.push(card);
+ }
+ },
+ selectCard5: function(selectedCard, card) {
+ if (selectedCard.length < 5) {
+ $(card).addClass('selected');
+ selectedCard.push(card);
+ }
+ },
+ selectCard6: function(selectedCard, card) {
+ if (selectedCard.length < 6) {
+ $(card).addClass('selected');
+ selectedCard.push(card);
+ }
+ },
- setPageListeners0: function() {
- var self = this;
+ deselectCard: function(selectedCards,card) {
- // if the user clicks on the page outside the game board, clear selected
- $(document).on('click', function() {
- self.clearSelections0.call(self);
- });
+ var index = selectedCards.indexOf(card);
+ if (index > -1) {
+ selectedCards.splice(index, 1);
+ }
+ $(card).removeClass('selected');
},
- 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);
+ clearSelections: function(selectedCards) {
+ $.each(selectedCards, function(index, card) {
+ $(card).removeClass('selected');
});
+ selectedCards = [];
},
- 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);
- });
- },
-
-
- 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);
- });
- },
- setPageListenersHS1: function() {
- var self = this;
-
- // if the user clicks on the page outside the game board, clear selected
- $(document).on('click', function() {
- self.clearSelectionsHS1.call(self);
- });
- },
- setPageListenersHS2: function() {
- var self = this;
-
- // if the user clicks on the page outside the game board, clear selected
- $(document).on('click', function() {
- self.clearSelectionsHS2.call(self);
- });
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- selectCard0: function(card) {
-
- if (this.selected0.length < 3) {
- $(card).addClass('selected');
- this.selected0.push(card);
- }
-
- },
-
- selectCard: function(card) {
- if (this.selected.length < 3) {
- $(card).addClass('selected');
- this.selected.push(card);
-
- }
-
- },
-
- selectCard1: function(card) {
-
-
- if (this.selected1.length < 3) {
- $(card).addClass('selected');
- this.selected1.push(card);
- }
-
- },
-
- selectCard2: function(card) {
- if (this.selected2.length < 4) {
- $(card).addClass('selected');
- this.selected2.push(card);
-
- }
-
- },
-
- selectCard3: function(card) {
-
-
- if (this.selected3.length < 4) {
- $(card).addClass('selected');
- this.selected3.push(card);
- }
-
- },
-
- selectCard4: function(card) {
-
-
- if (this.selected4.length < 5) {
- $(card).addClass('selected');
- this.selected4.push(card);
- }
-
- },
-
- 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);
-
- }
-
- },
-
-
- selectCardHS1: function(card) {
-
- if (this.selectedHS1.length < 4) {
- $(card).addClass('selected');
- this.selectedHS1.push(card);
-
- }
-
- },
- selectCardHS2: function(card) {
-
- if (this.selectedHS2.length < 6) {
- $(card).addClass('selected');
- this.selectedHS2.push(card);
-
- }
-
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- deselectCard0: function(card) {
- var self = this;
- var index = self.selected0.indexOf(card);
- if (index > -1) {
- self.selected0.splice(index, 1);
- }
- $(card).removeClass('selected');
- },
- 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');
- },
- 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');
- },
-
- deselectCardHS1: function(card) {
- var self = this;
- var index = self.selectedHS1.indexOf(card);
- if (index > -1) {
- self.selectedHS1.splice(index, 1);
- }
- $(card).removeClass('selected');
- },
- deselectCardHS2: function(card) {
- var self = this;
- var index = self.selectedHS2.indexOf(card);
- if (index > -1) {
- self.selectedHS2.splice(index, 1);
- }
- $(card).removeClass('selected');
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- clearSelections0: function() {
- $.each(this.selected0, function(index, card) {
- $(card).removeClass('selected');
- });
- this.selected0 = [];
- },
- 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 = [];
- },
-
-
- 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 = [];
- },
- clearSelectionsHS1: function() {
- $.each(this.selectedHS1, function(index, card) {
- $(card).removeClass('selected');
- });
- this.selectedHS1 = [];
- },
- clearSelectionsHS2: function() {
- $.each(this.selectedHS2, function(index, card) {
- $(card).removeClass('selected');
- });
- this.selectedHS2 = [];
- },
@@ -2314,288 +1311,249 @@ var Game = {
+ generateVirtualCard34: function(cards1){
-
-
-
-
-
-
-
-// cards1 combinaison ab, cards2 combinaison cd, selectedCards(taille toujours 2) pré-effectuer les combinaison 0 et 1, 0 et 2, 0 et 3...
-
- generateVirtualCard34: function(cards1, cards2){
var colors2= $.map(cards1, function(el) { return $(el).data("color");});
var shapes2 = $.map(cards1, function(el) { return $(el).data("shape");});
var fills2 = $.map(cards1, function(el) { return $(el).data("fill");});
var numbers2 = $.map(cards1, function(el) { return $(el).data("number");});
- var colors3= $.map(cards2, function(el) { return $(el).data("color");});
- var shapes3 = $.map(cards2, function(el) { return $(el).data("shape");});
- var fills3 = $.map(cards2, function(el) { return $(el).data("fill");});
- var numbers3 = $.map(cards2, function(el) { return $(el).data("number");});
+ if (shapes2[0] === undefined && colors2[0] === undefined && fills2[0] === undefined && numbers2[0] === undefined) {
+ colors2= $.map(cards1, function(el) { return el.color;});
+ shapes2 = $.map(cards1, function(el) { return el.shape;});
+ fills2 = $.map(cards1, function(el) { return el.fill;});
+ numbers2 = $.map(cards1, function(el) { return el.number;});
+ }
+
if(colors2[0] === colors2 [1]){
colors2.push(colors2[0]);
- colors3.push(colors2[0]);
}
else{
if(colors2[0] === 'red' && colors2[1] === 'green'){
- colors3.push('purple');
colors2.push('purple');
}
if(colors2[0] === 'red' && colors2[1] === 'purple'){
- colors3.push('green');
colors2.push('green');
}
if(colors2[0] === 'green' && colors2[1] === 'purple'){
- colors3.push('red');
colors2.push('red');
}
if(colors2[0] === 'green' && colors2[1] === 'red'){
- colors3.push('purple');
colors2.push('purple');
}
if(colors2[0] === 'purple' && colors2[1] === 'red'){
- colors3.push('green');
colors2.push('green');
}
if(colors2[0] === 'purple' && colors2[1] === 'green'){
- colors3.push('red');
colors2.push('red');
}
}
if(shapes2[0] === shapes2 [1]){
- shapes3.push(shapes2[0]);
shapes2.push(shapes2[0]);
}
else{
if(shapes2[0] === 'oval' && shapes2[1] === 'diamond'){
- shapes3.push('wave');
shapes2.push('wave');
}
if(shapes2[0] === 'oval' && shapes2[1] === 'wave'){
- shapes3.push('diamond');
shapes2.push('diamond');
}
if(shapes2[0] === 'diamond' && shapes2[1] === 'oval'){
- shapes3.push('wave');
shapes2.push('wave');
}
if(shapes2[0] === 'diamond' && shapes2[1] === 'wave'){
- shapes3.push('oval');
shapes2.push('oval');
}
if(shapes2[0] === 'wave' && shapes2[1] === 'diamond'){
- shapes3.push('oval');
shapes2.push('oval');
}
if(shapes2[0] === 'wave' && shapes2[1] === 'oval'){
- shapes3.push('diamond');
shapes2.push('diamond');
}
}
if(fills2[0] === fills2 [1]){
- fills3.push(fills2[0]);
fills2.push(fills2[0]);
}
else{
if(fills2[0] === 'solid' && fills2[1] === 'stripped'){
- fills3.push('open');
fills2.push('open');
}
if(fills2[0] === 'solid' && fills2[1] === 'open'){
- fills3.push('stripped');
fills2.push('stripped');
}
if(fills2[0] === 'stripped' && fills2[1] === 'open'){
- fills3.push('solid');
fills2.push('solid');
}
if(fills2[0] === 'open' && fills2[1] === 'stripped'){
- fills3.push('solid');
fills2.push('solid');
}
if(fills2[0] === 'stripped' && fills2[1] === 'solid'){
- fills3.push('open');
fills2.push('open');
}
if(fills2[0] === 'open' && fills2[1] === 'solid'){
- fills3.push('stripped');
fills2.push('stripped');
}
}
if(numbers2[0] === numbers2[1]){
- numbers3.push(numbers2[0]);
numbers2.push(numbers2[0]);
}
else{
if(numbers2[0] === 1 && numbers2[1] === 2){
- numbers3.push(3);
numbers2.push(3);
}
if(numbers2[0] === 1 && numbers2[1] === 3){
- numbers3.push(2);
numbers2.push(2);
}
if(numbers2[0] === 2 && numbers2[1] === 1){
- numbers3.push(3);
numbers2.push(3);
}
if(numbers2[0] === 2 && numbers2[1] === 3){
- numbers3.push(1);
numbers2.push(1);
}
if(numbers2[0] === 3 && numbers2[1] === 1){
- numbers3.push(2);
numbers2.push(2);
}
if(numbers2[0] === 3 && numbers2[1] === 2){
- numbers3.push(1);
numbers2.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)
- }
+ var cards4 = [];
+
+ cards4.push({
+ shape: shapes2[2],
+ fill: fills2[2],
+ color: colors2[2],
+ number: numbers2[2]
+ });
+
+ return cards4;
},
- generateVirtualCard33: function(cards1, cards2){
+ generateVirtualCard33: function(cards1){
var colors2= $.map(cards1, function(el) { return $(el).data("color");});
var shapes2 = $.map(cards1, function(el) { return $(el).data("shape");});
var numbers2 = $.map(cards1, function(el) { return $(el).data("number");});
- var colors3= $.map(cards2, function(el) { return $(el).data("color");});
- var shapes3 = $.map(cards2, function(el) { return $(el).data("shape");});
- var numbers3 = $.map(cards2, function(el) { return $(el).data("number");});
+ if (shapes2[0] === undefined && colors2[0] === undefined && numbers2[0] === undefined) {
+ colors2= $.map(cards1, function(el) { return el.color;});
+ shapes2 = $.map(cards1, function(el) { return el.shape;});
+ numbers2 = $.map(cards1, function(el) { return el.number;});
+ }
+
if(colors2[0] === colors2 [1]){
colors2.push(colors2[0]);
- colors3.push(colors2[0]);
}
else{
if(colors2[0] === 'red' && colors2[1] === 'green'){
- colors3.push('purple');
colors2.push('purple');
}
if(colors2[0] === 'red' && colors2[1] === 'purple'){
- colors3.push('green');
colors2.push('green');
}
if(colors2[0] === 'green' && colors2[1] === 'purple'){
- colors3.push('red');
colors2.push('red');
}
if(colors2[0] === 'green' && colors2[1] === 'red'){
- colors3.push('purple');
colors2.push('purple');
}
if(colors2[0] === 'purple' && colors2[1] === 'red'){
- colors3.push('green');
colors2.push('green');
}
if(colors2[0] === 'purple' && colors2[1] === 'green'){
- colors3.push('red');
colors2.push('red');
}
}
if(shapes2[0] === shapes2 [1]){
- shapes3.push(shapes2[0]);
shapes2.push(shapes2[0]);
}
else{
if(shapes2[0] === 'oval' && shapes2[1] === 'diamond'){
- shapes3.push('wave');
shapes2.push('wave');
}
if(shapes2[0] === 'oval' && shapes2[1] === 'wave'){
- shapes3.push('diamond');
shapes2.push('diamond');
}
if(shapes2[0] === 'diamond' && shapes2[1] === 'oval'){
- shapes3.push('wave');
shapes2.push('wave');
}
if(shapes2[0] === 'diamond' && shapes2[1] === 'wave'){
- shapes3.push('oval');
shapes2.push('oval');
}
if(shapes2[0] === 'wave' && shapes2[1] === 'diamond'){
- shapes3.push('oval');
shapes2.push('oval');
}
if(shapes2[0] === 'wave' && shapes2[1] === 'oval'){
- shapes3.push('diamond');
shapes2.push('diamond');
}
}
if(numbers2[0] === numbers2[1]){
- numbers3.push(numbers2[0]);
numbers2.push(numbers2[0]);
}
else{
if(numbers2[0] === 1 && numbers2[1] === 2){
- numbers3.push(3);
numbers2.push(3);
}
if(numbers2[0] === 1 && numbers2[1] === 3){
- numbers3.push(2);
numbers2.push(2);
}
if(numbers2[0] === 2 && numbers2[1] === 1){
- numbers3.push(3);
numbers2.push(3);
}
if(numbers2[0] === 2 && numbers2[1] === 3){
- numbers3.push(1);
numbers2.push(1);
}
if(numbers2[0] === 3 && numbers2[1] === 1){
- numbers3.push(2);
numbers2.push(2);
}
if(numbers2[0] === 3 && numbers2[1] === 2){
- numbers3.push(1);
numbers2.push(1);
}
}
- if(this.isSet(colors2) && this.isSet(shapes2) && this.isSet(numbers2)) {
- return this.isSet(colors3) && this.isSet(shapes3) && this.isSet(numbers3)
- }
+ var cards4 = [];
+
+ cards4.push({
+ shape: shapes2[2],
+ color: colors2[2],
+ number: numbers2[2]
+ });
+
+ return cards4;
},
- generateVirtualCard35: function(cards1, cards2){
+ generateVirtualCard35: function(cards1){
// modalité des combinaison de carte (ab ac ad ...) pour verifier si forme un set
var colors2= $.map(cards1, function(el) { return $(el).data("color");});
@@ -2604,700 +1562,628 @@ var Game = {
var borders2 = $.map(cards1, function(el) { return $(el).data("border");});
var numbers2 = $.map(cards1, function(el) { return $(el).data("number");});
- var colors3= $.map(cards2, function(el) { return $(el).data("color");});
- var shapes3 = $.map(cards2, function(el) { return $(el).data("shape");});
- var fills3 = $.map(cards2, function(el) { return $(el).data("fill");});
- var borders3 = $.map(cards2, function(el) { return $(el).data("border");});
- var numbers3 = $.map(cards2, function(el) { return $(el).data("number");});
+ if (shapes2[0] === undefined && colors2[0] === undefined && fills2[0] === undefined && numbers2[0] === undefined && borders2[0] === undefined) {
+ colors2= $.map(cards1, function(el) { return el.color;});
+ shapes2 = $.map(cards1, function(el) { return el.shape;});
+ fills2 = $.map(cards1, function(el) { return el.fill;});
+ numbers2 = $.map(cards1, function(el) { return el.number;});
+ borders2 = $.map(cards1, function(el) { return el.border;});
+
+ }
+
if(colors2[0] === colors2 [1]){
colors2.push(colors2[0]);
- colors3.push(colors2[0]);
}
else{
if(colors2[0] === 'red' && colors2[1] === 'green'){
- colors3.push('purple');
colors2.push('purple');
}
if(colors2[0] === 'red' && colors2[1] === 'purple'){
- colors3.push('green');
colors2.push('green');
}
if(colors2[0] === 'green' && colors2[1] === 'purple'){
- colors3.push('red');
colors2.push('red');
}
if(colors2[0] === 'green' && colors2[1] === 'red'){
- colors3.push('purple');
colors2.push('purple');
}
if(colors2[0] === 'purple' && colors2[1] === 'red'){
- colors3.push('green');
colors2.push('green');
}
if(colors2[0] === 'purple' && colors2[1] === 'green'){
- colors3.push('red');
colors2.push('red');
}
}
if(shapes2[0] === shapes2 [1]){
- shapes3.push(shapes2[0]);
shapes2.push(shapes2[0]);
}
else{
if(shapes2[0] === 'oval' && shapes2[1] === 'diamond'){
- shapes3.push('wave');
shapes2.push('wave');
}
if(shapes2[0] === 'oval' && shapes2[1] === 'wave'){
- shapes3.push('diamond');
shapes2.push('diamond');
}
if(shapes2[0] === 'diamond' && shapes2[1] === 'oval'){
- shapes3.push('wave');
shapes2.push('wave');
}
if(shapes2[0] === 'diamond' && shapes2[1] === 'wave'){
- shapes3.push('oval');
- shapes2.push('oval');
- }
-
- if(shapes2[0] === 'wave' && shapes2[1] === 'diamond'){
- shapes3.push('oval');
shapes2.push('oval');
}
- if(shapes2[0] === 'wave' && shapes2[1] === 'oval'){
- shapes3.push('diamond');
- shapes2.push('diamond');
- }
- }
- if(fills2[0] === fills2 [1]){
- fills3.push(fills2[0]);
- fills2.push(fills2[0]);
- }
- else{
- if(fills2[0] === 'solid' && fills2[1] === 'stripped'){
- fills3.push('open');
- fills2.push('open');
- }
-
- if(fills2[0] === 'solid' && fills2[1] === 'open'){
- fills3.push('stripped');
- fills2.push('stripped');
- }
-
- if(fills2[0] === 'stripped' && fills2[1] === 'open'){
- fills3.push('solid');
- fills2.push('solid');
- }
- if(fills2[0] === 'open' && fills2[1] === 'stripped'){
- fills3.push('solid');
- fills2.push('solid');
- }
-
- if(fills2[0] === 'stripped' && fills2[1] === 'solid'){
- fills3.push('open');
- fills2.push('open');
- }
- if(fills2[0] === 'open' && fills2[1] === 'solid'){
- fills3.push('stripped');
- fills2.push('stripped');
- }
- }
-
- if(borders2[0] === borders2 [1]){
- borders3.push(borders2[0]);
- borders2.push(borders2[0]);
- }
- else{
- if(borders2[0] === 'plein' && borders2[1] === 'point'){
- borders3.push('rond');
- borders2.push('rond');
- }
-
- if(borders2[0] === 'point' && borders2[1] === 'plein'){
- borders3.push('rond');
- borders2.push('rond');
- }
-
- if(borders2[0] === 'rond' && borders2[1] === 'plein'){
- borders3.push('point');
- borders2.push('point');
- }
- if(borders2[0] === 'plein' && borders2[1] === 'rond'){
- borders3.push('point');
- borders2.push('point');
- }
-
- if(borders2[0] === 'rond' && borders2[1] === 'point'){
- borders3.push('plein');
- borders2.push('plein');
- }
- if(borders2[0] === 'point' && borders2[1] === 'rond'){
- borders3.push('plein');
- borders2.push('plein');
- }
- }
-
- if(numbers2[0] === numbers2[1]){
- numbers3.push(numbers2[0]);
- numbers2.push(numbers2[0]);
- }
- else{
- if(numbers2[0] === 1 && numbers2[1] === 2){
- numbers3.push(3);
- numbers2.push(3);
- }
-
- if(numbers2[0] === 1 && numbers2[1] === 3){
- numbers3.push(2);
- numbers2.push(2);
- }
-
- if(numbers2[0] === 2 && numbers2[1] === 1){
- numbers3.push(3);
- numbers2.push(3);
- }
- if(numbers2[0] === 2 && numbers2[1] === 3){
- numbers3.push(1);
- numbers2.push(1);
- }
-
- if(numbers2[0] === 3 && numbers2[1] === 1){
- numbers3.push(2);
- numbers2.push(2);
- }
- if(numbers2[0] === 3 && numbers2[1] === 2){
- numbers3.push(1);
- numbers2.push(1);
- }
-
- }
-
- if(this.isSet(colors2) && this.isSet(shapes2) && this.isSet(fills2) && this.isSet(borders2) && this.isSet(numbers2)) {
- return this.isSet(colors3) && this.isSet(shapes3) && this.isSet(fills3) && this.isSet(borders3) && this.isSet(numbers3)
- }
- },
-
-
- generateVirtualCard44: function(cards1, cards2){
-
- var colors2= $.map(cards1, function(el) { return $(el).data("color");});
- var shapes2 = $.map(cards1, function(el) { return $(el).data("shape");});
- var fills2 = $.map(cards1, function(el) { return $(el).data("fill");});
- var numbers2 = $.map(cards1, function(el) { return $(el).data("number");});
-
- var colors3= $.map(cards2, function(el) { return $(el).data("color");});
- var shapes3 = $.map(cards2, function(el) { return $(el).data("shape");});
- var fills3 = $.map(cards2, function(el) { return $(el).data("fill");});
- var numbers3 = $.map(cards2, function(el) { return $(el).data("number");});
-
- if (colors2[0] === colors2[1] && colors2[0] === colors2[2]) {
- colors2.push(colors2[0]);
- colors3.push(colors2[0]);
- } else {
- if (colors2[0] === 'red' && colors2[1] === 'green' && colors2[2] === 'purple') {
- colors3.push('lightblue');
- colors2.push('lightblue');
- }
-
- if (colors2[0] === 'red' && colors2[1] === 'purple' && colors2[2] === 'green') {
- colors3.push('lightblue');
- colors2.push('lightblue');
- }
-
- if (colors2[0] === 'purple' && colors2[1] === 'red' && colors2[2] === 'green') {
- colors3.push('lightblue');
- colors2.push('lightblue');
- }
- if (colors2[0] === 'purple' && colors2[1] === 'green' && colors2[2] === 'red') {
- colors3.push('lightblue');
- colors2.push('lightblue');
- }
-
- if (colors2[0] === 'green' && colors2[1] === 'purple' && colors2[2] === 'red') {
- colors3.push('lightblue');
- colors2.push('lightblue');
- }
- if (colors2[0] === 'green' && colors2[1] === 'red' && colors2[2] === 'purple') {
- colors3.push('lightblue');
- colors2.push('lightblue');
- }
-
-
- if (colors2[0] === 'green' && colors2[1] === 'purple' && colors2[2] === 'lightblue') {
- colors3.push('red');
- colors2.push('red');
-
- }
-
- if (colors2[0] === 'green' && colors2[1] === 'lightblue' && colors2[2] === 'purple') {
- colors3.push('red');
- colors2.push('red');
- }
-
- if (colors2[0] === 'purple' && colors2[1] === 'lightblue' && colors2[2] === 'green') {
- colors3.push('red');
- colors2.push('red');
- }
- if (colors2[0] === 'purple' && colors2[1] === 'green' && colors2[2] === 'lightblue') {
- colors3.push('red');
- colors2.push('red');
- }
-
- if (colors2[0] === 'lightblue' && colors2[1] === 'purple' && colors2[2] === 'green') {
- colors3.push('red');
- colors2.push('red');
- }
- if (colors2[0] === 'lightblue' && colors2[1] === 'green' && colors2[2] === 'purple') {
- colors3.push('red');
- colors2.push('red');
- }
-
-
- if (colors2[0] === 'red' && colors2[1] === 'green' && colors2[2] === 'lightblue') {
- colors3.push('purple');
- colors2.push('purple');
- }
-
- if (colors2[0] === 'red' && colors2[1] === 'lightblue' && colors2[2] === 'green') {
- colors3.push('purple');
- colors2.push('purple');
- }
-
- if (colors2[0] === 'lightblue' && colors2[1] === 'green' && colors2[2] === 'red') {
- colors3.push('purple');
- colors2.push('purple');
- }
- if (colors2[0] === 'lightblue' && colors2[1] === 'red' && colors2[2] === 'green') {
- colors3.push('purple');
- colors2.push('purple');
- }
-
- if (colors2[0] === 'green' && colors2[1] === 'lightblue' && colors2[2] === 'red') {
- colors3.push('purple');
- colors2.push('purple');
- }
- if (colors2[0] === 'green' && colors2[1] === 'red' && colors2[2] === 'lightblue') {
- colors3.push('purple');
- colors2.push('purple');
- }
-
-
- if (colors2[0] === 'red' && colors2[1] === 'purple' && colors2[2] === 'lightblue') {
- colors3.push('green');
- colors2.push('green');
- }
-
- if (colors2[0] === 'red' && colors2[1] === 'lightblue' && colors2[2] === 'purple') {
- colors3.push('green');
- colors2.push('green');
- }
-
- if (colors2[0] === 'lightblue' && colors2[1] === 'purple' && colors2[2] === 'red') {
- colors3.push('green');
- colors2.push('green');
- }
- if (colors2[0] === 'lightblue' && colors2[1] === 'red' && colors2[2] === 'purple') {
- colors3.push('green');
- colors2.push('green');
- }
-
- if (colors2[0] === 'purple' && colors2[1] === 'lightblue' && colors2[2] === 'red') {
- colors3.push('green');
- colors2.push('green');
- }
- if (colors2[0] === 'purple' && colors2[1] === 'red' && colors2[2] === 'lightblue') {
- colors3.push('green');
- colors2.push('green');
- }
-
- }
-
-
- if (shapes2[0] === shapes2 [1] && shapes2[0] === shapes2 [2]) {
- shapes3.push(shapes2[0]);
- shapes2.push(shapes2[0]);
- } else {
- if (shapes2[0] === 'oval' && shapes2[1] === 'diamond' && shapes2[2] === 'wave') {
- shapes3.push('rectangle');
- shapes2.push('rectangle');
- }
-
- if (shapes2[0] === 'oval' && shapes2[1] === 'wave' && shapes2[2] === 'diamond') {
- shapes3.push('rectangle');
- shapes2.push('rectangle');
- }
-
- if (shapes2[0] === 'wave' && shapes2[1] === 'diamond' && shapes2[2] === 'oval') {
- shapes3.push('rectangle');
- shapes2.push('rectangle');
-
- }
- if (shapes2[0] === 'wave' && shapes2[1] === 'oval' && shapes2[2] === 'diamond') {
- shapes3.push('rectangle');
- shapes2.push('rectangle');
- }
-
- if (shapes2[0] === 'diamond' && shapes2[1] === 'oval' && shapes2[2] === 'wave') {
- shapes3.push('rectangle');
- shapes2.push('rectangle');
- }
- if (shapes2[0] === 'diamond' && shapes2[1] === 'wave' && shapes2[2] === 'oval') {
- shapes3.push('rectangle');
- shapes2.push('rectangle');
- }
-
-
- if (shapes2[0] === 'oval' && shapes2[1] === 'diamond' && shapes2[2] === 'rectangle') {
- shapes3.push('wave');
- shapes2.push('wave');
- }
-
- if (shapes2[0] === 'oval' && shapes2[1] === 'rectangle' && shapes2[2] === 'diamond') {
- shapes3.push('wave');
- shapes2.push('wave');
- }
-
- if (shapes2[0] === 'rectangle' && shapes2[1] === 'oval' && shapes2[2] === 'diamond') {
- shapes3.push('wave');
- shapes2.push('wave');
-
- }
- if (shapes2[0] === 'rectangle' && shapes2[1] === 'diamond' && shapes2[2] === 'oval') {
- shapes3.push('wave');
- shapes2.push('wave');
- }
-
- if (shapes2[0] === 'diamond' && shapes2[1] === 'oval' && shapes2[2] === 'rectangle') {
- shapes3.push('wave');
- shapes2.push('wave');
- }
- if (shapes2[0] === 'diamond' && shapes2[1] === 'rectangle' && shapes2[2] === 'oval') {
- shapes3.push('wave');
- shapes2.push('wave');
- }
-
-
- if (shapes2[0] === 'oval' && shapes2[1] === 'wave' && shapes2[2] === 'rectangle') {
- shapes3.push('diamond');
- shapes2.push('diamond');
- }
-
- if (shapes2[0] === 'oval' && shapes2[1] === 'rectangle' && shapes2[2] === 'wave') {
- shapes3.push('diamond');
- shapes2.push('diamond');
- }
-
- if (shapes2[0] === 'rectangle' && shapes2[1] === 'wave' && shapes2[2] === 'oval') {
- shapes3.push('diamond');
- shapes2.push('diamond');
-
- }
- if (shapes2[0] === 'rectangle' && shapes2[1] === 'oval' && shapes2[2] === 'wave') {
- shapes3.push('diamond');
- shapes2.push('diamond');
- }
-
- if (shapes2[0] === 'wave' && shapes2[1] === 'oval' && shapes2[2] === 'rectangle') {
- shapes3.push('diamond');
- shapes2.push('diamond');
- }
- if (shapes2[0] === 'wave' && shapes2[1] === 'rectangle' && shapes2[2] === 'oval') {
- shapes3.push('diamond');
- shapes2.push('diamond');
- }
-
-
- if (shapes2[0] === 'diamond' && shapes2[1] === 'wave' && shapes2[2] === 'rectangle') {
- shapes3.push('oval');
- shapes2.push('oval');
- }
-
- if (shapes2[0] === 'diamond' && shapes2[1] === 'rectangle' && shapes2[2] === 'wave') {
- shapes3.push('oval');
- shapes2.push('oval');
- }
-
- if (shapes2[0] === 'rectangle' && shapes2[1] === 'wave' && shapes2[2] === 'diamond') {
- shapes3.push('oval');
- shapes2.push('oval');
-
- }
- if (shapes2[0] === 'rectangle' && shapes2[1] === 'diamond' && shapes2[2] === 'wave') {
- shapes3.push('oval');
- shapes2.push('oval');
- }
-
- if (shapes2[0] === 'wave' && shapes2[1] === 'diamond' && shapes2[2] === 'rectangle') {
- shapes3.push('oval');
- shapes2.push('oval');
- }
- if (shapes2[0] === 'wave' && shapes2[1] === 'rectangle' && shapes2[2] === 'diamond') {
- shapes3.push('oval');
- shapes2.push('oval');
- }
-
- }
- if (fills2[0] === fills2 [1] && fills2[0] === fills2 [2]) {
- fills3.push(fills2[0]);
- fills2.push(fills2[0]);
- } else {
- if (fills2[0] === 'solid' && fills2[1] === 'stripped' && fills2[2] === 'open') {
- fills3.push('quadrillage');
- fills2.push('quadrillage');
- }
-
- if (fills2[0] === 'solid' && fills2[1] === 'open' && fills2[2] === 'stripped') {
- fills3.push('quadrillage');
- fills2.push('quadrillage');
- }
-
- if (fills2[0] === 'stripped' && fills2[1] === 'open' && fills2[2] === 'solid') {
- fills3.push('quadrillage');
- fills2.push('quadrillage');
- }
- if (fills2[0] === 'stripped' && fills2[1] === 'solid' && fills2[2] === 'open') {
- fills3.push('quadrillage');
- fills2.push('quadrillage');
- }
-
- if (fills2[0] === 'open' && fills2[1] === 'stripped' && fills2[2] === 'solid') {
- fills3.push('quadrillage');
- fills2.push('quadrillage');
- }
- if (fills2[0] === 'open' && fills2[1] === 'solid' && fills2[2] === 'stripped') {
- fills3.push('quadrillage');
- fills2.push('quadrillage');
- }
-
-
- if (fills2[0] === 'solid' && fills2[1] === 'stripped' && fills2[2] === 'quadrillage') {
- fills3.push('open');
- fills2.push('open');
- }
-
- if (fills2[0] === 'solid' && fills2[1] === 'quadrillage' && fills2[2] === 'stripped') {
- fills3.push('open');
- fills2.push('open');
- }
-
- if (fills2[0] === 'quadrillage' && fills2[1] === 'solid' && fills2[2] === 'stripped') {
- fills3.push('open');
- fills2.push('open');
- }
- if (fills2[0] === 'quadrillage' && fills2[1] === 'stripped' && fills2[2] === 'solid') {
- fills3.push('open');
- fills2.push('open');
- }
-
- if (fills2[0] === 'stripped' && fills2[1] === 'quadrillage' && fills2[2] === 'solid') {
- fills3.push('open');
- fills2.push('open');
- }
- if (fills2[0] === 'stripped' && fills2[1] === 'solid' && fills2[2] === 'quadrillage') {
- fills3.push('open');
- fills2.push('open');
- }
-
-
- if (fills2[0] === 'solid' && fills2[1] === 'open' && fills2[2] === 'quadrillage') {
- fills3.push('stripped');
- fills2.push('stripped');
- }
-
- if (fills2[0] === 'solid' && fills2[1] === 'quadrillage' && fills2[2] === 'open') {
- fills3.push('stripped');
- fills2.push('stripped');
- }
-
- if (fills2[0] === 'quadrillage' && fills2[1] === 'solid' && fills2[2] === 'open') {
- fills3.push('stripped');
- fills2.push('stripped');
- }
- if (fills2[0] === 'quadrillage' && fills2[1] === 'open' && fills2[2] === 'solid') {
- fills3.push('stripped');
- fills2.push('stripped');
- }
- if (fills2[0] === 'open' && fills2[1] === 'quadrillage' && fills2[2] === 'solid') {
- fills3.push('stripped');
- fills2.push('stripped');
+ if(shapes2[0] === 'wave' && shapes2[1] === 'diamond'){
+ shapes2.push('oval');
}
- if (fills2[0] === 'open' && fills2[1] === 'solid' && fills2[2] === 'quadrillage') {
- fills3.push('stripped');
- fills2.push('stripped');
+ if(shapes2[0] === 'wave' && shapes2[1] === 'oval'){
+ shapes2.push('diamond');
}
-
-
- if (fills2[0] === 'stripped' && fills2[1] === 'open' && fills2[2] === 'quadrillage') {
- fills3.push('solid');
- fills2.push('solid');
+ }
+ if(fills2[0] === fills2 [1]){
+ fills2.push(fills2[0]);
+ }
+ else{
+ if(fills2[0] === 'solid' && fills2[1] === 'stripped'){
+ fills2.push('open');
}
- if (fills2[0] === 'stripped' && fills2[1] === 'quadrillage' && fills2[2] === 'open') {
- fills3.push('solid');
- fills2.push('solid');
+ if(fills2[0] === 'solid' && fills2[1] === 'open'){
+ fills2.push('stripped');
}
- if (fills2[0] === 'quadrillage' && fills2[1] === 'stripped' && fills2[2] === 'open') {
- fills3.push('solid');
+ if(fills2[0] === 'stripped' && fills2[1] === 'open'){
fills2.push('solid');
}
- if (fills2[0] === 'quadrillage' && fills2[1] === 'open' && fills2[2] === 'stripped') {
- fills3.push('solid');
+ if(fills2[0] === 'open' && fills2[1] === 'stripped'){
fills2.push('solid');
}
- if (fills2[0] === 'open' && fills2[1] === 'quadrillage' && fills2[2] === 'stripped') {
- fills3.push('solid');
- fills2.push('solid');
+ if(fills2[0] === 'stripped' && fills2[1] === 'solid'){
+ fills2.push('open');
}
- if (fills2[0] === 'open' && fills2[1] === 'stripped' && fills2[2] === 'quadrillage') {
- fills3.push('solid');
- fills2.push('solid');
+ if(fills2[0] === 'open' && fills2[1] === 'solid'){
+ fills2.push('stripped');
}
+ }
-
+ if(borders2[0] === borders2 [1]){
+ borders2.push(borders2[0]);
}
- if (numbers2[0] === numbers2[1] && numbers2[0] === numbers2[2]) {
- numbers3.push(numbers2[0]);
- numbers2.push(numbers2[0]);
- } else {
- if (numbers2[0] === 1 && numbers2[1] === 2 && numbers2[2] === 3) {
- numbers3.push(4);
- numbers2.push(4);
+ else{
+ if(borders2[0] === 'plein' && borders2[1] === 'point'){
+ borders2.push('rond');
}
- if (numbers2[0] === 1 && numbers2[1] === 3 && numbers2[2] === 2) {
- numbers3.push(4);
- numbers2.push(4);
+ if(borders2[0] === 'point' && borders2[1] === 'plein'){
+ borders2.push('rond');
}
- if (numbers2[0] === 2 && numbers2[1] === 1 && numbers2[2] === 3) {
- numbers3.push(4);
- numbers2.push(4);
+ if(borders2[0] === 'rond' && borders2[1] === 'plein'){
+ borders2.push('point');
}
- if (numbers2[0] === 2 && numbers2[1] === 3 && numbers2[2] === 1) {
- numbers3.push(4);
- numbers2.push(4);
+ if(borders2[0] === 'plein' && borders2[1] === 'rond'){
+ borders2.push('point');
}
- if (numbers2[0] === 3 && numbers2[1] === 1 && numbers2[2] === 2) {
- numbers3.push(4);
- numbers2.push(4);
+ if(borders2[0] === 'rond' && borders2[1] === 'point'){
+ borders2.push('plein');
}
- if (numbers2[0] === 3 && numbers2[1] === 2 && numbers2[2] === 1) {
- numbers3.push(4);
- numbers2.push(4);
+ if(borders2[0] === 'point' && borders2[1] === 'rond'){
+ borders2.push('plein');
}
+ }
-
- if (numbers2[0] === 1 && numbers2[1] === 2 && numbers2[2] === 4) {
- numbers3.push(3);
+ if(numbers2[0] === numbers2[1]){
+ numbers2.push(numbers2[0]);
+ }
+ else{
+ if(numbers2[0] === 1 && numbers2[1] === 2){
numbers2.push(3);
}
- if (numbers2[0] === 1 && numbers2[1] === 4 && numbers2[2] === 2) {
- numbers3.push(3);
- numbers2.push(3);
+ if(numbers2[0] === 1 && numbers2[1] === 3){
+ numbers2.push(2);
}
- if (numbers2[0] === 2 && numbers2[1] === 1 && numbers2[2] === 4) {
- numbers3.push(3);
+ if(numbers2[0] === 2 && numbers2[1] === 1){
numbers2.push(3);
}
- if (numbers2[0] === 2 && numbers2[1] === 4 && numbers2[2] === 1) {
- numbers3.push(3);
- numbers2.push(3);
+ if(numbers2[0] === 2 && numbers2[1] === 3){
+ numbers2.push(1);
}
- if (numbers2[0] === 4 && numbers2[1] === 1 && numbers2[2] === 2) {
- numbers3.push(3);
- numbers2.push(3);
+ if(numbers2[0] === 3 && numbers2[1] === 1){
+ numbers2.push(2);
}
- if (numbers2[0] === 4 && numbers2[1] === 2 && numbers2[2] === 1) {
- numbers3.push(3);
- numbers2.push(3);
+ if(numbers2[0] === 3 && numbers2[1] === 2){
+ numbers2.push(1);
}
+ }
+ var cards4 = [];
- if (numbers2[0] === 1 && numbers2[1] === 3 && numbers2[2] === 4) {
- numbers3.push(2);
- numbers2.push(2);
- }
+ cards4.push({
+ shape: shapes2[2],
+ fill: fills2[2],
+ color: colors2[2],
+ border: borders2[2],
+ number: numbers2[2]
+ });
- if (numbers2[0] === 1 && numbers2[1] === 4 && numbers2[2] === 3) {
- numbers3.push(2);
- numbers2.push(2);
- }
+ return cards4;
+ },
- if (numbers2[0] === 3 && numbers2[1] === 1 && numbers2[2] === 4) {
- numbers3.push(2);
- numbers2.push(2);
- }
- if (numbers2[0] === 3 && numbers2[1] === 4 && numbers2[2] === 1) {
- numbers3.push(2);
- numbers2.push(2);
- }
- if (numbers2[0] === 4 && numbers2[1] === 1 && numbers2[2] === 3) {
- numbers3.push(2);
- numbers2.push(2);
- }
- if (numbers2[0] === 4 && numbers2[1] === 3 && numbers2[2] === 1) {
- numbers3.push(2);
- numbers2.push(2);
- }
+ generateVirtualCard44: function(cards1){
+ var colors2= $.map(cards1, function(el) { return $(el).data("color");});
+ var shapes2 = $.map(cards1, function(el) { return $(el).data("shape");});
+ var fills2 = $.map(cards1, function(el) { return $(el).data("fill");});
+ var numbers2 = $.map(cards1, function(el) { return $(el).data("number");});
- if (numbers2[0] === 2 && numbers2[1] === 3 && numbers2[2] === 4) {
- numbers3.push(1);
- numbers2.push(1);
- }
+ if (shapes2[0] === undefined && colors2[0] === undefined && fills2[0] === undefined && numbers2[0] === undefined) {
+ colors2= $.map(cards1, function(el) { return el.color;});
+ shapes2 = $.map(cards1, function(el) { return el.shape;});
+ fills2 = $.map(cards1, function(el) { return el.fill;});
+ numbers2 = $.map(cards1, function(el) { return el.number;});
+ }
- if (numbers2[0] === 2 && numbers2[1] === 4 && numbers2[2] === 3) {
- numbers3.push(1);
- numbers2.push(1);
- }
- if (numbers2[0] === 3 && numbers2[1] === 2 && numbers2[2] === 4) {
- numbers3.push(1);
- numbers2.push(1);
- }
- if (numbers2[0] === 3 && numbers2[1] === 4 && numbers2[2] === 2) {
- numbers3.push(1);
- numbers2.push(1);
- }
+ if (colors2[0] === colors2[1] && colors2[0] === colors2[2]) {
+ colors2.push(colors2[0]);
+
+ } else {
+ if (colors2[0] === 'red' && colors2[1] === 'green' && colors2[2] === 'purple') {
+ colors2.push('lightblue');
+ }
+
+ if (colors2[0] === 'red' && colors2[1] === 'purple' && colors2[2] === 'green') {
+ colors2.push('lightblue');
+ }
+
+ if (colors2[0] === 'purple' && colors2[1] === 'red' && colors2[2] === 'green') {
+ colors2.push('lightblue');
+ }
+ if (colors2[0] === 'purple' && colors2[1] === 'green' && colors2[2] === 'red') {
+ colors2.push('lightblue');
+ }
+
+ if (colors2[0] === 'green' && colors2[1] === 'purple' && colors2[2] === 'red') {
+ colors2.push('lightblue');
+ }
+ if (colors2[0] === 'green' && colors2[1] === 'red' && colors2[2] === 'purple') {
+ colors2.push('lightblue');
+ }
+
+
+ if (colors2[0] === 'green' && colors2[1] === 'purple' && colors2[2] === 'lightblue') {
+ colors2.push('red');
+
+ }
+
+ if (colors2[0] === 'green' && colors2[1] === 'lightblue' && colors2[2] === 'purple') {
+ colors2.push('red');
+ }
+
+ if (colors2[0] === 'purple' && colors2[1] === 'lightblue' && colors2[2] === 'green') {
+ colors2.push('red');
+ }
+ if (colors2[0] === 'purple' && colors2[1] === 'green' && colors2[2] === 'lightblue') {
+ colors2.push('red');
+ }
+
+ if (colors2[0] === 'lightblue' && colors2[1] === 'purple' && colors2[2] === 'green') {
+ colors2.push('red');
+ }
+ if (colors2[0] === 'lightblue' && colors2[1] === 'green' && colors2[2] === 'purple') {
+ colors2.push('red');
+ }
+
+
+ if (colors2[0] === 'red' && colors2[1] === 'green' && colors2[2] === 'lightblue') {
+ colors2.push('purple');
+ }
+
+ if (colors2[0] === 'red' && colors2[1] === 'lightblue' && colors2[2] === 'green') {
+ colors2.push('purple');
+ }
+
+ if (colors2[0] === 'lightblue' && colors2[1] === 'green' && colors2[2] === 'red') {
+ colors2.push('purple');
+ }
+ if (colors2[0] === 'lightblue' && colors2[1] === 'red' && colors2[2] === 'green') {
+ colors2.push('purple');
+ }
+
+ if (colors2[0] === 'green' && colors2[1] === 'lightblue' && colors2[2] === 'red') {
+ colors2.push('purple');
+ }
+ if (colors2[0] === 'green' && colors2[1] === 'red' && colors2[2] === 'lightblue') {
+ colors2.push('purple');
+ }
+
+
+ if (colors2[0] === 'red' && colors2[1] === 'purple' && colors2[2] === 'lightblue') {
+ colors2.push('green');
+ }
+
+ if (colors2[0] === 'red' && colors2[1] === 'lightblue' && colors2[2] === 'purple') {
+ colors2.push('green');
+ }
+
+ if (colors2[0] === 'lightblue' && colors2[1] === 'purple' && colors2[2] === 'red') {
+ colors2.push('green');
+ }
+ if (colors2[0] === 'lightblue' && colors2[1] === 'red' && colors2[2] === 'purple') {
+ colors2.push('green');
+ }
+
+ if (colors2[0] === 'purple' && colors2[1] === 'lightblue' && colors2[2] === 'red') {
+ colors2.push('green');
+ }
+ if (colors2[0] === 'purple' && colors2[1] === 'red' && colors2[2] === 'lightblue') {
+ colors2.push('green');
+ }
+
+ }
+
+
+ if (shapes2[0] === shapes2 [1] && shapes2[0] === shapes2 [2]) {
+ shapes2.push(shapes2[0]);
+ } else {
+ if (shapes2[0] === 'oval' && shapes2[1] === 'diamond' && shapes2[2] === 'wave') {
+ shapes2.push('rectangle');
+ }
+
+ if (shapes2[0] === 'oval' && shapes2[1] === 'wave' && shapes2[2] === 'diamond') {
+ shapes2.push('rectangle');
+ }
+
+ if (shapes2[0] === 'wave' && shapes2[1] === 'diamond' && shapes2[2] === 'oval') {
+ shapes2.push('rectangle');
+
+ }
+ if (shapes2[0] === 'wave' && shapes2[1] === 'oval' && shapes2[2] === 'diamond') {
+ shapes2.push('rectangle');
+ }
+
+ if (shapes2[0] === 'diamond' && shapes2[1] === 'oval' && shapes2[2] === 'wave') {
+ shapes2.push('rectangle');
+ }
+ if (shapes2[0] === 'diamond' && shapes2[1] === 'wave' && shapes2[2] === 'oval') {
+ shapes2.push('rectangle');
+ }
+
+
+ if (shapes2[0] === 'oval' && shapes2[1] === 'diamond' && shapes2[2] === 'rectangle') {
+ shapes2.push('wave');
+ }
+
+ if (shapes2[0] === 'oval' && shapes2[1] === 'rectangle' && shapes2[2] === 'diamond') {
+ shapes2.push('wave');
+ }
+
+ if (shapes2[0] === 'rectangle' && shapes2[1] === 'oval' && shapes2[2] === 'diamond') {
+ shapes2.push('wave');
+
+ }
+ if (shapes2[0] === 'rectangle' && shapes2[1] === 'diamond' && shapes2[2] === 'oval') {
+ shapes2.push('wave');
+ }
+
+ if (shapes2[0] === 'diamond' && shapes2[1] === 'oval' && shapes2[2] === 'rectangle') {
+ shapes2.push('wave');
+ }
+ if (shapes2[0] === 'diamond' && shapes2[1] === 'rectangle' && shapes2[2] === 'oval') {
+ shapes2.push('wave');
+ }
+
+
+ if (shapes2[0] === 'oval' && shapes2[1] === 'wave' && shapes2[2] === 'rectangle') {
+ shapes2.push('diamond');
+ }
+
+ if (shapes2[0] === 'oval' && shapes2[1] === 'rectangle' && shapes2[2] === 'wave') {
+ shapes2.push('diamond');
+ }
+
+ if (shapes2[0] === 'rectangle' && shapes2[1] === 'wave' && shapes2[2] === 'oval') {
+ shapes2.push('diamond');
+
+ }
+ if (shapes2[0] === 'rectangle' && shapes2[1] === 'oval' && shapes2[2] === 'wave') {
+ shapes2.push('diamond');
+ }
+
+ if (shapes2[0] === 'wave' && shapes2[1] === 'oval' && shapes2[2] === 'rectangle') {
+ shapes2.push('diamond');
+ }
+ if (shapes2[0] === 'wave' && shapes2[1] === 'rectangle' && shapes2[2] === 'oval') {
+ shapes2.push('diamond');
+ }
+
+
+ if (shapes2[0] === 'diamond' && shapes2[1] === 'wave' && shapes2[2] === 'rectangle') {
+ shapes2.push('oval');
+ }
+
+ if (shapes2[0] === 'diamond' && shapes2[1] === 'rectangle' && shapes2[2] === 'wave') {
+ shapes2.push('oval');
+ }
+
+ if (shapes2[0] === 'rectangle' && shapes2[1] === 'wave' && shapes2[2] === 'diamond') {
+ shapes2.push('oval');
+
+ }
+ if (shapes2[0] === 'rectangle' && shapes2[1] === 'diamond' && shapes2[2] === 'wave') {
+ shapes2.push('oval');
+ }
+
+ if (shapes2[0] === 'wave' && shapes2[1] === 'diamond' && shapes2[2] === 'rectangle') {
+ shapes2.push('oval');
+ }
+ if (shapes2[0] === 'wave' && shapes2[1] === 'rectangle' && shapes2[2] === 'diamond') {
+ shapes2.push('oval');
+ }
+
+ }
+ if (fills2[0] === fills2 [1] && fills2[0] === fills2 [2]) {
+ fills2.push(fills2[0]);
+ } else {
+ if (fills2[0] === 'solid' && fills2[1] === 'stripped' && fills2[2] === 'open') {
+ fills2.push('quadrillage');
+ }
+
+ if (fills2[0] === 'solid' && fills2[1] === 'open' && fills2[2] === 'stripped') {
+ fills2.push('quadrillage');
+ }
+
+ if (fills2[0] === 'stripped' && fills2[1] === 'open' && fills2[2] === 'solid') {
+ fills2.push('quadrillage');
+ }
+ if (fills2[0] === 'stripped' && fills2[1] === 'solid' && fills2[2] === 'open') {
+ fills2.push('quadrillage');
+ }
+
+ if (fills2[0] === 'open' && fills2[1] === 'stripped' && fills2[2] === 'solid') {
+ fills2.push('quadrillage');
+ }
+ if (fills2[0] === 'open' && fills2[1] === 'solid' && fills2[2] === 'stripped') {
+ fills2.push('quadrillage');
+ }
+
+
+ if (fills2[0] === 'solid' && fills2[1] === 'stripped' && fills2[2] === 'quadrillage') {
+ fills2.push('open');
+ }
+
+ if (fills2[0] === 'solid' && fills2[1] === 'quadrillage' && fills2[2] === 'stripped') {
+ fills2.push('open');
+ }
+
+ if (fills2[0] === 'quadrillage' && fills2[1] === 'solid' && fills2[2] === 'stripped') {
+ fills2.push('open');
+ }
+ if (fills2[0] === 'quadrillage' && fills2[1] === 'stripped' && fills2[2] === 'solid') {
+ fills2.push('open');
+ }
+
+ if (fills2[0] === 'stripped' && fills2[1] === 'quadrillage' && fills2[2] === 'solid') {
+ fills2.push('open');
+ }
+ if (fills2[0] === 'stripped' && fills2[1] === 'solid' && fills2[2] === 'quadrillage') {
+ fills2.push('open');
+ }
+
+
+ if (fills2[0] === 'solid' && fills2[1] === 'open' && fills2[2] === 'quadrillage') {
+ fills2.push('stripped');
+ }
+
+ if (fills2[0] === 'solid' && fills2[1] === 'quadrillage' && fills2[2] === 'open') {
+ fills2.push('stripped');
+ }
+
+ if (fills2[0] === 'quadrillage' && fills2[1] === 'solid' && fills2[2] === 'open') {
+ fills2.push('stripped');
+ }
+ if (fills2[0] === 'quadrillage' && fills2[1] === 'open' && fills2[2] === 'solid') {
+ fills2.push('stripped');
+ }
+
+ if (fills2[0] === 'open' && fills2[1] === 'quadrillage' && fills2[2] === 'solid') {
+ fills2.push('stripped');
+ }
+ if (fills2[0] === 'open' && fills2[1] === 'solid' && fills2[2] === 'quadrillage') {
+ fills2.push('stripped');
+ }
+
+
+ if (fills2[0] === 'stripped' && fills2[1] === 'open' && fills2[2] === 'quadrillage') {
+ fills2.push('solid');
+ }
+
+ if (fills2[0] === 'stripped' && fills2[1] === 'quadrillage' && fills2[2] === 'open') {
+ fills2.push('solid');
+ }
+
+ if (fills2[0] === 'quadrillage' && fills2[1] === 'stripped' && fills2[2] === 'open') {
+ fills2.push('solid');
+ }
+ if (fills2[0] === 'quadrillage' && fills2[1] === 'open' && fills2[2] === 'stripped') {
+ fills2.push('solid');
+ }
+
+ if (fills2[0] === 'open' && fills2[1] === 'quadrillage' && fills2[2] === 'stripped') {
+ fills2.push('solid');
+ }
+ if (fills2[0] === 'open' && fills2[1] === 'stripped' && fills2[2] === 'quadrillage') {
+ fills2.push('solid');
+ }
+
+
+ }
+ if (numbers2[0] === numbers2[1] && numbers2[0] === numbers2[2]) {
+ numbers2.push(numbers2[0]);
+ } else {
+ if (numbers2[0] === 1 && numbers2[1] === 2 && numbers2[2] === 3) {
+ numbers2.push(4);
+ }
+
+ if (numbers2[0] === 1 && numbers2[1] === 3 && numbers2[2] === 2) {
+ numbers2.push(4);
+ }
+
+ if (numbers2[0] === 2 && numbers2[1] === 1 && numbers2[2] === 3) {
+ numbers2.push(4);
+ }
+ if (numbers2[0] === 2 && numbers2[1] === 3 && numbers2[2] === 1) {
+ numbers2.push(4);
+ }
+
+ if (numbers2[0] === 3 && numbers2[1] === 1 && numbers2[2] === 2) {
+ numbers2.push(4);
+ }
+ if (numbers2[0] === 3 && numbers2[1] === 2 && numbers2[2] === 1) {
+ numbers2.push(4);
+ }
+
+
+ if (numbers2[0] === 1 && numbers2[1] === 2 && numbers2[2] === 4) {
+ numbers2.push(3);
+ }
+
+ if (numbers2[0] === 1 && numbers2[1] === 4 && numbers2[2] === 2) {
+ numbers2.push(3);
+ }
+
+ if (numbers2[0] === 2 && numbers2[1] === 1 && numbers2[2] === 4) {
+ numbers2.push(3);
+ }
+ if (numbers2[0] === 2 && numbers2[1] === 4 && numbers2[2] === 1) {
+ numbers2.push(3);
+ }
+
+ if (numbers2[0] === 4 && numbers2[1] === 1 && numbers2[2] === 2) {
+ numbers2.push(3);
+ }
+ if (numbers2[0] === 4 && numbers2[1] === 2 && numbers2[2] === 1) {
+ numbers2.push(3);
+ }
+
+
+ if (numbers2[0] === 1 && numbers2[1] === 3 && numbers2[2] === 4) {
+ numbers2.push(2);
+ }
+
+ if (numbers2[0] === 1 && numbers2[1] === 4 && numbers2[2] === 3) {
+ numbers2.push(2);
+ }
- if (numbers2[0] === 4 && numbers2[1] === 2 && numbers2[2] === 3) {
- numbers3.push(1);
- numbers2.push(1);
- }
- if (numbers2[0] === 4 && numbers2[1] === 3 && numbers2[2] === 2) {
- numbers3.push(1);
- numbers2.push(1);
- }
- }
+ if (numbers2[0] === 3 && numbers2[1] === 1 && numbers2[2] === 4) {
+ numbers2.push(2);
+ }
+ if (numbers2[0] === 3 && numbers2[1] === 4 && numbers2[2] === 1) {
+ numbers2.push(2);
+ }
+ if (numbers2[0] === 4 && numbers2[1] === 1 && numbers2[2] === 3) {
+ numbers2.push(2);
+ }
+ if (numbers2[0] === 4 && numbers2[1] === 3 && numbers2[2] === 1) {
+ numbers2.push(2);
+ }
- if(this.isSet4(colors2) && this.isSet4(shapes2) && this.isSet4(fills2) && this.isSet4(numbers2)) {
- return this.isSet4(colors3) && this.isSet4(shapes3) && this.isSet4(fills3) && this.isSet4(numbers3)
- }
- },
+ if (numbers2[0] === 2 && numbers2[1] === 3 && numbers2[2] === 4) {
+ numbers2.push(1);
+ }
+ if (numbers2[0] === 2 && numbers2[1] === 4 && numbers2[2] === 3) {
+ numbers2.push(1);
+ }
+ if (numbers2[0] === 3 && numbers2[1] === 2 && numbers2[2] === 4) {
+ numbers2.push(1);
+ }
+ if (numbers2[0] === 3 && numbers2[1] === 4 && numbers2[2] === 2) {
+ numbers2.push(1);
+ }
+ if (numbers2[0] === 4 && numbers2[1] === 2 && numbers2[2] === 3) {
+ numbers2.push(1);
+ }
+ if (numbers2[0] === 4 && numbers2[1] === 3 && numbers2[2] === 2) {
+ numbers2.push(1);
+ }
+ }
+ var cards4 =[];
+ /*cards4.push({
+ shape: shapes2[0],
+ fill: fills2[0],
+ color: colors2[0],
+ number: numbers2[0]
+ });
+ cards4.push({
+ shape: shapes2[1],
+ fill: fills2[1],
+ color: colors2[1],
+ number: numbers2[1]
+ });
+
+ cards4.push({
+ shape: shapes2[2],
+ fill: fills2[2],
+ color: colors2[2],
+ number: numbers2[2]
+ });*/
+
+ cards4.push({
+ shape: shapes2[3],
+ fill: fills2[3],
+ color: colors2[3],
+ number: numbers2[3]
+ });
+
+ return cards4;
+ },
+
+
+
+
+
+
+ comparaison2Carte4:function (carte1, carte2){
+ if( carte1[0].color !== undefined && carte1[0].shape !== undefined && carte1[0].fill !== undefined && carte1[0].number !== undefined && carte2[0].color !== undefined && carte2[0].shape !== undefined && carte2[0].fill !== undefined && carte2[0].number !== undefined){
+ return carte1[0].color === carte2[0].color && carte1[0].shape === carte2[0].shape && carte1[0].number === carte2[0].number && carte1[0].fill === carte2[0].fill ;
+ }
+ else {
+ return false;
+ }
+
+
+ },
+ comparaison2Carte3:function (carte1, carte2) {
+ if( carte1[0].color !== undefined && carte1[0].shape !== undefined && carte1[0].number !== undefined && carte2[0].color !== undefined && carte2[0].shape !== undefined && carte2[0].number !== undefined){
+ return carte1[0].color === carte2[0].color && carte1[0].shape === carte2[0].shape && carte1[0].number === carte2[0].number ;
+
+ }
+ },
+ comparaison2Carte5:function (carte1, carte2) {
+ if( carte1[0].color !== undefined && carte1[0].border!== undefined && carte1[0].shape !== undefined && carte1[0].fill !== undefined && carte1[0].number !== undefined && carte2[0].color !== undefined && carte2[0].border !== undefined && carte2[0].shape !== undefined && carte2[0].fill !== undefined && carte2[0].number !== undefined){
+ return carte1[0].color === carte2[0].color && carte1[0].shape === carte2[0].shape && carte1[0].number === carte2[0].number && carte1[0].fill === carte2[0].fill ;
+
+ }
+ },
@@ -3329,19 +2215,25 @@ var Game = {
carteBC.splice(0,1,this.selectedHS0[1]);
carteBC.splice(1,1,this.selectedHS0[2]);
- if (this.generateVirtualCard33(carteAB, carteCD)) {
- return true;
+ var card3 = this.generateVirtualCard33(carteAB);
+ var card4 = this.generateVirtualCard33(carteCD);
+ if (this.comparaison2Carte3(card3,card4)){
+ return true;
+ }
- }
- if (this.generateVirtualCard33(carteAC, carteBD)) {
- return true;
- }
+ var card5 = this.generateVirtualCard33(carteAC);
+ var card6 = this.generateVirtualCard33(carteBD);
+ if (this.comparaison2Carte3(card5,card6)){
+ return true;
+ }
- if (this.generateVirtualCard33(carteAD, carteBC)) {
- return true;
- }
+ var card7 = this.generateVirtualCard33(carteAD);
+ var card8 = this.generateVirtualCard33(carteBC);
+ if (this.comparaison2Carte3(card7,card8)){
+ return true;
+ }
- return false;
+ return false;
},
@@ -3370,19 +2262,25 @@ var Game = {
- if (this.generateVirtualCard34(carteAB, carteCD)) {
- return true;
+ var card3 = this.generateVirtualCard34(carteAB);
+ var card4 = this.generateVirtualCard34(carteCD);
+ if (this.comparaison2Carte4(card3,card4)){
+ return true;
+ }
- }
- else if (this.generateVirtualCard34(carteAC, carteBD)){
- return true;
- }
- else if (this.generateVirtualCard34(carteAD, carteBC)) {
- return true;
- }
- else{
- return false;
- }
+ var card5 = this.generateVirtualCard34(carteAC);
+ var card6 = this.generateVirtualCard34(carteBD);
+ if (this.comparaison2Carte4(card5,card6)){
+ return true;
+ }
+
+ var card7 = this.generateVirtualCard34(carteAD);
+ var card8 = this.generateVirtualCard34(carteBC);
+ if (this.comparaison2Carte4(card7,card8)){
+ return true;
+ }
+
+ return false;
},
@@ -3411,20 +2309,25 @@ var Game = {
carteBC.splice(1,1,this.selectedHS1[2]);
- if (this.generateVirtualCard35(carteAB, carteCD)) {
- return true;
+ var card3 = this.generateVirtualCard35(carteAB);
+ var card4 = this.generateVirtualCard35(carteCD);
+ if (this.comparaison2Carte5(card3,card4)){
+ return true;
+ }
- }
- else if (this.generateVirtualCard35(carteAC, carteBD)) {
- return true;
- }
+ var card5 = this.generateVirtualCard35(carteAC);
+ var card6 = this.generateVirtualCard35(carteBD);
+ if (this.comparaison2Carte5(card5,card6)){
+ return true;
+ }
- else if (this.generateVirtualCard35(carteAD, carteBC)) {
- return true;
- }
- else{
- return false;
- }
+ var card7 = this.generateVirtualCard35(carteAD);
+ var card8 = this.generateVirtualCard35(carteBC);
+ if (this.comparaison2Carte5(card7,card8)){
+ return true;
+ }
+
+ return false;
},
@@ -3535,68 +2438,61 @@ var Game = {
carteBCD.splice(2, 1, this.selectedHS2[3]);
- if (this.generateVirtualCard44(carteABC, carteDEF)) {
- return true;
-
- }
- else if (this.generateVirtualCard44(carteABD, carteCEF)) {
- return true;
-
- }
- else if (this.generateVirtualCard44(carteABE, carteCDF)) {
- return true;
-
- }
- else if (this.generateVirtualCard44(carteABF, carteCDE)) {
- return true;
-
- }
- else if (this.generateVirtualCard44(carteACD, carteBEF)) {
- return true;
-
- }
- if (this.generateVirtualCard44(carteACE, carteBDF)) {
- return true;
-
- }
- else if (this.generateVirtualCard44(carteACF, carteBDE)) {
- return true;
-
- }
- else if (this.generateVirtualCard44(carteADE, carteBCF)) {
- return true;
-
- }
- else if (this.generateVirtualCard44(carteADF, carteBCE)) {
- return true;
-
- }
- else if (this.generateVirtualCard44(carteAEF, carteBCD)) {
- return true;
+ var card3 = this.generateVirtualCard44(carteABC);
+ var card4 = this.generateVirtualCard44(carteDEF);
+ if (this.comparaison2Carte4(card3,card4)){
+ return true;
+ }
+
+ var card5 = this.generateVirtualCard44(carteABD);
+ var card6 = this.generateVirtualCard44(carteCEF);
+ if (this.comparaison2Carte4(card5,card6)){
+ return true;
+ }
+ var card7 = this.generateVirtualCard44(carteABE);
+ var card8 = this.generateVirtualCard44(carteCDF);
+ if (this.comparaison2Carte4(card7,card8)){
+ return true;
+ }
+ var card9 = this.generateVirtualCard44(carteABF);
+ var card10 = this.generateVirtualCard44(carteCDE);
+ if (this.comparaison2Carte4(card9,card10)){
+ return true;
+ }
+ var card11 = this.generateVirtualCard44(carteACD);
+ var card12 = this.generateVirtualCard44(carteBEF);
+ if (this.comparaison2Carte4(card11,card12)){
+ return true;
+ }
+ var card13 = this.generateVirtualCard44(carteACE);
+ var card14 = this.generateVirtualCard44(carteBDF);
+ if (this.comparaison2Carte4(card13,card14)){
+ return true;
+ }
+ var card15 = this.generateVirtualCard44(carteACF);
+ var card16 = this.generateVirtualCard44(carteBDE);
+ if (this.comparaison2Carte4(card15,card16)){
+ return true;
+ }
+ var card17 = this.generateVirtualCard44(carteADE);
+ var card18 = this.generateVirtualCard44(carteBCF);
+ if (this.comparaison2Carte4(card17,card18)){
+ return true;
+ }
+ var card19= this.generateVirtualCard44(carteADF);
+ var card20 = this.generateVirtualCard44(carteBCE);
+ if (this.comparaison2Carte4(card19,card20)){
+ return true;
+ }
+ var card21 = this.generateVirtualCard44(carteAEF);
+ var card22 = this.generateVirtualCard44(carteBCD);
+ if (this.comparaison2Carte4(card21,card22)){
+ return true;
+ }
+ return false;
- }
- else{
- return false;
- }
},
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -3677,15 +2573,6 @@ var Game = {
-
-
-
-
-
-
-
-
-
isSet: function(arr) {
var unique = [];
$.each(arr, function(i, el){
@@ -3718,11 +2605,6 @@ var Game = {
-
-
-
-
-
silentSubmission0: function() {
var valid = this.validateSet0();
if (valid) {
@@ -3794,18 +2676,6 @@ var Game = {
-
-
-
-
-
-
-
-
-
-
-
-
submitSet0: function() {
var self = this;
var ids = $.map(self.selected0, function(el) { return $(el).data("id");});
@@ -3834,7 +2704,7 @@ var Game = {
}
});
- this.clearSelections0();
+ this.clearSelections(this.selected0);
},
submitSet: function() {
@@ -3864,7 +2734,7 @@ var Game = {
}
});
- this.clearSelections();
+ this.clearSelections(this.selected);
},
submitSet1: function() {
@@ -3893,7 +2763,7 @@ var Game = {
}
});
- this.clearSelections1();
+ this.clearSelections(this.selected1);
},
@@ -3924,7 +2794,7 @@ var Game = {
}
});
- this.clearSelections2();
+ this.clearSelections(this.selected2);
},
@@ -3954,7 +2824,7 @@ var Game = {
}
});
- this.clearSelections3();
+ this.clearSelections(this.selected3);
},
@@ -3986,7 +2856,7 @@ var Game = {
}
});
- this.clearSelections4();
+ this.clearSelections(this.selected4);
},
@@ -4019,7 +2889,7 @@ var Game = {
}
});
- this.clearSelectionsHS();
+ this.clearSelections(this.selectedHS);
},
@@ -4051,7 +2921,7 @@ var Game = {
}
});
- this.clearSelectionsHS0();
+ this.clearSelections(this.selectedHS0);
},
submitSetHS1: function() {
@@ -4082,7 +2952,7 @@ var Game = {
}
});
- this.clearSelectionsHS1();
+ this.clearSelections(this.selectedHS1);
},
submitSetHS2: function() {
var self = this;
@@ -4112,26 +2982,15 @@ var Game = {
}
});
- this.clearSelectionsHS2();
+ this.clearSelections(this.selectedHS2);
},
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ remplacerCarte : function(location, card, setOfCards){
+ setOfCards.splice(location,1,card);
+ },
@@ -4148,7 +3007,7 @@ var Game = {
if (location > -1) {
cardIds.splice(location, 1);
if(data[idx] != null){
- self.cards0.splice(location, 1, data[idx]);
+ self.remplacerCarte(location,data[idx],self.cards0);
cardIds = $.map(self.cards0, function(card) { return card.id; });
}
else{
@@ -4175,7 +3034,7 @@ var Game = {
if (location > -1) {
cardIds.splice(location, 1);
if(data[idx] != null){
- self.cards.splice(location, 1, data[idx]);
+ self.remplacerCarte(location,data[idx],self.cards);
cardIds = $.map(self.cards, function(card) { return card.id; });
}
else{
@@ -4199,7 +3058,7 @@ var Game = {
if (location > -1) {
cardIds.splice(location, 1);
if(data[idx] != null){
- self.cards1.splice(location, 1, data[idx]);
+ self.remplacerCarte(location,data[idx],self.cards1);
cardIds = $.map(self.cards1, function(card) { return card.id; });
}
else{
@@ -4223,7 +3082,7 @@ var Game = {
if (location > -1) {
cardIds.splice(location, 1);
if(data[idx] != null){
- self.cards2.splice(location, 1, data[idx]);
+ self.remplacerCarte(location,data[idx],self.cards2);
cardIds = $.map(self.cards2, function(card) { return card.id; });
}
else{
@@ -4247,7 +3106,7 @@ var Game = {
if (location > -1) {
cardIds.splice(location, 1);
if(data[idx] != null){
- self.cards3.splice(location, 1, data[idx]);
+ self.remplacerCarte(location,data[idx],self.cards3);
cardIds = $.map(self.cards3, function(card) { return card.id; });
}
else{
@@ -4271,7 +3130,7 @@ var Game = {
if (location > -1) {
cardIds.splice(location, 1);
if(data[idx] != null){
- self.cards4.splice(location, 1, data[idx]);
+ self.remplacerCarte(location,data[idx],self.cards4);
cardIds = $.map(self.cards4, function(card) { return card.id; });
}
else{
@@ -4295,7 +3154,7 @@ var Game = {
if (location > -1) {
cardIds.splice(location, 1);
if(data[idx] != null){
- self.cardsHS.splice(location, 1, data[idx]);
+ self.remplacerCarte(location,data[idx],self.cardsHS);
cardIds = $.map(self.cardsHS, function(card) { return card.id; });
}
else{
@@ -4322,7 +3181,7 @@ var Game = {
if (location > -1) {
cardIds.splice(location, 1);
if(data[idx] != null){
- self.cardsHS0.splice(location, 1, data[idx]);
+ self.remplacerCarte(location,data[idx],self.cardsHS0);
cardIds = $.map(self.cardsHS0, function(card) { return card.id; });
}
else{
@@ -4348,7 +3207,7 @@ var Game = {
if (location > -1) {
cardIds.splice(location, 1);
if(data[idx] != null){
- self.cardsHS1.splice(location, 1, data[idx]);
+ self.remplacerCarte(location,data[idx],self.cardsHS1);
cardIds = $.map(self.cardsHS1, function(card) { return card.id; });
}
else{
@@ -4372,7 +3231,7 @@ var Game = {
if (location > -1) {
cardIds.splice(location, 1);
if(data[idx] != null){
- self.cardsHS2.splice(location, 1, data[idx]);
+ self.remplacerCarte(location,data[idx],self.cardsHS2);
cardIds = $.map(self.cardsHS2, function(card) { return card.id; });
}
else{
@@ -4386,59 +3245,6 @@ var Game = {
alert("you won!");
}
},
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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();
- },
-
-
-
-
-
-
-
-
@@ -4477,7 +3283,6 @@ var Game = {
},
-
startRound: function() {
// todo
// reset timer to 30 seconds
@@ -4491,9 +3296,7 @@ var Game = {
alert("you lost :(");
}
-
-
-};;;
+};