vérificatoin fonctionnelle

vérification_résultat
adplantade 5 years ago
parent 078f2b6b6b
commit f0715190b9

@ -36,6 +36,7 @@
tab3=[]; tab3=[];
tab4=[]; tab4=[];
tabTotal=[]; tabTotal=[];
tabObjCmp=[];
mousePos=[]; mousePos=[];
colors=["red","blue","green","brown"]; colors=["red","blue","green","brown"];
@ -114,12 +115,14 @@
}) })
} }
function empiler() function empiler(obj=false)
{ {
tabTotal=[];
const unique = (val) => val.toString() != test.toString(); const unique = (val) => val.toString() != test.toString();
exists=false; exists=false;
if(!obj)
{
tabTotal=[];
tab1.forEach(element => { tab1.forEach(element => {
tabTotal.push(element); tabTotal.push(element);
}) })
@ -153,9 +156,26 @@
tabTotal.push(element); tabTotal.push(element);
exists=false; exists=false;
}) })
checkAllOK();
toutDessiner(tabTotal,canvasT,ctxT); toutDessiner(tabTotal,canvasT,ctxT);
} }
else{
tabObj[0].forEach(element => {
tabObjCmp.push(element);
})
tabObj[1].forEach(element => {
colors.forEach(col => {
test=[element[0],element[1],col];
if(!exists)
exists=!tabObjCmp.every(unique);
})
if(!exists)
tabObjCmp.push(element);
exists=false;
})
}
}
function swap(letab, lecanvas, lectx,ladir){ function swap(letab, lecanvas, lectx,ladir){
if(ladir=="H"){ if(ladir=="H"){
@ -181,15 +201,14 @@
tabObj=[[],[]]; tabObj=[[],[]];
tabObj[0]=Array.from(tab1); tabObj[0]=Array.from(tab1);
tabObj[1]=Array.from(tab2); tabObj[1]=Array.from(tab2);
console.log(tabObj); tabObjCmp=[];
actions=getRandomInt(5); actions=getRandomInt(5);
while(actions>0){ while(actions>0){
tourneD(tabObj,canvasO,ctxO,getRandomInt(2)-1); tourneD(tabObj,canvasO,ctxO,getRandomInt(2)-1);
console.log(tabObj);
actions--; actions--;
} }
console.log("sec",tabObj); empiler(true);
toutDessiner(tabObj,canvasO,ctxO); toutDessiner(tabObj,canvasO,ctxO);
} }
@ -247,6 +266,30 @@
} }
} }
function checkAllOK(){
//const condition = (val) => val.toString() == element.toString();
exists=true;
//exists=!tabObjCmp.every(unique);
if(tabTotal.length==tabObjCmp.length)
{
for(i=0;i>tabTotal.length;i++)
{
exists*tabTotal[i].toString()==tabObjCmp[i].toString();
}
}
else
exists=false;
if(exists)
{
console.log("OK");
generateEasy();
}
}
canvas1.addEventListener("mousedown",function(e){ canvas1.addEventListener("mousedown",function(e){
mousePos = [e.currentTarget.id.substring(6),compas(e.clientX,e.clientY,e.currentTarget)]; mousePos = [e.currentTarget.id.substring(6),compas(e.clientX,e.clientY,e.currentTarget)];
}) })

Loading…
Cancel
Save