amélioration de la page de génération

master
pisouvigne 5 years ago
parent 0e3ba8d8c1
commit 02914539ed

@ -62,7 +62,6 @@ function createLine(points, id) {
let newPoints = [startX, startY, startX + distance20, startY, endX - distance20, endY, endX, endY]; let newPoints = [startX, startY, startX + distance20, startY, endX - distance20, endY, endX, endY];
let line = new Konva.Line({ let line = new Konva.Line({
points: newPoints, points: newPoints,
fill: 'blue',
stroke: colorLineInnactive, stroke: colorLineInnactive,
strokeWidth: lineStroke, strokeWidth: lineStroke,
id: id, id: id,

@ -145,10 +145,13 @@ function calcul(launch) {
var matchs = []; var matchs = [];
var fork = []; var fork = [];
var count = [];
for (let i = 0; i < col.length; i++) count[i] = 0;
var error = null; var error = null;
document.querySelectorAll(".div_gen_col_fork").forEach(function (element) { 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; 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)]); 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)]); 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) { if (parseInt(element.childNodes[1].value) < 1 || parseInt(element.childNodes[1].value) > col.length) {
@ -157,6 +160,12 @@ function calcul(launch) {
} else { } else {
element.childNodes[1].style.borderColor = "white"; 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 (error !== null) ErrorMessage(error);
if (launch !== undefined && launch !== null && launch === true) { if (launch !== undefined && launch !== null && launch === true) {
@ -175,12 +184,14 @@ function addGenForkInput() {
calcul(); calcul();
}); });
input.value = 1; input.value = 1;
input.setAttribute("type", "number");
div.append(input); div.append(input);
input = document.createElement("input"); input = document.createElement("input");
input.addEventListener('input', (event) => { input.addEventListener('input', (event) => {
calcul(); calcul();
}); });
input.value = 2; input.value = 2;
input.setAttribute("type", "number");
div.append(input); div.append(input);
var i = document.createElement("i"); var i = document.createElement("i");
i.className = "fa fa-trash"; i.className = "fa fa-trash";
@ -279,7 +290,7 @@ function createGameOne(niveau) {
numberColonne2 = 1; numberColonne2 = 1;
timeEnd = 20; timeEnd = 20;
break; break;
//Fin premiere serie //Fin premiere serie
case 5: case 5:
firstTime.push("inv"); firstTime.push("inv");
isNotAllowed = true; isNotAllowed = true;
@ -567,6 +578,7 @@ function generate2(col, matchs, fork) {
} }
} }
initEndGame(); initEndGame();
isLineCollapsing();
checkAllSortieLogique(); checkAllSortieLogique();
} }

Loading…
Cancel
Save