diff --git a/code/vitraux.js b/code/vitraux.js index a9c22e6..4ad0bf7 100644 --- a/code/vitraux.js +++ b/code/vitraux.js @@ -373,6 +373,10 @@ function generate(){ } } empiler(true); + if(checkAllOK(true)==true) + { + generate(); + } toutDessiner(tabObjCmp,canvasO,ctxO); } @@ -488,7 +492,7 @@ function rotationManager(e) } -function checkAllOK(){ +function checkAllOK(justChecking=false){ //const condition = (val) => val.toString() == element.toString(); var exists=true; //exists=!tabObjCmp.every(unique); @@ -510,7 +514,7 @@ function checkAllOK(){ exists=false; } - if(exists) + if(exists && !justChecking) { var audio = new Audio('ress/Jewel4.mp3'); audio.play(); @@ -519,6 +523,10 @@ function checkAllOK(){ handleScore(1); generate(); } + else if(justChecking) + { + return exists; + } } function handleScore(modif)