|
|
|
@ -145,10 +145,13 @@ function calcul(launch) {
|
|
|
|
|
|
|
|
|
|
var matchs = [];
|
|
|
|
|
var fork = [];
|
|
|
|
|
var count = [];
|
|
|
|
|
for (let i = 0; i < col.length; i++) count[i] = 0;
|
|
|
|
|
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;
|
|
|
|
|
count[(parseInt(element.childNodes[1].value) - 1)] = count[(parseInt(element.childNodes[1].value) - 1)] + parseInt(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) {
|
|
|
|
@ -157,6 +160,12 @@ function calcul(launch) {
|
|
|
|
|
} else {
|
|
|
|
|
element.childNodes[1].style.borderColor = "white";
|
|
|
|
|
}
|
|
|
|
|
if (count[(parseInt(element.childNodes[1].value) - 1)] > col[count[(parseInt(element.childNodes[1].value) - 1)]]) {
|
|
|
|
|
error = "Problème nombre de porte dans la colonne";
|
|
|
|
|
element.childNodes[2].style.borderColor = "red";
|
|
|
|
|
} else {
|
|
|
|
|
element.childNodes[2].style.borderColor = "white";
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (error !== null) ErrorMessage(error);
|
|
|
|
|
if (launch !== undefined && launch !== null && launch === true) {
|
|
|
|
@ -175,12 +184,14 @@ function addGenForkInput() {
|
|
|
|
|
calcul();
|
|
|
|
|
});
|
|
|
|
|
input.value = 1;
|
|
|
|
|
input.setAttribute("type", "number");
|
|
|
|
|
div.append(input);
|
|
|
|
|
input = document.createElement("input");
|
|
|
|
|
input.addEventListener('input', (event) => {
|
|
|
|
|
calcul();
|
|
|
|
|
});
|
|
|
|
|
input.value = 2;
|
|
|
|
|
input.setAttribute("type", "number");
|
|
|
|
|
div.append(input);
|
|
|
|
|
var i = document.createElement("i");
|
|
|
|
|
i.className = "fa fa-trash";
|
|
|
|
@ -567,6 +578,7 @@ function generate2(col, matchs, fork) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
initEndGame();
|
|
|
|
|
isLineCollapsing();
|
|
|
|
|
checkAllSortieLogique();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|