4x4 V2 compteur

master
readhame 5 years ago
parent e4a15a2e3d
commit 83fe43ce67

@ -138,6 +138,9 @@
<workItem from="1595502519582" duration="8852000" />
<workItem from="1595514911380" duration="1711000" />
<workItem from="1595527325944" duration="1234000" />
<workItem from="1595588432637" duration="9907000" />
<workItem from="1595599991194" duration="2000" />
<workItem from="1595606617252" duration="1336000" />
</task>
<servers />
</component>
@ -181,10 +184,10 @@
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state width="623" height="498" key="SwitcherDM/0.0.1920.1040@0.0.1920.1040" timestamp="1595243925469" />
<state x="1136" y="344" key="com.intellij.ide.util.TipDialog" timestamp="1595527689222">
<state x="1136" y="344" key="com.intellij.ide.util.TipDialog" timestamp="1595606628874">
<screen x="0" y="0" width="1920" height="1040" />
</state>
<state x="1136" y="344" key="com.intellij.ide.util.TipDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1595527689222" />
<state x="1136" y="344" key="com.intellij.ide.util.TipDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1595606628874" />
<state x="701" y="162" key="refactoring.ChangeSignatureDialog" timestamp="1593090265720">
<screen x="0" y="0" width="1920" height="1040" />
</state>

