diff --git a/code/index.html b/code/index.html
index 665cf58..de0b413 100644
--- a/code/index.html
+++ b/code/index.html
@@ -64,6 +64,7 @@
tabTotal=[];
tabObjCmp=[];
mousePos=[];
+ colorsAvailable=["red","yellow","green","purple"];
colors=["red","yellow","green","purple"];
width=120; // 6 lignes de 50px
@@ -109,7 +110,6 @@
img.src="ress/"+color+".png";
img.onload = function(){
- console.log("x:"+x+" y:"+y+" col:"+color);
lectx.drawImage(img,nx,ny,width/6,height/6);
}
@@ -142,9 +142,10 @@
element[0]=-tmp;
});
}
- toutDessiner(letab,lecanvas,lectx);
+
+ empiler(sselem!=null);
if(sselem==null)
- empiler();
+ toutDessiner(letab,lecanvas,lectx);
}
function toutDessiner(pts,lecanvas,lectx)
@@ -152,8 +153,8 @@
lectx.clearRect(0, 0, lecanvas.width, lecanvas.height);
if(pts[0])
{
-
- for(i=1;i val.toString() != test.toString();
- exists=false;
+ var exists=false;
if(!obj)
{
@@ -177,66 +178,114 @@
{
tab1.forEach(element => {
- tabTotal.push(element);
+ if(typeof element!= "boolean")
+ {
+ console.log(element.toString()+" n'est pas bool");
+ tabTotal.push(element);
+ }
})
}
if(tab2[0]){
tab2.forEach(element => {
- colors.forEach(col => {
- test=[element[0],element[1],col];
+ if(typeof element!= "boolean")
+ {
+ colors.forEach(col => {
+ test=[element[0],element[1],col];
+ if(!exists)
+ exists=!tabTotal.every(unique);
+ })
if(!exists)
- exists=!tabTotal.every(unique);
- })
- if(!exists)
- tabTotal.push(element);
- exists=false;
+ tabTotal.push(element);
+ exists=false;
+ }
})
}
if(tab3[0])
{
tab3.forEach(element => {
- colors.forEach(col => {
- test=[element[0],element[1],col];
+ if(typeof element!= "boolean"){
+ colors.forEach(col => {
+ test=[element[0],element[1],col];
+ if(!exists)
+ exists=!tabTotal.every(unique);
+ })
if(!exists)
- exists=!tabTotal.every(unique);
- })
- if(!exists)
- tabTotal.push(element);
- exists=false;
+ tabTotal.push(element);
+ exists=false;
+ }
})
}
if(tab4[0]){
tab4.forEach(element => {
- colors.forEach(col => {
- test=[element[0],element[1],col];
+ if(typeof element!= "boolean")
+ {
+ colors.forEach(col => {
+ test=[element[0],element[1],col];
+ if(!exists)
+ exists=!tabTotal.every(unique);
+ })
if(!exists)
- exists=!tabTotal.every(unique);
- })
- if(!exists)
- tabTotal.push(element);
- exists=false;
+ tabTotal.push(element);
+ exists=false;
+ }
})
}
checkAllOK();
toutDessiner(tabTotal,canvasT,ctxT);
}
else{
+ tabObjCmp=[];
tabObj[0].forEach(element => {
- tabObjCmp.push(element);
+ if(typeof element!= "boolean")
+ {
+ tabObjCmp.push(element);
+ }
})
tabObj[1].forEach(element => {
- colors.forEach(col => {
- test=[element[0],element[1],col];
+ if(typeof element!= "boolean")
+ {
+ colors.forEach(col => {
+ test=[element[0],element[1],col];
+ if(!exists)
+ exists=!tabObjCmp.every(unique);
+ })
if(!exists)
- exists=!tabObjCmp.every(unique);
- })
- if(!exists)
- tabObjCmp.push(element);
- exists=false;
+ 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")
+ {
+ colors.forEach(col => {
+ test=[element[0],element[1],col];
+ if(!exists)
+ exists=!tabObjCmp.every(unique);
+ })
+ if(!exists)
+ tabObjCmp.push(element);
+ exists=false;
+ }
+
})
}
}
@@ -264,7 +313,7 @@
function generateEasy(){
tabObj=[Array.from(tab1),Array.from(tab2),Array.from(tab3),Array.from(tab4)];
tabObjCmp=[];
- actions=getRandomInt(8);
+ actions=getRandomInt(8)+1;
while(actions>0){
tourneD(tabObj,canvasO,ctxO,getRandomInt(4)-1);
@@ -344,18 +393,22 @@
{
if((mousePos[1]=="N" && dir == "O") || (mousePos[1]=="S" && dir == "E") || (mousePos[1]=="O" && dir == "S") || (mousePos[1]=="E" && dir == "N"))
{
+ console.log("G");
tourneG(letab,lecanvas,lectx);
}
else if((mousePos[1] == "N" && dir == "E") || (mousePos[1] == "S" && dir == "O") || (mousePos[1] == "E" && dir == "S") || (mousePos[1] == "O" && dir == "N"))
{
+ console.log("D");
tourneD(letab,lecanvas,lectx);
}
else if ((mousePos[1] == "E" && dir == "O") || (mousePos[1] == "O" && dir == "E"))
{
+ console.log("V");
swap(letab,lecanvas,lectx,"V");
}
else if ((mousePos[1] == "N" && dir == "S") || (mousePos[1] == "S" && dir == "N"))
{
+ console.log("H");
swap(letab,lecanvas,lectx,"H");
}
}
@@ -371,18 +424,23 @@
function checkAllOK(){
//const condition = (val) => val.toString() == element.toString();
- exists=true;
+ var exists=true;
//exists=!tabObjCmp.every(unique);
-
+ console.log("---------------------------------");
if(tabTotal.length==tabObjCmp.length)
{
- for(i=0;i>tabTotal.length;i++)
+ console.log("bon nombre, tab total.l="+tabTotal.length);
+ for(i=0;i