From 0e3ba8d8c1e87fa49982e87babb4d6f78e8a1fd6 Mon Sep 17 00:00:00 2001 From: pisouvigne Date: Mon, 6 Jul 2020 17:30:31 +0200 Subject: [PATCH] =?UTF-8?q?am=C3=A9lioration=20de=20la=20page=20pour=20tes?= =?UTF-8?q?ter=20le=20nouveau=20g=C3=A9n=C3=A9rteur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/vue/css/style.css | 12 +++++++ site/vue/index.html | 11 ++++++ site/vue/js/func.js | 4 +++ site/vue/js/generateGame.js | 70 +++++++++++++++++++++++++++++-------- 4 files changed, 82 insertions(+), 15 deletions(-) diff --git a/site/vue/css/style.css b/site/vue/css/style.css index 7b3ce20..2361efc 100644 --- a/site/vue/css/style.css +++ b/site/vue/css/style.css @@ -571,6 +571,18 @@ input[type=color] { color: green; } +#error_perso { + color: red; +} + +.fa-trash:hover { + color: red; +} + +.fa-trash { + margin-left: 20px; +} + #waitingPage { margin: auto; position: absolute; diff --git a/site/vue/index.html b/site/vue/index.html index 5a6fdad..c74a90a 100644 --- a/site/vue/index.html +++ b/site/vue/index.html @@ -60,6 +60,17 @@

Colonnes :


+ +
+
+ +
+
+

+
Générer le niveau diff --git a/site/vue/js/func.js b/site/vue/js/func.js index 031e0b7..a5518c6 100644 --- a/site/vue/js/func.js +++ b/site/vue/js/func.js @@ -671,6 +671,10 @@ function modeTest() { } +function ErrorMessage(message) { + document.querySelector("#error_perso").innerHTML = message; +} + function wait(mode, btn) { var time = 300; spin(btn); diff --git a/site/vue/js/generateGame.js b/site/vue/js/generateGame.js index 04cbff5..0919522 100644 --- a/site/vue/js/generateGame.js +++ b/site/vue/js/generateGame.js @@ -111,7 +111,7 @@ function buttonSpin(button, type) { } document.querySelector("#colonne_number_setup_global_gen").addEventListener('input', (event) => { - if (parseInt(document.querySelector("#colonne_number_setup_global_gen").value) <= 1) document.querySelector("#colonne_number_setup_global_gen").value = 2; + if (parseInt(document.querySelector("#colonne_number_setup_global_gen").value) <= 0) document.querySelector("#colonne_number_setup_global_gen").value = 1; calcul(); }); @@ -143,9 +143,53 @@ function calcul(launch) { } document.querySelector("#colonnes_live").innerHTML = col + " | nombre de colonne : " + col.length + " | nombre total de portes : " + number_const; + var matchs = []; + var fork = []; + var error = null; + + document.querySelectorAll(".div_gen_col_fork").forEach(function (element) { + element.childNodes[0].innerHTML = "Ajouter un fork pour la colonne " + element.childNodes[1].value + " qui se divise en " + element.childNodes[2].value; + matchs.push([(parseInt(element.childNodes[1].value) + 1), parseInt(element.childNodes[2].value)]); + fork.push([parseInt(element.childNodes[1].value), parseInt(element.childNodes[2].value)]); + if (parseInt(element.childNodes[1].value) < 1 || parseInt(element.childNodes[1].value) > col.length) { + error = "Problème sur le numéro de colonne"; + element.childNodes[1].style.borderColor = "red"; + } else { + element.childNodes[1].style.borderColor = "white"; + } + }); + if (error !== null) ErrorMessage(error); if (launch !== undefined && launch !== null && launch === true) { - generate2(col); + generate2(col, matchs, fork); + } +} + +function addGenForkInput() { + var div = document.createElement("div"); + div.classList = "div_gen_col_fork"; + var span = document.createElement("span"); + span.innerHTML = "Ajouter un fork pour la colonne 1 qui se divise en 2"; + div.appendChild(span); + var input = document.createElement("input"); + input.addEventListener('input', (event) => { + calcul(); + }); + input.value = 1; + div.append(input); + input = document.createElement("input"); + input.addEventListener('input', (event) => { + calcul(); + }); + input.value = 2; + div.append(input); + var i = document.createElement("i"); + i.className = "fa fa-trash"; + i.onclick = function () { + this.parentElement.remove(); } + div.append(i); + document.querySelector("#gen_fork_div").appendChild(div); + calcul(); } function tuto(niveau) { @@ -235,7 +279,7 @@ function createGameOne(niveau) { numberColonne2 = 1; timeEnd = 20; break; - //Fin premiere serie + //Fin premiere serie case 5: firstTime.push("inv"); isNotAllowed = true; @@ -354,31 +398,26 @@ function createGameOne(niveau) { } -function generate2(col) { +function generate2(col, matchs, fork) { hideDiv(document.querySelector('#TestNouveauGenerateur')); showDiv(document.querySelector('#playPage')); resetAllTabs(false); - var matchs = [ - [2, 2] - ]; - var fork = [ - [1, 2] - ]; var numberCol = col.length; - var numberPerCol = col; + var numberPerCol = []; + numberPerColonne = []; + for (let i = 0; i < col.length; i++) { + numberPerCol[i] = col[i]; + numberPerColonne[i] = col[i]; + } colonneTot = col.length; - numberPerColonne = col; - console.log(numberPerColonne); - var compt = new Array(); var listeSame = []; let num = 1; //attribution for (let i = numberCol; i > 0; i--) { - matchs.forEach(function (element) { if (element[0] == i) { for (let j = 0; j < element[1]; j++) { @@ -528,6 +567,7 @@ function generate2(col) { } } initEndGame(); + checkAllSortieLogique(); } function getNumberFork(arr, col) {