|
|
|
@ -3,7 +3,7 @@ var Game = {
|
|
|
|
|
cards: [],
|
|
|
|
|
selected: [],
|
|
|
|
|
score: 0,
|
|
|
|
|
set: 1,
|
|
|
|
|
set: 0,
|
|
|
|
|
$board: $('[data-display="game-board"]'),
|
|
|
|
|
$score: $('[data-display="score"]'),
|
|
|
|
|
$nbSets: $('[data-display="nbSets"]'),
|
|
|
|
@ -125,6 +125,7 @@ var Game = {
|
|
|
|
|
success: function (data) {
|
|
|
|
|
self.cards = data;
|
|
|
|
|
self.existingSet();
|
|
|
|
|
self.existingSetT();
|
|
|
|
|
self.displayCards.call(self);
|
|
|
|
|
self.setCardListeners();
|
|
|
|
|
//self.setPageListeners();
|
|
|
|
@ -138,8 +139,8 @@ var Game = {
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
success: function (data) {
|
|
|
|
|
self.cards1 = data;
|
|
|
|
|
//self.existingSet1();
|
|
|
|
|
self.displayCards1.call(self);
|
|
|
|
|
self.existingSet1();
|
|
|
|
|
self.setCardListeners1();
|
|
|
|
|
//self.setPageListeners1();
|
|
|
|
|
|
|
|
|
@ -192,6 +193,7 @@ var Game = {
|
|
|
|
|
success: function (data) {
|
|
|
|
|
self.cards0 = data;
|
|
|
|
|
self.displayCards0.call(self);
|
|
|
|
|
self.existingSet0();
|
|
|
|
|
self.setCardListeners0();
|
|
|
|
|
//self.setPageListeners0();
|
|
|
|
|
}
|
|
|
|
@ -653,7 +655,7 @@ var Game = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// PARLER SUR CET ALGO SUR LE RAPPORT
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
existingSet: function() {
|
|
|
|
|
var colors = [];
|
|
|
|
@ -709,15 +711,15 @@ var Game = {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
console.log('ah' + self.set);
|
|
|
|
|
this.$nbSets.html(self.set);
|
|
|
|
|
},*/
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
existingSet: function() {
|
|
|
|
|
existingSetT: function() {
|
|
|
|
|
var colors1 = [];
|
|
|
|
|
var shapes1 =[];
|
|
|
|
|
var fills1= [];
|
|
|
|
|
var numbers1= [];
|
|
|
|
|
var valid;
|
|
|
|
|
var self = this;
|
|
|
|
|
var cartes = self.cards;
|
|
|
|
|
var cartes1 = cartes;
|
|
|
|
@ -726,14 +728,13 @@ var Game = {
|
|
|
|
|
var carte1;
|
|
|
|
|
var carte2;
|
|
|
|
|
|
|
|
|
|
var carte3 = [];
|
|
|
|
|
|
|
|
|
|
var colors2 = [];
|
|
|
|
|
var shapes2 =[];
|
|
|
|
|
var fills2= [];
|
|
|
|
|
var numbers2= [];
|
|
|
|
|
var i, j, a;
|
|
|
|
|
|
|
|
|
|
var test = 0;
|
|
|
|
|
var colorsall= $.map(this.cards, function(el) { return el.color;});
|
|
|
|
|
var shapesall = $.map(this.cards, function(el) { return el.shape; });
|
|
|
|
|
var fillsall= $.map(this.cards,function(el) { return el.fill; });
|
|
|
|
@ -872,7 +873,9 @@ var Game = {
|
|
|
|
|
if(colors2[0] === colorsall[a]){
|
|
|
|
|
if(fills2[0] === fillsall[a]) {
|
|
|
|
|
if(numbers2[0] === numbersall[a]){
|
|
|
|
|
self.set = self.set+1;
|
|
|
|
|
test = test + 1;
|
|
|
|
|
//self.set = self.set+1;
|
|
|
|
|
//console.log(shapes2,colors2,fills2,numbers2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -884,13 +887,357 @@ var Game = {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
console.log(test);
|
|
|
|
|
|
|
|
|
|
this.$nbSets.html(self.set);
|
|
|
|
|
//this.$nbSets.html(self.set);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
existingSet0: function() {
|
|
|
|
|
var colors1 = [];
|
|
|
|
|
var shapes1 =[];
|
|
|
|
|
var numbers1= [];
|
|
|
|
|
var self = this;
|
|
|
|
|
var cartes = self.cards0;
|
|
|
|
|
var cartes1 = cartes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var carte1;
|
|
|
|
|
var carte2;
|
|
|
|
|
|
|
|
|
|
var colors2 = [];
|
|
|
|
|
var shapes2 =[];
|
|
|
|
|
var numbers2= [];
|
|
|
|
|
var i, j, a;
|
|
|
|
|
|
|
|
|
|
var colorsall= $.map(this.cards0, function(el) { return el.color;});
|
|
|
|
|
var shapesall = $.map(this.cards0, function(el) { return el.shape; });
|
|
|
|
|
var numbersall = $.map(this.cards0, function(el) { return el.number;});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(i=0; i<cartes.length; i++) {
|
|
|
|
|
for (j = i+1; j < cartes1.length; j++) {
|
|
|
|
|
|
|
|
|
|
carte1 = cartes[i];
|
|
|
|
|
carte2 = cartes1[j];
|
|
|
|
|
|
|
|
|
|
colors1.splice(0,1,carte1.color);
|
|
|
|
|
colors1.splice(1,1,carte2.color);
|
|
|
|
|
|
|
|
|
|
shapes1.splice(0,1,carte1.shape);
|
|
|
|
|
shapes1.splice(1,1,carte2.shape);
|
|
|
|
|
|
|
|
|
|
numbers1.splice(0,1,carte1.number);
|
|
|
|
|
numbers1.splice(1,1,carte2.number);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(colors1[0] === colors1 [1]){
|
|
|
|
|
colors2.splice(0,1,colors1[0]);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if(colors1[0] === 'red' && colors1[1] === 'green'){
|
|
|
|
|
colors2.splice(0,1,'purple');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(colors1[0] === 'red' && colors1[1] === 'purple'){
|
|
|
|
|
colors2.splice(0,1,'green');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(colors1[0] === 'green' && colors1[1] === 'purple'){
|
|
|
|
|
colors2.splice(0,1,'red');
|
|
|
|
|
}
|
|
|
|
|
if(colors1[0] === 'green' && colors1[1] === 'red'){
|
|
|
|
|
colors2.splice(0,1,'purple');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(colors1[0] === 'purple' && colors1[1] === 'red'){
|
|
|
|
|
colors2.splice(0,1,'green');
|
|
|
|
|
}
|
|
|
|
|
if(colors1[0] === 'purple' && colors1[1] === 'green'){
|
|
|
|
|
colors2.splice(0,1,'red');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(shapes1[0] === shapes1 [1]){
|
|
|
|
|
shapes2.splice(0,1,shapes1[0]);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if(shapes1[0] === 'oval' && shapes1[1] === 'diamond'){
|
|
|
|
|
shapes2.splice(0,1,'wave');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(shapes1[0] === 'oval' && shapes1[1] === 'wave'){
|
|
|
|
|
shapes2.splice(0,1,'diamond');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(shapes1[0] === 'diamond' && shapes1[1] === 'oval'){
|
|
|
|
|
shapes2.splice(0,1,'wave');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(shapes1[0] === 'diamond' && shapes1[1] === 'wave'){
|
|
|
|
|
shapes2.splice(0,1,'oval');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(shapes1[0] === 'wave' && shapes1[1] === 'diamond'){
|
|
|
|
|
shapes2.splice(0,1,'oval');
|
|
|
|
|
}
|
|
|
|
|
if(shapes1[0] === 'wave' && shapes1[1] === 'oval'){
|
|
|
|
|
shapes2.splice(0,1,'diamond');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(numbers1[0] === numbers1[1]){
|
|
|
|
|
numbers2.splice(0,1,numbers1[0]);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if(numbers1[0] === 1 && numbers1[1] === 2){
|
|
|
|
|
numbers2.splice(0,1,3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(numbers1[0] === 1 && numbers1[1] === 3){
|
|
|
|
|
numbers2.splice(0,1,2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(numbers1[0] === 2 && numbers1[1] === 1){
|
|
|
|
|
numbers2.splice(0,1,3);
|
|
|
|
|
}
|
|
|
|
|
if(numbers1[0] === 2 && numbers1[1] === 3){
|
|
|
|
|
numbers2.splice(0,1,1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(numbers1[0] === 3 && numbers1[1] === 1){
|
|
|
|
|
numbers2.splice(0,1,2);
|
|
|
|
|
}
|
|
|
|
|
if(numbers1[0] === 3 && numbers1[1] === 2){
|
|
|
|
|
numbers2.splice(0,1,1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (a = j+1; a<this.cards0.length; a++) {
|
|
|
|
|
if (shapes2[0] === shapesall[a] ) {
|
|
|
|
|
if(colors2[0] === colorsall[a]){
|
|
|
|
|
if(numbers2[0] === numbersall[a]){
|
|
|
|
|
self.set0 = self.set0+1;
|
|
|
|
|
console.log(shapes2,colors2,numbers2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.$nbSets0.html(self.set0);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
existingSet1: function() {
|
|
|
|
|
var colors1 = [];
|
|
|
|
|
var shapes1 =[];
|
|
|
|
|
var fills1= [];
|
|
|
|
|
var borders1= [];
|
|
|
|
|
var numbers1= [];
|
|
|
|
|
var self = this;
|
|
|
|
|
var cartes = self.cards1;
|
|
|
|
|
var cartes1 = cartes;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var carte1;
|
|
|
|
|
var carte2;
|
|
|
|
|
|
|
|
|
|
var colors2 = [];
|
|
|
|
|
var shapes2 =[];
|
|
|
|
|
var fills2= [];
|
|
|
|
|
var borders2 = [];
|
|
|
|
|
var numbers2= [];
|
|
|
|
|
var i, j, a;
|
|
|
|
|
|
|
|
|
|
var colorsall= $.map(this.cards1, function(el) { return el.color;});
|
|
|
|
|
var shapesall = $.map(this.cards1, function(el) { return el.shape; });
|
|
|
|
|
var fillsall= $.map(this.cards1,function(el) { return el.fill; });
|
|
|
|
|
var bordersall= $.map(this.cards1,function(el) { return el.border; });
|
|
|
|
|
var numbersall = $.map(this.cards1, function(el) { return el.number;});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(i=0; i<cartes.length; i++) {
|
|
|
|
|
for (j = i+1; j < cartes1.length; j++) {
|
|
|
|
|
|
|
|
|
|
carte1 = cartes[i];
|
|
|
|
|
carte2 = cartes1[j];
|
|
|
|
|
|
|
|
|
|
colors1.splice(0,1,carte1.color);
|
|
|
|
|
colors1.splice(1,1,carte2.color);
|
|
|
|
|
|
|
|
|
|
shapes1.splice(0,1,carte1.shape);
|
|
|
|
|
shapes1.splice(1,1,carte2.shape);
|
|
|
|
|
|
|
|
|
|
fills1.splice(0,1,carte1.fill);
|
|
|
|
|
fills1.splice(1,1,carte2.fill);
|
|
|
|
|
|
|
|
|
|
borders1.splice(0,1,carte1.border);
|
|
|
|
|
borders1.splice(1,1,carte2.border);
|
|
|
|
|
|
|
|
|
|
numbers1.splice(0,1,carte1.number);
|
|
|
|
|
numbers1.splice(1,1,carte2.number);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(colors1[0] === colors1 [1]){
|
|
|
|
|
colors2.splice(0,1,colors1[0]);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if(colors1[0] === 'red' && colors1[1] === 'green'){
|
|
|
|
|
colors2.splice(0,1,'purple');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(colors1[0] === 'red' && colors1[1] === 'purple'){
|
|
|
|
|
colors2.splice(0,1,'green');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(colors1[0] === 'green' && colors1[1] === 'purple'){
|
|
|
|
|
colors2.splice(0,1,'red');
|
|
|
|
|
}
|
|
|
|
|
if(colors1[0] === 'green' && colors1[1] === 'red'){
|
|
|
|
|
colors2.splice(0,1,'purple');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(colors1[0] === 'purple' && colors1[1] === 'red'){
|
|
|
|
|
colors2.splice(0,1,'green');
|
|
|
|
|
}
|
|
|
|
|
if(colors1[0] === 'purple' && colors1[1] === 'green'){
|
|
|
|
|
colors2.splice(0,1,'red');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(shapes1[0] === shapes1 [1]){
|
|
|
|
|
shapes2.splice(0,1,shapes1[0]);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if(shapes1[0] === 'oval' && shapes1[1] === 'diamond'){
|
|
|
|
|
shapes2.splice(0,1,'wave');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(shapes1[0] === 'oval' && shapes1[1] === 'wave'){
|
|
|
|
|
shapes2.splice(0,1,'diamond');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(shapes1[0] === 'diamond' && shapes1[1] === 'oval'){
|
|
|
|
|
shapes2.splice(0,1,'wave');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(shapes1[0] === 'diamond' && shapes1[1] === 'wave'){
|
|
|
|
|
shapes2.splice(0,1,'oval');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(shapes1[0] === 'wave' && shapes1[1] === 'diamond'){
|
|
|
|
|
shapes2.splice(0,1,'oval');
|
|
|
|
|
}
|
|
|
|
|
if(shapes1[0] === 'wave' && shapes1[1] === 'oval'){
|
|
|
|
|
shapes2.splice(0,1,'diamond');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(fills1[0] === fills1 [1]){
|
|
|
|
|
fills2.splice(0,1,fills1[0]);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if(fills1[0] === 'solid' && fills1[1] === 'stripped'){
|
|
|
|
|
fills2.splice(0,1,'open');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(fills1[0] === 'solid' && fills1[1] === 'open'){
|
|
|
|
|
fills2.splice(0,1,'stripped');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(fills1[0] === 'stripped' && fills1[1] === 'open'){
|
|
|
|
|
fills2.splice(0,1,'solid');
|
|
|
|
|
}
|
|
|
|
|
if(fills1[0] === 'open' && fills1[1] === 'stripped'){
|
|
|
|
|
fills2.splice(0,1,'solid');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(fills1[0] === 'stripped' && fills1[1] === 'solid'){
|
|
|
|
|
fills2.splice(0,1,'open');
|
|
|
|
|
}
|
|
|
|
|
if(fills1[0] === 'open' && fills1[1] === 'solid'){
|
|
|
|
|
fills2.splice(0,1,'stripped');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(borders1[0] === borders1 [1]){
|
|
|
|
|
borders2.splice(0,1,borders1[0]);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if(borders1[0] === 'plein' && borders1[1] === 'point'){
|
|
|
|
|
borders2.splice(0,1,'rond');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(borders1[0] === 'point' && borders1[1] === 'plein'){
|
|
|
|
|
borders2.splice(0,1,'rond');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(borders1[0] === 'rond' && borders1[1] === 'plein'){
|
|
|
|
|
borders2.splice(0,1,'point');
|
|
|
|
|
}
|
|
|
|
|
if(borders1[0] === 'plein' && borders1[1] === 'rond'){
|
|
|
|
|
borders2.splice(0,1,'point');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(borders1[0] === 'rond' && borders1[1] === 'point'){
|
|
|
|
|
borders2.splice(0,1,'plein');
|
|
|
|
|
}
|
|
|
|
|
if(borders1[0] === 'point' && borders1[1] === 'rond'){
|
|
|
|
|
borders2.splice(0,1,'plein');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(numbers1[0] === numbers1[1]){
|
|
|
|
|
numbers2.splice(0,1,numbers1[0]);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
if(numbers1[0] === 1 && numbers1[1] === 2){
|
|
|
|
|
numbers2.splice(0,1,3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(numbers1[0] === 1 && numbers1[1] === 3){
|
|
|
|
|
numbers2.splice(0,1,2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(numbers1[0] === 2 && numbers1[1] === 1){
|
|
|
|
|
numbers2.splice(0,1,3);
|
|
|
|
|
}
|
|
|
|
|
if(numbers1[0] === 2 && numbers1[1] === 3){
|
|
|
|
|
numbers2.splice(0,1,1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(numbers1[0] === 3 && numbers1[1] === 1){
|
|
|
|
|
numbers2.splice(0,1,2);
|
|
|
|
|
}
|
|
|
|
|
if(numbers1[0] === 3 && numbers1[1] === 2){
|
|
|
|
|
numbers2.splice(0,1,1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (a = j+1; a<this.cards1.length; a++) {
|
|
|
|
|
if (shapes2[0] === shapesall[a] ) {
|
|
|
|
|
if(colors2[0] === colorsall[a]){
|
|
|
|
|
if(fills2[0] === fillsall[a]) {
|
|
|
|
|
if(borders2[0] === bordersall[a]) {
|
|
|
|
|
if (numbers2[0] === numbersall[a]) {
|
|
|
|
|
self.set1 = self.set1 + 1;
|
|
|
|
|
//console.log(shapes2, colors2, fills2, borders2, numbers2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.$nbSets1.html(self.set1);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|