|
|
@ -224,6 +224,21 @@ function changeLineColorInput(idLine, color) {
|
|
|
|
line.stroke(color);
|
|
|
|
line.stroke(color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function changeCircleBlack(logiqueId) {
|
|
|
|
|
|
|
|
circles.forEach(function (cir) {
|
|
|
|
|
|
|
|
if (cir[1] === logiqueId) {
|
|
|
|
|
|
|
|
stage.findOne("#" + cir[0]).fill(colorLineInnactive);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeCircleYellow(logiqueId) {
|
|
|
|
|
|
|
|
circles.forEach(function (cir) {
|
|
|
|
|
|
|
|
if (cir[1] === logiqueId) {
|
|
|
|
|
|
|
|
stage.findOne("#" + cir[0]).fill(colorLineActive);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function changeLineColorBlack(idLine) {
|
|
|
|
function changeLineColorBlack(idLine) {
|
|
|
|
setLineStateFalse(idLine);
|
|
|
|
setLineStateFalse(idLine);
|
|
|
|
let line = stage.findOne("#" + idLine);
|
|
|
|
let line = stage.findOne("#" + idLine);
|
|
|
@ -384,10 +399,12 @@ function checkSortieLogique(logiqueId) {
|
|
|
|
if (line1State == true && line2State == true) {
|
|
|
|
if (line1State == true && line2State == true) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
|
|
|
|
changeCircleYellow(logique.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
changeLineColorBlack(line);
|
|
|
|
changeLineColorBlack(line);
|
|
|
|
|
|
|
|
changeCircleBlack(logique.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -395,10 +412,12 @@ function checkSortieLogique(logiqueId) {
|
|
|
|
if (line1State == false) {
|
|
|
|
if (line1State == false) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
|
|
|
|
changeCircleYellow(logique.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
changeLineColorBlack(line);
|
|
|
|
changeLineColorBlack(line);
|
|
|
|
|
|
|
|
changeCircleBlack(logique.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -406,10 +425,12 @@ function checkSortieLogique(logiqueId) {
|
|
|
|
if (line1State == true || line2State == true) {
|
|
|
|
if (line1State == true || line2State == true) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
|
|
|
|
changeCircleYellow(logique.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
changeLineColorBlack(line);
|
|
|
|
changeLineColorBlack(line);
|
|
|
|
|
|
|
|
changeCircleBlack(logique.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -417,10 +438,12 @@ function checkSortieLogique(logiqueId) {
|
|
|
|
if (line1State == true || line2State == true) {
|
|
|
|
if (line1State == true || line2State == true) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
changeLineColorBlack(line);
|
|
|
|
changeLineColorBlack(line);
|
|
|
|
|
|
|
|
changeCircleBlack(logique.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
|
|
|
|
changeCircleYellow(logique.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -428,18 +451,22 @@ function checkSortieLogique(logiqueId) {
|
|
|
|
if (line1State == false && line2State == false) {
|
|
|
|
if (line1State == false && line2State == false) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
|
|
|
|
changeCircleYellow(logique.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (line1State == false && line2State == true) {
|
|
|
|
} else if (line1State == false && line2State == true) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
|
|
|
|
changeCircleYellow(logique.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (line1State == true && line2State == false) {
|
|
|
|
} else if (line1State == true && line2State == false) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
changeLineColorYellow(line);
|
|
|
|
|
|
|
|
changeCircleYellow(logique.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
element.id3.forEach(function (line) {
|
|
|
|
changeLineColorBlack(line);
|
|
|
|
changeLineColorBlack(line);
|
|
|
|
|
|
|
|
changeCircleBlack(logique.name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -605,6 +632,7 @@ function checkEnd(mode) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function success(mode) {
|
|
|
|
function success(mode) {
|
|
|
|
|
|
|
|
console.log(mode)
|
|
|
|
timeTot = timeTot + timer.getTimeValues().seconds;
|
|
|
|
timeTot = timeTot + timer.getTimeValues().seconds;
|
|
|
|
timer.stop();
|
|
|
|
timer.stop();
|
|
|
|
stage.findOne("#end").fill(colorSwitchActiveBackground);
|
|
|
|
stage.findOne("#end").fill(colorSwitchActiveBackground);
|
|
|
@ -612,20 +640,21 @@ function success(mode) {
|
|
|
|
if (mode != undefined && mode != null && mode === "tuto") {
|
|
|
|
if (mode != undefined && mode != null && mode === "tuto") {
|
|
|
|
document.querySelector(".retry_tuto").style.display = "flex";
|
|
|
|
document.querySelector(".retry_tuto").style.display = "flex";
|
|
|
|
document.querySelector("#retry_tuto_button").onclick = function () {
|
|
|
|
document.querySelector("#retry_tuto_button").onclick = function () {
|
|
|
|
closeModal('success');
|
|
|
|
//closeModal('success');
|
|
|
|
launchTuto();
|
|
|
|
launchTuto();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
document.querySelector(".retry_tuto").style.display = "none";
|
|
|
|
document.querySelector(".retry_tuto").style.display = "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (successPanel) {
|
|
|
|
if (successPanel) {
|
|
|
|
openModal("success");
|
|
|
|
document.querySelector("#win_pannel").style.display = "block";
|
|
|
|
|
|
|
|
//openModal("success");
|
|
|
|
document.querySelector("#click_number").innerHTML = click;
|
|
|
|
document.querySelector("#click_number").innerHTML = click;
|
|
|
|
document.querySelector("#next_level_button").onclick = function () {
|
|
|
|
document.querySelector("#next_level_button").onclick = function () {
|
|
|
|
closeModal('success');
|
|
|
|
//closeModal('success');
|
|
|
|
nextLevel(mode);
|
|
|
|
nextLevel(mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var previewStage = new Konva.Stage({
|
|
|
|
/*var previewStage = new Konva.Stage({
|
|
|
|
container: 'show_stage',
|
|
|
|
container: 'show_stage',
|
|
|
|
width: window.innerWidth / 1.5,
|
|
|
|
width: window.innerWidth / 1.5,
|
|
|
|
height: window.innerHeight / 2.5,
|
|
|
|
height: window.innerHeight / 2.5,
|
|
|
@ -636,7 +665,7 @@ function success(mode) {
|
|
|
|
hitGraphEnabled: false
|
|
|
|
hitGraphEnabled: false
|
|
|
|
});
|
|
|
|
});
|
|
|
|
previewStage.add(previewLayer);
|
|
|
|
previewStage.add(previewLayer);
|
|
|
|
previewLayer.batchDraw();
|
|
|
|
previewLayer.batchDraw();*/
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
setTimeout(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
nextLevel(mode);
|
|
|
|
nextLevel(mode);
|
|
|
@ -654,7 +683,7 @@ function nextLevel(mode) {
|
|
|
|
if (mode != undefined && mode != null && mode === "tuto") {
|
|
|
|
if (mode != undefined && mode != null && mode === "tuto") {
|
|
|
|
launchTuto();
|
|
|
|
launchTuto();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
generate2(tempCol, tempMatchs, tempFork, tempPortes);
|
|
|
|
launchGameOne(mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -785,9 +814,16 @@ function playNormal() {
|
|
|
|
showDiv(document.querySelector("#playPage"));
|
|
|
|
showDiv(document.querySelector("#playPage"));
|
|
|
|
niveauActuel = 1;
|
|
|
|
niveauActuel = 1;
|
|
|
|
timeTot = 0;
|
|
|
|
timeTot = 0;
|
|
|
|
launchGameOne();
|
|
|
|
launchGameOne("normal");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function playVanilla() {
|
|
|
|
|
|
|
|
hideDiv(document.querySelector("#levelSelectionPage"));
|
|
|
|
|
|
|
|
showDiv(document.querySelector("#playPage"));
|
|
|
|
|
|
|
|
niveauActuel = 1;
|
|
|
|
|
|
|
|
timeTot = 0;
|
|
|
|
|
|
|
|
launchGameOne("vanilla");
|
|
|
|
|
|
|
|
}
|
|
|
|
function modeTuto() {
|
|
|
|
function modeTuto() {
|
|
|
|
hideDiv(document.querySelector("#levelSelectionPage"));
|
|
|
|
hideDiv(document.querySelector("#levelSelectionPage"));
|
|
|
|
showDiv(document.querySelector("#playPage"));
|
|
|
|
showDiv(document.querySelector("#playPage"));
|
|
|
@ -828,6 +864,10 @@ function wait(mode, btn) {
|
|
|
|
setTimeout(playNormal, time);
|
|
|
|
setTimeout(playNormal, time);
|
|
|
|
setMode("Normal");
|
|
|
|
setMode("Normal");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "vanilla":
|
|
|
|
|
|
|
|
setTimeout(playVanilla, time);
|
|
|
|
|
|
|
|
setMode("Vanilla")
|
|
|
|
|
|
|
|
break;
|
|
|
|
case "perso":
|
|
|
|
case "perso":
|
|
|
|
setTimeout(modePerso, time);
|
|
|
|
setTimeout(modePerso, time);
|
|
|
|
setMode("Perso")
|
|
|
|
setMode("Perso")
|
|
|
@ -894,15 +934,104 @@ function show_more_perso(div) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function launchGameOne() {
|
|
|
|
function launchGameOne(mode) {
|
|
|
|
document.querySelector(".niveau").innerHTML = niveauActuel;
|
|
|
|
document.querySelector(".niveau").innerHTML = niveauActuel;
|
|
|
|
|
|
|
|
document.querySelector("#win_pannel").style.display = "none";
|
|
|
|
timer.stop();
|
|
|
|
timer.stop();
|
|
|
|
timer.reset();
|
|
|
|
timer.reset();
|
|
|
|
resetAllTabs(false);
|
|
|
|
resetAllTabs(false);
|
|
|
|
gameOne();
|
|
|
|
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:
|
|
|
|
|
|
|
|
col = [5, 4, 3];
|
|
|
|
|
|
|
|
matchs = [[1, 3], [2, 2]];
|
|
|
|
|
|
|
|
porteLogique = [[true, "et"], [true, "ou"], [true, "inv"]];
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 12:
|
|
|
|
|
|
|
|
case 13:
|
|
|
|
|
|
|
|
case 14:
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
|
|
|
|
case 16:
|
|
|
|
|
|
|
|
col = [5, 4, 4];
|
|
|
|
|
|
|
|
matchs = [[1, 3], [2, 2]];
|
|
|
|
|
|
|
|
porteLogique = [[true, "et"], [true, "nonou"], [true, "ou"], [true, "inv"]];
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
col = [4, 3, 2];
|
|
|
|
|
|
|
|
matchs = [[1, 2], [2, 2]];
|
|
|
|
|
|
|
|
porteLogique = [[true, "et"], [true, "ou"]];
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 0; i < 200; i++) {
|
|
|
|
|
|
|
|
tentative = i;
|
|
|
|
|
|
|
|
if (generator(matchs, col, porteLogique, mode, time) === false)
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode === "normal") {
|
|
|
|
|
|
|
|
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 === "normal") {
|
|
|
|
|
|
|
|
switchsInfoCopy.forEach(function (sw) {
|
|
|
|
|
|
|
|
switchsInfoCopy.forEach(function (sw) {
|
|
|
|
|
|
|
|
if (getRandomArbitrary(0, 3) === 1) {
|
|
|
|
|
|
|
|
activeSwitch(sw.id);
|
|
|
|
|
|
|
|
checkAllSortieLogique();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function launchTuto() {
|
|
|
|
function launchTuto() {
|
|
|
|
|
|
|
|
document.querySelector("#win_pannel").style.display = "none";
|
|
|
|
document.querySelector(".niveau").innerHTML = niveauActuel;
|
|
|
|
document.querySelector(".niveau").innerHTML = niveauActuel;
|
|
|
|
timer.stop();
|
|
|
|
timer.stop();
|
|
|
|
timer.reset();
|
|
|
|
timer.reset();
|
|
|
@ -912,10 +1041,11 @@ function launchTuto() {
|
|
|
|
while (checkIfEnd()) {
|
|
|
|
while (checkIfEnd()) {
|
|
|
|
resetAllTabs(false);
|
|
|
|
resetAllTabs(false);
|
|
|
|
tuto();
|
|
|
|
tuto();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
document.querySelector("#niveauSuivantText").innerHTML = "Niveau Suivant";
|
|
|
|
|
|
|
|
document.querySelector(".niveauSuivantIcon").className = "fa fa fa-arrow-right niveauSuivantIcon";
|
|
|
|
hideDiv(document.querySelector("#playPage"));
|
|
|
|
hideDiv(document.querySelector("#playPage"));
|
|
|
|
showDiv(document.querySelector("#mainPage"));
|
|
|
|
showDiv(document.querySelector("#mainPage"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|