@ -147,7 +147,7 @@
empiler(sselem!=null);
empiler(sselem!=null);
//console.log("post-empiler :"+tabTotal);
//console.log("post-empiler :"+tabTotal);
if(sselem==null)
if(sselem==null)
toutDessiner(letab,lecanvas,lectx);
toutDessiner(letab,lecanvas,lectx);
}
}
function toutDessiner(pts,lecanvas,lectx)
function toutDessiner(pts,lecanvas,lectx)
@ -180,7 +180,7 @@
{
{
tab1.forEach(element => {
tab1.forEach(element => {
if(typeof element!= "boolean" )
if(Array.isArray(element) )
{
{
tabTotal.push(element);
tabTotal.push(element);
}
}
@ -189,7 +189,7 @@
if(tab2[0]){
if(tab2[0]){
tab2.forEach(element => {
tab2.forEach(element => {
if(typeof element!= "boolean" )
if(Array.isArray(element) )
{
{
colors.forEach(col => {
colors.forEach(col => {
test=[element[0],element[1],col];
test=[element[0],element[1],col];
@ -206,7 +206,7 @@
{
{
tab3.forEach(element => {
tab3.forEach(element => {
if(typeof element!= "boolean" ){
if(Array.isArray(element) ){
colors.forEach(col => {
colors.forEach(col => {
test=[element[0],element[1],col];
test=[element[0],element[1],col];
if(!exists)
if(!exists)
@ -221,7 +221,7 @@
if(tab4[0]){
if(tab4[0]){
tab4.forEach(element => {
tab4.forEach(element => {
if(typeof element!= "boolean" )
if(Array.isArray(element) )
{
{
colors.forEach(col => {
colors.forEach(col => {
test=[element[0],element[1],col];
test=[element[0],element[1],col];
@ -239,44 +239,15 @@
}
}
else{
else{
tabObjCmp=[];
tabObjCmp=[];
tabObj[0].forEach(element => {
for(count=1;count< tabObj [ 0 ] . length ; count + + )
if(typeof element!= "boolean")
{
{
tabObjCmp.push(tabObj[0][count]);
tabObjCmp.push(element);
}
}
for(tabCount=1;tabCount< tabObj.length ; tabCount + + )
})
{
for(elmCount=1;elmCount< tabObj [ tabCount ] . length ; elmCount + + )
tabObj[1].forEach(element => {
if(typeof element!= "boolean")
{
colors.forEach(col => {
test=[element[0],element[1],col];
if(!exists)
exists=!tabObjCmp.every(unique);
})
if(!exists)
tabObjCmp.push(element);
exists=false;
}
})
tabObj[2].forEach(element => {
if(typeof element!= "boolean")
{
colors.forEach(col => {
test=[element[0],element[1],col];
if(!exists)
exists=!tabObjCmp.every(unique);
})
if(!exists)
tabObjCmp.push(element);
exists=false;
}
})
tabObj[3].forEach(element => {
if(typeof element!= "boolean")
{
{
element=tabObj[tabCount][elmCount];
colors.forEach(col => {
colors.forEach(col => {
test=[element[0],element[1],col];
test=[element[0],element[1],col];
if(!exists)
if(!exists)
@ -284,10 +255,9 @@
})
})
if(!exists)
if(!exists)
tabObjCmp.push(element);
tabObjCmp.push(element);
exists=false;
exists=false;
}
}
}
})
}
}
}
}
@ -319,7 +289,7 @@
});
});
return newArray
return newArray
}
}
function generateEasy(){
function generateEasy(){
console.log(copyMDArray(tab1))
console.log(copyMDArray(tab1))
tabObj=[copyMDArray(tab1),copyMDArray(tab2),copyMDArray(tab3),copyMDArray(tab4)];
tabObj=[copyMDArray(tab1),copyMDArray(tab2),copyMDArray(tab3),copyMDArray(tab4)];
@ -441,10 +411,16 @@
if(tabTotal.length==tabObjCmp.length)
if(tabTotal.length==tabObjCmp.length)
{
{
console.log("bon nombre, tab total.l="+tabTotal.length);
console.log("bon nombre, tab total.l="+tabTotal.length);
var verifTab=[];
verifTab=copyMDArray(tabTotal);
for(i=0;i< tabTotal.length ; i + + )
for(i=0;i< tabTotal.length ; i + + )
{
{
exists*tabTotal[i].toString()==tabObjCmp[i].toString();
const result = verifTab.filter(point => point.toString()==tabObjCmp[i].toString());
console.log(tabTotal[i].toString()+"=="+tabObjCmp[i].toString()+" : "+exists);
exists*=result.length;
console.log("long : "+ result.length + "ling : "+verifTab.length);
}
}
}
}
else
else
@ -455,6 +431,8 @@
if(exists)
if(exists)
{
{
var audio = new Audio('ress/Jewel4.mp3');
audio.play();
console.log("OK");
console.log("OK");
generateEasy();
generateEasy();
}
}
@ -472,8 +450,8 @@
//[fromTab,toTab]=[toTab,fromTab];
//[fromTab,toTab]=[toTab,fromTab];
toutDessiner(fromTab,eval("canvas"+from),eval("ctx"+from));
toutDessiner(fromTab,eval("canvas"+from),eval("ctx"+from));
toutDessiner(toTab,eval("canvas"+to),eval("ctx"+to));
toutDessiner(toTab,eval("canvas"+to),eval("ctx"+to));
toutDessiner(tabTotal,canvasT,ctxT);
empiler();
empiler();
toutDessiner(tabTotal,canvasT,ctxT);
}
}