@ -344,7 +344,7 @@ var Game = {
dataType: 'json',
success: function (data) {
self.cardsHS2 = data;
self.existingHyperSet2();
// self.existingHyperSet2();
self.displayCardsHS2.call(self);
self.setCardListenersHS2();
}
@ -1306,8 +1306,8 @@ var Game = {
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.isSet4(shapes1) && this.isSet4(colors1) && this.isSet4(fills1) && this.isSet4(borders1) && this.isSet4(numbers1)) {
//console.log('Set 4x5 : ');
//console.log(shapes1, colors1, fills1, borders1, numbers1);
console.log('Set 4x5 : ');
console.log(shapes1, colors1, fills1, borders1, numbers1);
self.set3 = self.set3 + 1;
}
@ -1417,8 +1417,8 @@ var Game = {
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);
console.log('Set 5x5 : ');
console.log(shapes1, colors1, fills1, borders1, numbers1);
self.set4 = self.set4 + 1;
}
@ -2699,6 +2699,357 @@ var Game = {
this.$nbSetsHS2.html(self.setHS2);
},*/
testGeneration16Cartes: function(arr){
var unique = [];
$.each(arr, function(i, el){
if($.inArray(el, unique) === -1) unique.push(el);
});
return unique.length;
},
generer16Cartes: function(colors, shapes, fills, numbers, allCards){
var possibleCards = [];
var colors1 = [];
var shapes1 =[];
var fills1= [];
var numbers1= [];
var colors2 = [];
var shapes2 =[];
var fills2= [];
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 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 numbersall = $.map(allCards, function(el) { return el.number;});
var colorsSet = new Set(colors);
var shapesSet = new Set(shapes);
var fillsSet = new Set(fills);
var numbersSet = new Set(numbers);
if( colors[0] === colors[1]){
colors1.push(colors[1]);
}else {
if(colorsSet.has('green') && colorsSet.has('red') ){
colors1.push('purple');
colors2.push('lightblue');
}
if(colorsSet.has('green') && colorsSet.has('purple')){
colors1.push('red');
colors2.push('lightblue');
}
if(colorsSet.has('green') && colorsSet.has('lightblue')){
colors1.push('red');
colors2.push('purple');
}
if(colorsSet.has('red') && colorsSet.has('purple')){
colors1.push('green');
colors2.push('lightblue');
}
if(colorsSet.has('red') && colorsSet.has('lightblue')){
colors1.push('green');
colors2.push('purple');
}
if(colorsSet.has('purple') && colorsSet.has('lightblue')){
colors1.push('green');
colors2.push('red');
}
}
if( shapes[0] === shapes[1]){
shapes1.push(shapes[1]);
}else {
if(shapesSet.has('oval') && shapesSet.has('diamond') ){
shapes1.push('rectangle');
shapes2.push('wave');
}
if(shapesSet.has('oval') && shapesSet.has('rectangle')){
shapes1.push('diamond');
shapes2.push('wave');
}
if(shapesSet.has('oval') && shapesSet.has('wave')){
shapes1.push('diamond');
shapes2.push('rectangle');
}
if(shapesSet.has('diamond') && shapesSet.has('rectangle')){
shapes1.push('oval');
shapes2.push('wave');
}
if(shapesSet.has('diamond') && shapesSet.has('wave')){
shapes1.push('oval');
shapes2.push('rectangle');
}
if(shapesSet.has('rectangle') && shapesSet.has('wave')){
shapes1.push('diamond');
shapes2.push('oval');
}
}
if( fills[0] === fills[1]){
fills1.push(fills[1]);
}else {
if(fillsSet.has('solid') && fillsSet.has('open') ){
fills1.push('quadrillage');
fills2.push('stripped');
}
if(fillsSet.has('solid') && fillsSet.has('quadrillage')){
fills1.push('open');
fills2.push('stripped');
}
if(fillsSet.has('solid') && fillsSet.has('stripped')){
fills1.push('quadrillage');
fills2.push('stripped');
}
if(fillsSet.has('open') && fillsSet.has('quadrillage')){
fills1.push('solid');
fills2.push('wave');
}
if(fillsSet.has('open') && fillsSet.has('stripped')){
fills1.push('solid');
fills2.push('quadrillage');
}
if(fillsSet.has('stripped') && fillsSet.has('quadrillage')){
fills1.push('solid');
fills2.push('open');
}
}
if( numbers[0] === numbers[1]){
numbers1.push(numbers[1]);
}else {
if(numbersSet.has(1) && numbersSet.has(2) ){
numbers1.push(3);
numbers2.push(4);
}
if(numbersSet.has(1) && numbersSet.has(3)){
numbers1.push(2);
numbers2.push(4);
}
if(numbersSet.has(1) && numbersSet.has(4)){
numbers1.push(2);
numbers2.push(3);
}
if(numbersSet.has(2) && numbersSet.has(3)){
numbers1.push(1);
numbers2.push(4);
}
if(numbersSet.has(2) && numbersSet.has(4)){
numbers1.push(1);
numbers2.push(3);
}
if(numbersSet.has(3) && numbersSet.has(4)){
numbers1.push(1);
numbers2.push(2);
}
}
for (var a = 0 ; a < allCards.length; a++) {
if (shapes1[0] === shapesall[a] && colors1[0] === colorsall[a] && fills1[0] === fillsall[a] && numbers1[0] === numbersall[a]) {
card1.push({
color : colors1[0],
shape : shapes1[0],
fill : fills1[0],
number: numbers1[0]
});
possibleCards.push(card1);
}
if (shapes1[0] === shapesall[a] && colors2[0] === colorsall[a] && fills1[0] === fillsall[a] && numbers1[0] === numbersall[a]) {
if(colors2[0] !== undefined) {
card2.push({
color: colors2[0],
shape: shapes1[0],
fill: fills1[0],
number: numbers1[0]
});
possibleCards.push(card2);
}
}
if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills1[0] === fillsall[a] && numbers1[0] === numbersall[a]) {
if(shapes2[0] !== undefined) {
card3.push({
color: colors1[0],
shape: shapes2[0],
fill: fills1[0],
number: numbers1[0]
});
possibleCards.push(card3);
}
}
if (shapes1[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && numbers1[0] === numbersall[a]) {
if(fills2[0] !== undefined) {
card4.push({
color: colors1[0],
shape: shapes1[0],
fill: fills2[0],
number: numbers1[0]
});
possibleCards.push(card4);
}
}
if (shapes1[0] === shapesall[a] && colors1[0] === colorsall[a] && fills1[0] === fillsall[a] && numbers2[0] === numbersall[a]) {
if (numbers2[0] !== undefined) {
card5.push({
color: colors1[0],
shape: shapes1[0],
fill: fills1[0],
number: numbers2[0]
});
possibleCards.push(card5);
}
}
if (shapes1[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && numbers2[0] === numbersall[a]) {
if(fills2[0] !== undefined && numbers2[0] !== undefined) {
card6.push({
color: colors1[0],
shape: shapes1[0],
fill: fills2[0],
number: numbers2[0]
});
possibleCards.push(card6);
}
}
if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills1[0] === fillsall[a] && numbers2[0] === numbersall[a]) {
if(shapes2[0] !== undefined && numbers2[0] !== undefined) {
card7.push({
color: colors1[0],
shape: shapes2[0],
fill: fills1[0],
number: numbers2[0]
});
possibleCards.push(card7);
}
}
if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && numbers1[0] === numbersall[a]) {
if(fills2[0] !== undefined && shapes2[0] !== undefined ) {
card8.push({
color: colors1[0],
shape: shapes2[0],
fill: fills2[0],
number: numbers1[0]
});
possibleCards.push(card8);
}
}
if (shapes1[0] === shapesall[a] && colors2[0] === colorsall[a] && fills2[0] === fillsall[a] && numbers1[0] === numbersall[a]) {
if (colors2[0] !== undefined && fills2[0] !== undefined) {
card9.push({
color: colors2[0],
shape: shapes1[0],
fill: fills2[0],
number: numbers1[0]
});
possibleCards.push(card9);
}
}
if (shapes1[0] === shapesall[a] && colors2[0] === colorsall[a] && fills1[0] === fillsall[a] && numbers2[0] === numbersall[a]) {
if (colors2[0] !== undefined && numbers2[0] !== undefined) {
card10.push({
color: colors2[0],
shape: shapes1[0],
fill: fills1[0],
number: numbers2[0]
});
possibleCards.push(card10);
}
}
if (shapes2[0] === shapesall[a] && colors2[0] === colorsall[a] && fills1[0] === fillsall[a] && numbers1[0] === numbersall[a]) {
if (colors2[0] !== undefined && shapes2[0] !== undefined) {
card11.push({
color: colors2[0],
shape: shapes2[0],
fill: fills1[0],
number: numbers1[0]
});
possibleCards.push(card11);
}
}
if (shapes2[0] === shapesall[a] && colors2[0] === colorsall[a] && fills2[0] === fillsall[a] && numbers2[0] === numbersall[a]) {
if (colors2[0] !== undefined && shapes2[0] !== undefined && fills2[0] !== undefined && numbers2[0] !== undefined ) {
card12.push({
color: colors2[0],
shape: shapes2[0],
fill: fills2[0],
number: numbers2[0]
});
possibleCards.push(card12);
}
}
if (shapes2[0] === shapesall[a] && colors2[0] === colorsall[a] && fills2[0] === fillsall[a] && numbers1[0] === numbersall[a]) {
if(colors2[0] !== undefined && shapes2[0] !== undefined && fills2[0] !== undefined) {
card13.push({
color: colors2[0],
shape: shapes2[0],
fill: fills2[0],
number: numbers1[0]
});
possibleCards.push(card13);
}
}
if (shapes2[0] === shapesall[a] && colors2[0] === colorsall[a] && fills1[0] === fillsall[a] && numbers2[0] === numbersall[a]) {
if(colors2[0] !== undefined && shapes2[0] !== undefined && numbers2[0] !== undefined ) {
card14.push({
color: colors2[0],
shape: shapes2[0],
fill: fills1[0],
number: numbers2[0]
});
possibleCards.push(card14);
}
}
if (shapes1[0] === shapesall[a] && colors2[0] === colorsall[a] && fills2[0] === fillsall[a] && numbers2[0] === numbersall[a]) {
if(colors2[0] !== undefined && fills2[0] !== undefined && numbers2[0] !== undefined ) {
card15.push({
color: colors2[0],
shape: shapes1[0],
fill: fills2[0],
number: numbers2[0]
});
possibleCards.push(card15);
}
}
if (shapes2[0] === shapesall[a] && colors1[0] === colorsall[a] && fills2[0] === fillsall[a] && numbers2[0] === numbersall[a]) {
if (shapes2[0] !== undefined && fills2[0] !== undefined && numbers2[0] !== undefined) {
card16.push({
color: colors1[0],
shape: shapes2[0],
fill: fills2[0],
number: numbers2[0]
});
possibleCards.push(card16);
}
}
}
return possibleCards;
},
existingHyperSet2: function() {
var colors1 = [];
var shapes1 =[];
@ -2744,7 +3095,7 @@ var Game = {
var cartes4 = cartes;
var carte1, carte3, carte4, carte5;
var carte1, carte3, carte4, carte5, carte6 =[];
var carte2;
var card6ABC = [];
var card6ABD = [];
@ -2775,7 +3126,12 @@ var Game = {
var i, j, a,l, m, k;
var tCardsDGE = [];
var pCards = [];
var pCards2 = [];
var i, j, a,l, m, k ,z;
var colorsall= $.map(this.cardsHS2, function(el) { return el.color;});
var shapesall = $.map(this.cardsHS2, function(el) { return el.shape; });
@ -2786,20 +3142,62 @@ var Game = {
for(i=0; i < cartes.length-4; i++) {
for (j = i + 1; j < cartes1.length - 3; j++) {
for (k = j + 1; k < cartes2.length-2; k++) {
for (l = k + 1; l < cartes3.length-1; l++) {
for (m = l + 1; m < cartes4.length; m++) {
carte1 = cartes[i];
carte2 = cartes1[j];
carte3 = cartes2[k];
carte4 = cartes3[l];
carte5 = cartes4[m];
carte4 = cartes2[k];
tCardsABC[0] = carte1;
tCardsABC[1] = carte2;
tCardsABC[2] = carte3;
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);
numbers1.splice(0, 1, carte1.number);
numbers1.splice(1, 1, carte2.number);
pCards = self.generer16Cartes(colors1,shapes1, fills1, numbers1, this.cardsHS2);
for (z=0; z<pCards.length; z++ ){
tCardsABC[0] = carte1;
tCardsABC[1] = carte2;
tCardsABC[2] = pCards[z][0];
cardVirtualABC[z] = this.generateVirtualCard44(tCardsABC);
tCardsDGE[0] = carte4;
tCardsDGE[1] = cardVirtualABC[z][0];
colors2= $.map(tCardsDGE, function(el) { return el.color;});
shapes2 = $.map(tCardsDGE, function(el) { return el.shape; });
fills2= $.map(tCardsDGE,function(el) { return el.fill; });
numbers2 = $.map(tCardsDGE, function(el) { return el.number;});
console.log(tCardsDGE );
pCards2= self.generer16Cartes(colors2,shapes2, fills2, numbers2, this.cardsHS2);
if(pCards[z][0] !== undefined) {
tCardsDGE[2] = pCards2[z];
carte6[z] = this.generateVirtualCard44(tCardsDGE);
}
//console.log(tCardsABC, tCardsDGE, carte6);
}
//carte3 = cartes2[k];
// carte4 = cartes3[l];
// carte5 = cartes4[m];
/*
tCardsABD[0] = carte1;
@ -2830,7 +3228,6 @@ var Game = {
tCardsCDE[1] = carte4;
tCardsCDE[2] = carte5;
cardVirtualABC = this.generateVirtualCard44(tCardsABC);
cardVirtualABD = this.generateVirtualCard44(tCardsABD);
cardVirtualABE = this.generateVirtualCard44(tCardsABE);
cardVirtualACD = this.generateVirtualCard44(tCardsACD);
@ -3159,7 +3556,7 @@ var Game = {
}
}
}*/
}
}
}
@ -3580,8 +3977,8 @@ var Game = {
if (shapes1[2] === shapesall[a] && colors1[2] === colorsall[a] && fills1[2] === fillsall[a] && borders1[2] === bordersall[a] && numbers1[2] === numbersall[a]) {
//console.log('ab');
//console.log(shapes1, colors1, fills1, borders1, numbers1);
//console.log(carte1);
//console.log(carte2);
//console.log( 'carte1 :'+ carte1);
//console.log( carte2 : ' + carte2);
self.setHS3 = self.setHS3 + 1;
}
}

Loading…
Cancel
Save