From 82c784deddb8c22cf5f5b12400d9f7594126d346 Mon Sep 17 00:00:00 2001 From: pisouvigne Date: Sat, 1 Aug 2020 23:53:11 +0200 Subject: [PATCH] t --- site/v1/index.html | 9 ++-- site/v1/js/func.js | 122 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 124 insertions(+), 7 deletions(-) diff --git a/site/v1/index.html b/site/v1/index.html index 9f40c86..63aa11c 100644 --- a/site/v1/index.html +++ b/site/v1/index.html @@ -51,7 +51,7 @@
-
+ @@ -63,7 +63,7 @@
-
+ @@ -74,7 +74,8 @@
-
+ @@ -85,7 +86,7 @@
-
+ diff --git a/site/v1/js/func.js b/site/v1/js/func.js index 275d87e..f163800 100644 --- a/site/v1/js/func.js +++ b/site/v1/js/func.js @@ -682,8 +682,10 @@ function nextLevel(mode) { niveauActuel++; if (mode != undefined && mode != null && mode === "tuto") { launchTuto(); - } else { + } else if (mode === "vanilla" || mode === "normal") { launchGameOne(mode); + } else if (mode === "vanillaFacile") { + launchFacileGameOne(mode); } } @@ -825,15 +827,26 @@ function goToSelection(btn) { function vanillaSelection() { hideDiv(document.querySelector("#levelSelectionPage")); showDiv(document.querySelector("#VanillalevelSelectionPage")); + document.querySelectorAll(".vanillaElement").forEach(function (element) { + if (element.children[0].innerHTML !== "") + element.children[1].className = "fa fa-play"; + }); } function playVanilla() { - hideDiv(document.querySelector("#levelSelectionPage")); + hideDiv(document.querySelector("#VanillalevelSelectionPage")); showDiv(document.querySelector("#playPage")); niveauActuel = 1; timeTot = 0; launchGameOne("vanilla"); } +function playFacileVanilla() { + hideDiv(document.querySelector("#VanillalevelSelectionPage")); + showDiv(document.querySelector("#playPage")); + niveauActuel = 1; + timeTot = 0; + launchFacileGameOne("vanillaFacile"); +} function modeTuto() { hideDiv(document.querySelector("#levelSelectionPage")); showDiv(document.querySelector("#playPage")); @@ -870,12 +883,20 @@ function wait(mode, btn) { var time = 300; spin(btn); switch (mode) { + case "vanillaInfini": + setTimeout(playVanilla, time); + setMode("Vanilla Infini"); + break; + case "vanillaFacile": + setTimeout(playFacileVanilla, time); + setMode("Vanilla Facile"); + break; case "normal": setTimeout(playNormal, time); setMode("Normal"); break; case "vanilla": - setTimeout(playVanilla, time); + setTimeout(vanillaSelection, time); setMode("Vanilla") break; case "perso": @@ -1052,6 +1073,101 @@ function launchGameOne(mode) { } } +function launchFacileGameOne(mode) { + document.querySelector(".niveau").innerHTML = niveauActuel + " / 25"; + document.querySelector("#win_pannel").style.display = "none"; + timer.stop(); + timer.reset(); + resetAllTabs(false); + var col = []; + var matchs = []; + var porteLogique = []; + var time = 20; + switch (niveauActuel) { + case 1: + col = [2, 1]; + porteLogique = [[true, "et"], [true, "ou"]]; + break; + case 2: + col = [2, 2]; + porteLogique = [[true, "et"], [true, "ou"]]; + break; + case 3: + col = [3, 2]; + matchs = [[1, 2]]; + porteLogique = [[true, "et"], [true, "ou"]]; + break; + case 4: + col = [3, 2]; + porteLogique = [[true, "et"], [true, "inv"]]; + break; + case 5: + col = [3, 3]; + matchs = [[1, 2]]; + porteLogique = [[true, "et"], [true, "inv"]]; + break; + case 7: + case 6: + col = [4, 3]; + matchs = [[1, 2]]; + porteLogique = [[true, "et"], [true, "inv"], [true, "ou"]]; + break; + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + col = [5, 4, 3]; + matchs = [[1, 3], [2, 2]]; + porteLogique = [[true, "et"], [true, "ou"], [true, "inv"]]; + break; + } + for (let i = 0; i < 200; i++) { + tentative = i; + if (generator(matchs, col, porteLogique, mode, time) === false) + break; + + } + if (mode === "normalFacile") { + switchsInfoCopy.forEach(function (sw) { + if (getRandomArbitrary(0, 3) === 1) { + activeSwitch(sw.id); + checkAllSortieLogique(); + } + }); + } + while (checkIfEnd()) { + for (let i = 0; i < 200; i++) { + tentative = i; + if (generator(matchs, col, porteLogique, mode, time) === false) + break; + } + if (mode === "normalFacile") { + switchsInfoCopy.forEach(function (sw) { + switchsInfoCopy.forEach(function (sw) { + if (getRandomArbitrary(0, 3) === 1) { + activeSwitch(sw.id); + checkAllSortieLogique(); + } + }); + }); + } + } +} + function launchTuto() { document.querySelector("#win_pannel").style.display = "none"; document.querySelector(".niveau").innerHTML = niveauActuel;