diff --git a/HyperSet/.idea/workspace.xml b/HyperSet/.idea/workspace.xml index fe91f5e..a8112a4 100644 --- a/HyperSet/.idea/workspace.xml +++ b/HyperSet/.idea/workspace.xml @@ -144,6 +144,8 @@ + + @@ -187,10 +189,10 @@ - + - + diff --git a/HyperSet/set.php b/HyperSet/set.php index bcd535f..897ff20 100644 --- a/HyperSet/set.php +++ b/HyperSet/set.php @@ -74,7 +74,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'deal') { $_SESSION['deckHS4'] = new Deck($_GET['action']); $_SESSION['gameHS4'] = new Game($_SESSION['deckHS4']); $game = $_SESSION['gameHS4']; - echo json_encode($game->start(54)); + echo json_encode($game->start(40)); } diff --git a/HyperSet/vues/js/set.js b/HyperSet/vues/js/set.js index f899d69..f9da672 100644 --- a/HyperSet/vues/js/set.js +++ b/HyperSet/vues/js/set.js @@ -1340,6 +1340,7 @@ var Game = { var carte1, carte3, carte4; var carte2; var card4 = []; + var card5 ; var tCards = []; @@ -1354,74 +1355,102 @@ var Game = { for(i=0; i < cartes.length-3; i++) { for (j = i + 1; j < cartes1.length - 2; j++) { - for (k = j + 1; k < cartes2.length-1; k++) { - for (l = k + 1; l < cartes2.length; l++) { + for (k = j + 1; k < cartes2.length - 1; k++) { - carte1 = cartes[i]; - carte2 = cartes1[j]; - carte3 = cartes2[k]; - carte4 = cartes3[l]; + carte1 = cartes[i]; + carte2 = cartes1[j]; + carte3 = cartes2[k]; + + tCards[0] = carte1; + tCards[1] = carte2; + tCards[2] = carte3; - tCards[0] = carte1; - tCards[1] = carte2; - tCards[2] = carte3; - tCards[3] = carte4; + colors1.splice(0, 1, carte1.color); + colors1.splice(1, 1, carte2.color); + colors1.splice(2, 1, carte3.color); + shapes1.splice(0, 1, carte1.shape); + shapes1.splice(1, 1, carte2.shape); + shapes1.splice(2, 1, carte3.shape); + fills1.splice(0, 1, carte1.fill); + fills1.splice(1, 1, carte2.fill); + fills1.splice(2, 1, carte3.fill); - card4 = this.generateVirtualCard55(tCards); + borders1.splice(0, 1, carte1.border); + borders1.splice(1, 1, carte2.border); + borders1.splice(2, 1, carte3.border); - colors1.splice(0, 1, carte1.color); - colors1.splice(1, 1, carte2.color); - colors1.splice(2, 1, carte3.color); - colors1.splice(3, 1, card4[0].color); - colors1.splice(4, 1, carte4.color); + numbers1.splice(0, 1, carte1.number); + numbers1.splice(1, 1, carte2.number); + numbers1.splice(2, 1, carte3.number); - shapes1.splice(0, 1, carte1.shape); - shapes1.splice(1, 1, carte2.shape); - shapes1.splice(2, 1, carte3.shape); - shapes1.splice(3, 1, card4[0].shape); - shapes1.splice(4, 1, carte4.shape); + card4 = self.generer16Cartes55(colors1, shapes1, fills1, borders1, numbers1, this.cards4); + if (card4 !== undefined) { + if (card4.length > 0) { + for ( l = 0; l < card4.length; l++) { - fills1.splice(0, 1, carte1.fill); - fills1.splice(1, 1, carte2.fill); - fills1.splice(2, 1, carte3.fill); - fills1.splice(3, 1, card4[0].fill); - fills1.splice(4, 1, carte4.fill); + tCards[0] = carte1; + tCards[1] = carte2; + tCards[2] = carte3; + tCards[3] = card4[l][0]; + card5 = this.generateVirtualCard55(tCards); - borders1.splice(0, 1, carte1.border); - borders1.splice(1, 1, carte2.border); - borders1.splice(2, 1, carte3.border); - borders1.splice(3, 1, card4[0].border); - borders1.splice(4, 1, carte4.border); + colors1.splice(0, 1, carte1.color); + colors1.splice(1, 1, carte2.color); + colors1.splice(2, 1, carte3.color); + colors1.splice(3, 1, card4[l][0].color); + colors1.splice(4, 1, card5[0].color); - numbers1.splice(0, 1, carte1.number); - numbers1.splice(1, 1, carte2.number); - numbers1.splice(2, 1, carte3.number); - numbers1.splice(3, 1, card4[0].number); - numbers1.splice(4, 1, carte4.number); + shapes1.splice(0, 1, carte1.shape); + shapes1.splice(1, 1, carte2.shape); + shapes1.splice(2, 1, carte3.shape); + shapes1.splice(3, 1, card4[l][0].shape); + shapes1.splice(4, 1, card5[0].shape); + fills1.splice(0, 1, carte1.fill); + fills1.splice(1, 1, carte2.fill); + fills1.splice(2, 1, carte3.fill); + fills1.splice(3, 1, card4[l][0].fill); + fills1.splice(4, 1, card5[0].fill); - //if(this.cardInListOfCards44(shapes1[3],colors1[3],fills1[3],numbers1[3] )){} - for (a = l + 1; a < self.cards4.length; a++) { - if (shapes1[3] !== undefined && colors1[3] !== undefined && fills1[3] !== undefined && borders1[3] !== undefined && numbers1[3] !== undefined) { - if (shapes1[3] === shapesall[a] && colors1[3] === colorsall[a] && fills1[3] === fillsall[a] && borders1[3] === bordersall[a] && numbers1[3] === numbersall[a]) { - if (this.isSet5(shapes1) && this.isSet5(colors1) && this.isSet5(fills1) && this.isSet5(borders1) && this.isSet5(numbers1)) { - console.log('Set 5x5 : '); - console.log(shapes1, colors1, fills1, borders1, numbers1); - self.set4 = self.set4 + 1; - } + borders1.splice(0, 1, carte1.border); + borders1.splice(1, 1, carte2.border); + borders1.splice(2, 1, carte3.border); + borders1.splice(3, 1, card4[l][0].border); + borders1.splice(4, 1, card5[0].border); + + numbers1.splice(0, 1, carte1.number); + numbers1.splice(1, 1, carte2.number); + numbers1.splice(2, 1, carte3.number); + numbers1.splice(3, 1, card4[l][0].number); + numbers1.splice(4, 1, card5[0].number); + + //if(this.cardInListOfCards44(shapes1[3],colors1[3],fills1[3],numbers1[3] )){} + + + for (a = j + 1; a < self.cards4.length; a++) { + if (shapes1[3] !== undefined && colors1[3] !== undefined && fills1[3] !== undefined && borders1[3] !== undefined && numbers1[3] !== undefined) { + if (shapes1[4] === shapesall[a] && colors1[4] === colorsall[a] && fills1[4] === fillsall[a] && borders1[4] === bordersall[a] && numbers1[4] === numbersall[a]) { + if (this.isSet5(shapes1) && this.isSet5(colors1) && this.isSet5(fills1) && this.isSet5(borders1) && this.isSet5(numbers1)) { + console.log('Set 5x5 : '); + console.log(shapes1, colors1, fills1, borders1, numbers1); + self.set4 = self.set4 + 1; + } + + } + } } } } @@ -3201,11 +3230,11 @@ var Game = { } if (fillsSet.has('solid') && fillsSet.has('stripped')) { fills1.push('quadrillage'); - fills2.push('stripped'); + fills2.push('open'); } if (fillsSet.has('open') && fillsSet.has('quadrillage')) { fills1.push('solid'); - fills2.push('wave'); + fills2.push('stripped'); } if (fillsSet.has('open') && fillsSet.has('stripped')) { fills1.push('solid'); @@ -3573,7 +3602,7 @@ var Game = { possibleCards[i] = card22; i = i + 1; } - + } if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers1[0] === numbersall[a]) { if (shapes2[0] !== undefined && fills2[0] !== undefined && borders2[0] !== undefined) { @@ -3589,7 +3618,7 @@ var Game = { } } - } + if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers2[0] === numbersall[a]) { if (shapes2[0] !== undefined && fills2[0] !== undefined && numbers2[0] !== undefined) { card24.push({ @@ -4019,145 +4048,915 @@ var Game = { }, - - existingHyperSet4: function() { + generer16Cartes55: function(colors, shapes, fills, borders, numbers, allCards) { + var i = 0; + var possibleCards = []; var colors1 = []; - var shapes1 =[]; - var fills1= []; - var borders1 =[]; - var numbers1= []; + var shapes1 = []; + var fills1 = []; + var borders1 = []; + var numbers1 = []; var colors2 = []; - var shapes2 =[]; - var fills2= []; - var borders2 =[]; - var numbers2= []; + var shapes2 = []; + var fills2 = []; + var borders2 = []; + var numbers2 = []; + var card1 = []; + var card2 = []; + var card3 = []; + var card4 = []; + var card5 = []; + var card6 = []; + var card7 = []; + var card8 = []; + var card9 = []; + var card10 = []; + var card11 = []; + var card12 = []; + var card13 = []; + var card14 = []; + var card15 = []; + var card16 = []; + var card17 = []; + var card18 = []; + var card19 = []; + var card20 = []; + var card21 = []; + var card22 = []; + var card23 = []; + var card24 = []; + var card25 = []; + var card26 = []; + var card27 = []; + var card28 = []; + var card29 = []; + var card30 = []; + var card31 = []; + var card32 = []; - var self = this; - var cartes = self.cardsHS4; - var cartes1 = cartes; - var cartes2 = cartes; - var carte1, carte5, carte8 =[]; - var carte2; - var cardVirtualABC = []; - var tCardsABC = []; + var colorsall = $.map(allCards, function (el) { + return el.color; + }); + var shapesall = $.map(allCards, function (el) { + return el.shape; + }); + var fillsall = $.map(allCards, function (el) { + return el.fill; + }); + var bordersall = $.map(allCards, function (el) { + return el.border; + }); + var numbersall = $.map(allCards, function (el) { + return el.number; + }); - var tCardsDGE = []; - var pCards = []; - var pCards2 = []; + var colorsSet = new Set(colors); + var shapesSet = new Set(shapes); + var fillsSet = new Set(fills); + var bordersSet = new Set(borders); + var numbersSet = new Set(numbers); - var i, j, a, k ,z; + if (colors[0] === colors[1]) { + colors1.push(colors[1]); + } else { + if (colorsSet.has('green') && colorsSet.has('red') && colorsSet.has('yellow')) { + colors1.push('purple'); + colors2.push('lightblue'); + } + if (colorsSet.has('green') && colorsSet.has('purple') && colorsSet.has('yellow')) { + colors1.push('red'); + colors2.push('lightblue'); + } + if (colorsSet.has('green') && colorsSet.has('lightblue') && colorsSet.has('yellow')) { + colors1.push('red'); + colors2.push('purple'); + } + if (colorsSet.has('red') && colorsSet.has('purple') && colorsSet.has('yellow')) { + colors1.push('green'); + colors2.push('lightblue'); + } + if (colorsSet.has('red') && colorsSet.has('lightblue') && colorsSet.has('yellow')) { + colors1.push('green'); + colors2.push('purple'); + } + if (colorsSet.has('purple') && colorsSet.has('lightblue') && colorsSet.has('yellow')) { + colors1.push('green'); + colors2.push('red'); + } + if (colorsSet.has('red') && colorsSet.has('purple') && colorsSet.has('lightblue')) { + colors1.push('green'); + colors2.push('yellow'); + } + if (colorsSet.has('red') && colorsSet.has('lightblue') && colorsSet.has('green')) { + colors1.push('yellow'); + colors2.push('purple'); + } + if (colorsSet.has('red') && colorsSet.has('purple') && colorsSet.has('green')) { + colors1.push('yellow'); + colors2.push('lightblue'); + } + if (colorsSet.has('purple') && colorsSet.has('lightblue') && colorsSet.has('green')) { + colors1.push('yellow'); + colors2.push('red'); + } + } + if (shapes[0] === shapes[1]) { + shapes1.push(shapes[1]); + } else { + if (shapesSet.has('oval') && shapesSet.has('diamond') && shapesSet.has('triangle')) { + shapes1.push('rectangle'); + shapes2.push('wave'); + } + if (shapesSet.has('oval') && shapesSet.has('rectangle') && shapesSet.has('triangle')) { + shapes1.push('diamond'); + shapes2.push('wave'); + } + if (shapesSet.has('oval') && shapesSet.has('wave') && shapesSet.has('triangle')) { + shapes1.push('diamond'); + shapes2.push('rectangle'); + } + if (shapesSet.has('diamond') && shapesSet.has('rectangle') && shapesSet.has('triangle')) { + shapes1.push('oval'); + shapes2.push('wave'); + } + if (shapesSet.has('diamond') && shapesSet.has('wave') && shapesSet.has('triangle')) { + shapes1.push('oval'); + shapes2.push('rectangle'); + } + if (shapesSet.has('rectangle') && shapesSet.has('wave') && shapesSet.has('triangle')) { + shapes1.push('diamond'); + shapes2.push('oval'); + } + if (shapesSet.has('oval') && shapesSet.has('wave') && shapesSet.has('rectangle')) { + shapes1.push('diamond'); + shapes2.push('triangle'); + } + if (shapesSet.has('oval') && shapesSet.has('rectangle') && shapesSet.has('diamond')) { + shapes1.push('triangle'); + shapes2.push('wave'); + } + if (shapesSet.has('diamond') && shapesSet.has('wave') && shapesSet.has('rectangle')) { + shapes1.push('oval'); + shapes2.push('triangle'); + } + if (shapesSet.has('wave') && shapesSet.has('oval') && shapesSet.has('diamond')) { + shapes1.push('triangle'); + shapes2.push('rectangle'); + } + } - var colorsall= $.map(this.cardsHS4, function(el) { return el.color;}); - var shapesall = $.map(this.cardsHS4, function(el) { return el.shape; }); - var fillsall= $.map(this.cardsHS4,function(el) { return el.fill; }); - var bordersall= $.map(this.cardsHS4,function(el) { return el.border; }); - var numbersall = $.map(this.cardsHS4, function(el) { return el.number;}); + if (fills[0] === fills[1]) { + fills1.push(fills[1]); + } else { + if (fillsSet.has('solid') && fillsSet.has('open') && fillsSet.has('pointille')) { + fills1.push('quadrillage'); + fills2.push('stripped'); + } + if (fillsSet.has('solid') && fillsSet.has('quadrillage') && fillsSet.has('pointille')) { + fills1.push('open'); + fills2.push('stripped'); + } + if (fillsSet.has('solid') && fillsSet.has('stripped') && fillsSet.has('pointille')) { + fills1.push('quadrillage'); + fills2.push('open'); + } + if (fillsSet.has('open') && fillsSet.has('quadrillage') && fillsSet.has('pointille')) { + fills1.push('solid'); + fills2.push('stripped'); + } + if (fillsSet.has('open') && fillsSet.has('stripped') && fillsSet.has('pointille')) { + fills1.push('solid'); + fills2.push('quadrillage'); + } + if (fillsSet.has('stripped') && fillsSet.has('quadrillage') && fillsSet.has('pointille')) { + fills1.push('solid'); + fills2.push('open'); + } - for(i=0; i < cartes.length-2; i++) { - for (j = i + 1; j < cartes1.length - 1; j++) { - for (k = j + 1; k < cartes2.length; k++) { + if (fillsSet.has('solid') && fillsSet.has('stripped') && fillsSet.has('open')) { + fills1.push('quadrillage'); + fills2.push('pointille'); + } + if (fillsSet.has('open') && fillsSet.has('quadrillage') && fillsSet.has('stripped')) { + fills1.push('solid'); + fills2.push('pointille'); + } + if (fillsSet.has('open') && fillsSet.has('quadrillage') && fillsSet.has('solid')) { + fills1.push('stripped'); + fills2.push('pointille'); + } + if (fillsSet.has('stripped') && fillsSet.has('quadrillage') && fillsSet.has('solid')) { + fills1.push('pointille'); + fills2.push('open'); + } + } - carte1 = cartes[i]; - carte2 = cartes1[j]; - carte5 = cartes2[k]; + if (borders[0] === borders[1]) { + borders1.push(borders[1]); + } else { + if (bordersSet.has('plein') && bordersSet.has('point') && bordersSet.has('hachure')) { + borders1.push('rond'); + borders2.push('zigzag'); + } + if (bordersSet.has('plein') && bordersSet.has('rond') && bordersSet.has('hachure')) { + borders1.push('point'); + borders2.push('zigzag'); + } + if (bordersSet.has('plein') && bordersSet.has('zigzag') && bordersSet.has('hachure')) { + borders1.push('point'); + borders2.push('rond'); + } + if (bordersSet.has('point') && bordersSet.has('rond') && bordersSet.has('hachure')) { + borders1.push('plein'); + borders2.push('zigzag'); + } + if (bordersSet.has('point') && bordersSet.has('zigzag') && bordersSet.has('hachure')) { + borders1.push('plein'); + borders2.push('rond'); + } + if (bordersSet.has('rond') && bordersSet.has('zigzag') && bordersSet.has('hachure')) { + borders1.push('plein'); + borders2.push('point'); + } - colors1.splice(0, 1, carte1.color); - colors1.splice(1, 1, carte2.color); - shapes1.splice(0, 1, carte1.shape); - shapes1.splice(1, 1, carte2.shape); + if (bordersSet.has('plein') && bordersSet.has('zigzag') && bordersSet.has('point')) { + borders1.push('hachure'); + borders2.push('rond'); + } + if (bordersSet.has('point') && bordersSet.has('rond') && bordersSet.has('plein')) { + borders1.push('hachure'); + borders2.push('zigzag'); + } + if (bordersSet.has('point') && bordersSet.has('zigzag') && bordersSet.has('rond')) { + borders1.push('plein'); + borders2.push('hachure'); + } + if (bordersSet.has('rond') && bordersSet.has('zigzag') && bordersSet.has('plein')) { + borders1.push('hachure'); + borders2.push('point'); + } + } - 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 (numbers[0] === numbers[1]) { + numbers1.push(numbers[1]); + } else { + if (numbersSet.has(1) && numbersSet.has(2) && numbersSet.has(5)) { + numbers1.push(3); + numbers2.push(4); + } + if (numbersSet.has(1) && numbersSet.has(3) && numbersSet.has(5)) { + numbers1.push(2); + numbers2.push(4); + } + if (numbersSet.has(1) && numbersSet.has(4) && numbersSet.has(5)) { + numbers1.push(2); + numbers2.push(3); + } + if (numbersSet.has(2) && numbersSet.has(3) && numbersSet.has(5)) { + numbers1.push(1); + numbers2.push(4); + } + if (numbersSet.has(2) && numbersSet.has(4) && numbersSet.has(5)) { + numbers1.push(1); + numbers2.push(3); + } + if (numbersSet.has(3) && numbersSet.has(4) && numbersSet.has(5)) { + numbers1.push(1); + numbers2.push(2); + } - pCards = self.generer16Cartes5(colors1, shapes1, fills1, borders1, numbers1, this.cardsHS4); + if (numbersSet.has(1) && numbersSet.has(4) && numbersSet.has(3)) { + numbers1.push(2); + numbers2.push(5); + } + if (numbersSet.has(2) && numbersSet.has(3) && numbersSet.has(1)) { + numbers1.push(5); + numbers2.push(4); + } + if (numbersSet.has(2) && numbersSet.has(4) && numbersSet.has(1)) { + numbers1.push(5); + numbers2.push(3); + } + if (numbersSet.has(3) && numbersSet.has(4) && numbersSet.has(2)) { + numbers1.push(1); + numbers2.push(5); + } + } - if (pCards.length > 0) { - for (z = 0; z < pCards.length; z++) { - tCardsABC[0] = carte1; - tCardsABC[1] = carte2; - tCardsABC[2] = pCards[z][0]; + if(shapes1[0] === undefined && colors1[0] === undefined && fills1[0] === undefined && borders1[0] === undefined && numbers1[0] === undefined) { + return undefined; + }else{ + for (var a = 0; a < allCards.length; a++) { + if (shapes1[0] === shapesall[a] && colors1[0] === colorsall[a] && fills1[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + card1.push({ + color: colors1[0], + shape: shapes1[0], + fill: fills1[0], + border: borders1[0], + number: numbers1[0] + }); + possibleCards[i] = card1; + i = i + 1; + } + if (shapes1[0] === shapesall[a] && colors2[0] === colorsall[a] && fills1[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (colors2[0] !== undefined) { + card2.push({ + color: colors2[0], + shape: shapes1[0], + fill: fills1[0], + border: borders1[0], + number: numbers1[0] + }); + possibleCards[i] = card2; + i = i + 1; + } + } + if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills1[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (shapes2[0] !== undefined) { + card3.push({ + color: colors1[0], + shape: shapes2[0], + fill: fills1[0], + border: borders1[0], + number: numbers1[0] + }); + possibleCards[i] = card3; + i = i + 1; + } + } + if (shapes1[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (fills2[0] !== undefined) { + card4.push({ + color: colors1[0], + shape: shapes1[0], + fill: fills2[0], + border: borders1[0], + number: numbers1[0] + }); + possibleCards[i] = card4; + i = i + 1; + } + } + if (shapes1[0] === shapesall[a] && colors1[0] === colorsall[a] && fills1[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (borders2[0] !== undefined) { + card5.push({ + color: colors1[0], + shape: shapes1[0], + fill: fills1[0], + border: borders2[0], + number: numbers1[0] + }); + possibleCards[i] = card5; + i = i + 1; + } + } + if (shapes1[0] === shapesall[a] && colors1[0] === colorsall[a] && fills1[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (numbers2[0] !== undefined) { + card6.push({ + color: colors1[0], + shape: shapes1[0], + fill: fills1[0], + border: borders1[0], + number: numbers2[0] + }); + possibleCards[i] = card6; + i = i + 1; + } + } - tCardsABC[3] = this.generateVirtualCard45(tCardsABC); - cardVirtualABC[z] = this.generateVirtualCard55(tCardsABC); + if (shapes1[0] === shapesall[a] && colors1[0] === colorsall[a] && fills1[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (borders2[0] !== undefined && numbers2[0] !== undefined) { + card7.push({ + color: colors1[0], + shape: shapes1[0], + fill: fills1[0], + border: borders2[0], + number: numbers2[0] + }); + possibleCards[i] = card7; + i = i + 1; + } + } + if (shapes1[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (fills2[0] !== undefined && numbers2[0] !== undefined) { + card8.push({ + color: colors1[0], + shape: shapes1[0], + fill: fills2[0], + border: borders1[0], + number: numbers2[0] + }); + possibleCards[i] = card8; + i = i + 1; + } + } + if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills1[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (shapes2[0] !== undefined && numbers2[0] !== undefined) { + card9.push({ + color: colors1[0], + shape: shapes2[0], + fill: fills1[0], + border: borders1[0], + number: numbers2[0] + }); + possibleCards[i] = card9; + i = i + 1; + } + } + if (shapes1[0] === shapesall[a] && colors2[0] === colorsall[a] && fills1[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (colors2[0] !== undefined && numbers2[0] !== undefined) { + card10.push({ + color: colors2[0], + shape: shapes1[0], + fill: fills1[0], + border: borders1[0], + number: numbers2[0] + }); + possibleCards[i] = card10; + i = i + 1; + } + } + if (shapes1[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (fills2[0] !== undefined && borders2[0] !== undefined) { + card11.push({ + color: colors1[0], + shape: shapes1[0], + fill: fills2[0], + border: borders2[0], + number: numbers1[0] + }); + possibleCards[i] = card11; + i = i + 1; + } + } + if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills1[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (shapes2[0] !== undefined && borders2[0] !== undefined) { + card12.push({ + color: colors1[0], + shape: shapes2[0], + fill: fills1[0], + border: borders2[0], + number: numbers1[0] + }); + possibleCards[i] = card12; + i = i + 1; + } + } + if (shapes1[0] === shapesall[a] && colors2[0] === colorsall[a] && fills1[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (colors2[0] !== undefined && borders2[0] !== undefined) { + card13.push({ + color: colors2[0], + shape: shapes1[0], + fill: fills1[0], + border: borders2[0], + number: numbers1[0] + }); + possibleCards[i] = card13; + i = i + 1; + } + } - if (carte5.color !== tCardsABC[2].color && carte5.shape !== tCardsABC[2].shape && carte5.fill !== tCardsABC[2].fill && carte5.number !== tCardsABC[2].number && - carte5.color !== tCardsABC[3].color && carte5.shape !== tCardsABC[3].shape && carte5.fill !== tCardsABC[3].fill && carte5.number !== tCardsABC[3].number ) { - tCardsDGE[0] = carte5; - tCardsDGE[1] = cardVirtualABC[z][0]; - tCardsDGE[2] = []; + if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (shapes2[0] !== undefined && fills2[0] !== undefined) { + card14.push({ + color: colors1[0], + shape: shapes2[0], + fill: fills2[0], + border: borders1[0], + number: numbers1[0] + }); + possibleCards[i] = card14; + i = i + 1; + } + } + if (shapes1[0] === shapesall[a] && colors2[0] === colorsall[a] && fills2[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (fills2[0] !== undefined && colors2[0] !== undefined) { + card15.push({ + color: colors2[0], + shape: shapes1[0], + fill: fills2[0], + border: borders1[0], + number: numbers1[0] + }); + possibleCards[i] = card15; + i = i + 1; + } + } + if (shapes2[0] === shapesall[a] && colors2[0] === colorsall[a] && fills1[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (colors2[0] !== undefined && shapes2[0] !== undefined) { + card16.push({ + color: colors2[0], + shape: shapes2[0], + fill: fills1[0], + border: borders1[0], + number: numbers1[0] + }); + possibleCards[i] = card16; + i = i + 1; + } + } - colors2 = $.map(tCardsDGE, function (el) { - return el.color; - }); - shapes2 = $.map(tCardsDGE, function (el) { - return el.shape; - }); - fills2 = $.map(tCardsDGE, function (el) { - return el.fill; - }); - borders2 = $.map(tCardsDGE, function (el) { - return el.border; - }); - numbers2 = $.map(tCardsDGE, function (el) { - return el.number; - }); - pCards2 = self.generer16Cartes5(colors2, shapes2, fills2, borders2, numbers2, this.cardsHS4); + if (shapes2[0] === shapesall[a] && colors2[0] === colorsall[a] && fills2[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (colors2[0] !== undefined && shapes2[0] !== undefined && fills2[0] !== undefined) { + card17.push({ + color: colors2[0], + shape: shapes2[0], + fill: fills2[0], + border: borders1[0], + number: numbers1[0] + }); + possibleCards[i] = card17; + i = i + 1; + } + } + if (shapes2[0] === shapesall[a] && colors2[0] === colorsall[a] && fills1[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (colors2[0] !== undefined && shapes2[0] !== undefined && borders2[0] !== undefined) { + card18.push({ + color: colors2[0], + shape: shapes2[0], + fill: fills1[0], + border: borders2[0], + number: numbers1[0] + }); + possibleCards[i] = card18; + i = i + 1; + } + } - for (var w = 0; w < pCards2.length; w++) { - tCardsDGE[2] = pCards2[w][0]; - tCardsDGE[3] = this.generateVirtualCard45(tCardsDGE); - carte8[w] = this.generateVirtualCard55(tCardsDGE); - + if (shapes2[0] === shapesall[a] && colors2[0] === colorsall[a] && fills1[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (colors2[0] !== undefined && shapes2[0] !== undefined && numbers2[0] !== undefined) { + card19.push({ + color: colors2[0], + shape: shapes2[0], + fill: fills1[0], + border: borders1[0], + number: numbers2[0] + }); + possibleCards[i] = card19; + i = i + 1; + } + } + if (shapes1[0] === shapesall[a] && colors2[0] === colorsall[a] && fills2[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (colors2[0] !== undefined && fills2[0] !== undefined && borders2[0] !== undefined) { + card20.push({ + color: colors2[0], + shape: shapes1[0], + fill: fills2[0], + border: borders2[0], + number: numbers1[0] + }); + possibleCards[i] = card20; + i = i + 1; + } + } + if (shapes1[0] === shapesall[a] && colors2[0] === colorsall[a] && fills2[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (colors2[0] !== undefined && fills2[0] !== undefined && numbers2[0] !== undefined) { + card21.push({ + color: colors2[0], + shape: shapes1[0], + fill: fills2[0], + border: borders1[0], + number: numbers2[0] + }); + possibleCards[i] = card21; + i = i + 1; + } + } - } - } + if (shapes1[0] === shapesall[a] && colors2[0] === colorsall[a] && fills1[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (colors2[0] !== undefined && borders2[0] !== undefined && numbers2[0] !== undefined) { + card22.push({ + color: colors2[0], + shape: shapes1[0], + fill: fills1[0], + border: borders2[0], + number: numbers2[0] + }); + possibleCards[i] = card22; + i = i + 1; + } + } + if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (shapes2[0] !== undefined && fills2[0] !== undefined && borders2[0] !== undefined) { + card23.push({ + color: colors1[0], + shape: shapes2[0], + fill: fills2[0], + border: borders2[0], + number: numbers1[0] + }); + possibleCards[i] = card23; + i = i + 1; } + } + + if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (shapes2[0] !== undefined && fills2[0] !== undefined && numbers2[0] !== undefined) { + card24.push({ + color: colors1[0], + shape: shapes2[0], + fill: fills2[0], + border: borders1[0], + number: numbers2[0] + }); + possibleCards[i] = card24; + i = i + 1; + } + } + if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills1[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (shapes2[0] !== undefined && borders2[0] !== undefined && numbers2[0] !== undefined) { + card25.push({ + color: colors1[0], + shape: shapes2[0], + fill: fills1[0], + border: borders2[0], + number: numbers2[0] + }); + possibleCards[i] = card25; + i = i + 1; } + } + if (shapes1[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (fills2[0] !== undefined && borders2[0] !== undefined && numbers2[0] !== undefined) { + card26.push({ + color: colors1[0], + shape: shapes1[0], + fill: fills2[0], + border: borders2[0], + number: numbers2[0] + }); + possibleCards[i] = card26; + i = i + 1; + } + } - for(var x=0; x< carte8.length; x++) { - for (a = k + 1; a < self.cardsHS4.length; a++) { - if (carte8[x][0].color !== undefined && carte8[x][0].shape !== undefined && carte8[x][0].fill !== undefined && carte8[x][0].border !== undefined && carte8[x][0].number !== undefined) { - if (carte8[x][0].shape === shapesall[a] && carte8[x][0].color === colorsall[a] && carte8[x][0].fill === fillsall[a] && carte8[x][0].border === bordersall[a] && carte8[x][0].number === numbersall[a]) { - //console.log('ab'); - //console.log(carte6[x][0].shape, carte6[x][0].color, carte6[x][0].fill, carte6[x][0].number); - //console.log(carte1); - //console.log(carte2); - self.setHS4 = self.setHS4 + 1; - } - } - } + if (shapes2[0] === shapesall[a] && colors2[0] === colorsall[a] && fills2[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (colors2[0] !== undefined && shapes2[0] !== undefined && fills2[0] !== undefined && borders2[0] !== undefined && numbers2[0] !== undefined) { + card27.push({ + color: colors2[0], + shape: shapes2[0], + fill: fills2[0], + border: borders2[0], + number: numbers2[0] + }); + possibleCards[i] = card27; + i = i + 1; } + } - carte8 = []; - pCards = []; - pCards2 = []; + + if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (shapes2[0] !== undefined && fills2[0] !== undefined && borders2[0] !== undefined && numbers2[0] !== undefined) { + card28.push({ + color: colors1[0], + shape: shapes2[0], + fill: fills2[0], + border: borders2[0], + number: numbers2[0] + }); + possibleCards[i] = card28; + i = i + 1; + } + } + + if (shapes1[0] === shapesall[a] && colors2[0] === colorsall[a] && fills2[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (colors2[0] !== undefined && borders2[0] !== undefined && fills2[0] !== undefined && numbers2[0] !== undefined) { + card29.push({ + color: colors2[0], + shape: shapes1[0], + fill: fills2[0], + border: borders2[0], + number: numbers2[0] + }); + possibleCards[i] = card29; + i = i + 1; + } + } + + if (shapes2[0] === shapesall[a] && colors2[0] === colorsall[a] && fills1[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (colors2[0] !== undefined && shapes2[0] !== undefined && borders2[0] !== undefined && numbers2[0] !== undefined) { + card30.push({ + color: colors2[0], + shape: shapes2[0], + fill: fills1[0], + border: borders2[0], + number: numbers2[0] + }); + possibleCards[i] = card30; + i = i + 1; + } + } + + if (shapes2[0] === shapesall[a] && colors2[0] === colorsall[a] && fills2[0] === fillsall[a] && borders1[0] === bordersall[a] && numbers2[0] === numbersall[a]) { + if (colors2[0] !== undefined && shapes2[0] !== undefined && fills2[0] !== undefined && numbers2[0] !== undefined) { + card31.push({ + color: colors2[0], + shape: shapes2[0], + fill: fills2[0], + border: borders1[0], + number: numbers2[0] + }); + possibleCards[i] = card31; + i = i + 1; + } + } + + if (shapes2[0] === shapesall[a] && colors2[0] === colorsall[a] && fills2[0] === fillsall[a] && borders2[0] === bordersall[a] && numbers1[0] === numbersall[a]) { + if (colors2[0] !== undefined && shapes2[0] !== undefined && fills2[0] !== undefined && borders2[0] !== undefined) { + card32.push({ + color: colors2[0], + shape: shapes2[0], + fill: fills2[0], + border: borders2[0], + number: numbers1[0] + }); + possibleCards[i] = card32; + i = i + 1; + } + } + } + } + return possibleCards; + }, + + + + + existingHyperSet4: function() { + var colors1 = []; + var shapes1 =[]; + var fills1= []; + var borders1 =[]; + var numbers1= []; + var colors2 = []; + var shapes2 =[]; + var fills2= []; + var borders2 =[]; + var numbers2= []; + + + var self = this; + var cartes = self.cardsHS4; + var cartes1 = cartes; + var cartes2 = cartes; + var cartes3 = cartes; + var cartes4 = cartes; + + var carte1, carte5, carte6, carte3, carte8 =[]; + var carte2; + + var cardVirtualABC = []; + + var tCardsABC = []; + + var tCardsDGE = []; + var pCards = []; + var pCards2 = []; + + var i, j, a, k ,z, l, m; + + var colorsall= $.map(this.cardsHS4, function(el) { return el.color;}); + var shapesall = $.map(this.cardsHS4, function(el) { return el.shape; }); + var fillsall= $.map(this.cardsHS4,function(el) { return el.fill; }); + var bordersall= $.map(this.cardsHS4,function(el) { return el.border; }); + var numbersall = $.map(this.cardsHS4, function(el) { return el.number;}); + + + for(i=0; i < cartes.length-2; i++) { + for (j = i + 1; j < cartes1.length - 1; j++) { + for (k = j + 1; k < cartes2.length; k++) { + for (l= k + 1; l < cartes3.length; l++) { + for (m = l+ 1; m < cartes4.length; m++) { + + + carte1 = cartes[i]; + carte2 = cartes1[j]; + carte3 = cartes2[k]; + + carte5 = cartes3[l]; + carte6 = cartes4[m]; + + + colors1.splice(0, 1, carte1.color); + colors1.splice(1, 1, carte2.color); + colors1.splice(2, 1, carte3.color); + + + shapes1.splice(0, 1, carte1.shape); + shapes1.splice(1, 1, carte2.shape); + shapes1.splice(2, 1, carte3.shape); + + + fills1.splice(0, 1, carte1.fill); + fills1.splice(1, 1, carte2.fill); + fills1.splice(2, 1, carte3.fill); + + + borders1.splice(0, 1, carte1.border); + borders1.splice(1, 1, carte2.border); + borders1.splice(2, 1, carte3.border); + + + numbers1.splice(0, 1, carte1.number); + numbers1.splice(1, 1, carte2.number); + numbers1.splice(2, 1, carte3.number); + pCards = self.generer16Cartes55(colors1, shapes1, fills1, borders1, numbers1, this.cardsHS4); + + if(pCards !== undefined) { + if (pCards.length > 0) { + + for (z = 0; z < pCards.length; z++) { + tCardsABC[0] = carte1; + tCardsABC[1] = carte2; + tCardsABC[2] = carte3; + tCardsABC[3] = pCards[z][0]; + + cardVirtualABC[z] = this.generateVirtualCard55(tCardsABC); + + + if (carte5.color !== tCardsABC[2].color && carte5.shape !== tCardsABC[2].shape && carte5.fill !== tCardsABC[2].fill && carte5.number !== tCardsABC[2].number && + carte5.color !== tCardsABC[3].color && carte5.shape !== tCardsABC[3].shape && carte5.fill !== tCardsABC[3].fill && carte5.number !== tCardsABC[3].number) { + + tCardsDGE[0] = carte5; + tCardsDGE[1] = carte6; + tCardsDGE[2] = cardVirtualABC[z][0]; + tCardsDGE[3] = []; + + + colors2 = $.map(tCardsDGE, function (el) { + return el.color; + }); + shapes2 = $.map(tCardsDGE, function (el) { + return el.shape; + }); + fills2 = $.map(tCardsDGE, function (el) { + return el.fill; + }); + borders2 = $.map(tCardsDGE, function (el) { + return el.border; + }); + numbers2 = $.map(tCardsDGE, function (el) { + return el.number; + }); + + pCards2 = self.generer16Cartes55(colors2, shapes2, fills2, borders2, numbers2, this.cardsHS4); + + if(pCards2 !== undefined) { + for (var w = 0; w < pCards2.length; w++) { + tCardsDGE[3] = pCards2[w][0]; + carte8[w] = this.generateVirtualCard55(tCardsDGE); + + } + } + } + + } + + } + + for (var x = 0; x < carte8.length; x++) { + for (a = k + 1; a < self.cardsHS4.length; a++) { + + if (carte8[x][0].color !== undefined && carte8[x][0].shape !== undefined && carte8[x][0].fill !== undefined && carte8[x][0].border !== undefined && carte8[x][0].number !== undefined) { + if (carte8[x][0].shape === shapesall[a] && carte8[x][0].color === colorsall[a] && carte8[x][0].fill === fillsall[a] && carte8[x][0].border === bordersall[a] && carte8[x][0].number === numbersall[a]) { + //console.log('ab'); + //console.log(carte6[x][0].shape, carte6[x][0].color, carte6[x][0].fill, carte6[x][0].number); + //console.log(carte1); + //console.log(carte2); + self.setHS4 = self.setHS4 + 1; + } + } + } + } + + carte8 = []; + pCards = []; + pCards2 = []; + } + } + } } } }