From ed949a82218d0a984bb10f0be30c15d283d3cd08 Mon Sep 17 00:00:00 2001 From: pisouvigne Date: Thu, 4 Jun 2020 12:42:19 +0200 Subject: [PATCH] =?UTF-8?q?le=20niveau=20sait=20maintenant=20lorsque=20que?= =?UTF-8?q?lqu'un=20a=20r=C3=A9ussi=20=C3=A0=20allumer=20toute=20les=20lig?= =?UTF-8?q?nes=20reli=C3=A9s=20=C3=A0=20la=20fin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/js/func.js | 13 +++++++++++++ site/js/init.js | 3 +++ site/vues/jeu.html | 3 +-- 3 files changed, 17 insertions(+), 2 deletions(-) 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(); - - +