diff --git a/site/js/func.js b/site/js/func.js index bd58a06..ba9d29f 100644 --- a/site/js/func.js +++ b/site/js/func.js @@ -92,5 +92,18 @@ function checkLineSwitch(switchId) { return false; } +function checkEnd(){ + let ter = true; + endLines.forEach(function(element){ + if(stage.findOne("#line"+element).stroke() == "black"){ + ter = false; + + } + }); + if(ter){ + setTimeout(() => { alert("Niveau terminé"); }, 40); + } +} + diff --git a/site/js/init.js b/site/js/init.js index 0aeeb0e..0e63d02 100644 --- a/site/js/init.js +++ b/site/js/init.js @@ -2,11 +2,13 @@ function initAllSwitch() { switchs.forEach(function (element) { let switche = stage.findOne("#" + element); switche.on('click', function () { + let colorrect = switche.fill() == colorSwitchInnactiveBackground ? colorSwitchActiveBackground : colorSwitchInnactiveBackground; switche.fill(colorrect); changeLineColor(switche.id3); checkAllSortieLogique(); layer.draw(); + checkEnd(); }); switche.on('mouseover', function () { document.body.style.cursor = "pointer"; @@ -16,6 +18,7 @@ function initAllSwitch() { }); }); + } function initLayer() { diff --git a/site/vues/jeu.html b/site/vues/jeu.html index c16430a..77aaadd 100644 --- a/site/vues/jeu.html +++ b/site/vues/jeu.html @@ -66,8 +66,7 @@ initAllSwitch(); createEnd(800, 320); initEnd(); - - +