You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
2.6 KiB
110 lines
2.6 KiB
function whatIsElement(element) {
|
|
if (findLogique(element.name) == null || findLogique(element.name) == undefined) {
|
|
return "switch";
|
|
} else {
|
|
return "logique";
|
|
}
|
|
}
|
|
|
|
function setLine(logiqueElement, lineId, lineName) {
|
|
logiques.forEach(function (element, index) {
|
|
if (element.name === logiqueElement.name) {
|
|
Object.keys(element).map(function (objectKey, index) {
|
|
if (objectKey == lineId) {
|
|
element[objectKey] = lineName;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function changeLineColor(idLine) {
|
|
let line = stage.findOne("#" + idLine);
|
|
var colorline = line.stroke() == colorLineActive ? colorLineInnactive : colorLineActive;
|
|
line.stroke(colorline);
|
|
}
|
|
function changeLineColorBlack(idLine) {
|
|
let line = stage.findOne("#" + idLine);
|
|
line.stroke(colorLineInnactive);
|
|
}
|
|
function changeLineColorYellow(idLine) {
|
|
let line = stage.findOne("#" + idLine);
|
|
line.stroke(colorLineActive);
|
|
}
|
|
|
|
function checkAllSortieLogique() {
|
|
logiques.forEach(function (element) {
|
|
if (element.id3 != null)
|
|
checkSortieLogique(element.name);
|
|
});
|
|
}
|
|
|
|
function checkSortieLogique(logiqueId) {
|
|
let logique = findLogique(logiqueId);
|
|
logiques.forEach(function (element, index) {
|
|
if (element.name === logique.name) {
|
|
let line1State, line2State;
|
|
let id1Color = stage.findOne("#" + element.id1).stroke();
|
|
let id2Color = stage.findOne("#" + element.id2).stroke();
|
|
if (id1Color == colorLineInnactive) {
|
|
line1State = false;
|
|
} else {
|
|
line1State = true;
|
|
}
|
|
if (id2Color == colorLineInnactive) {
|
|
line2State = false;
|
|
} else {
|
|
line2State = true;
|
|
}
|
|
switch (logique.type) {
|
|
case "et":
|
|
if (line1State == true && line2State == true) {
|
|
changeLineColorYellow(element.id3);
|
|
}
|
|
else {
|
|
changeLineColorBlack(element.id3);
|
|
}
|
|
break;
|
|
case "ou":
|
|
if (line1State == true || line2State == true) {
|
|
changeLineColorYellow(element.id3);
|
|
}
|
|
else {
|
|
changeLineColorBlack(element.id3);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function isElementExisting(elementId) {
|
|
if (stage.findOne("#" + elementId) != null) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function checkLineSwitch(switchId) {
|
|
if (stage.findOne("#" + switchId) != null) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function checkEnd(){
|
|
let ter = true;
|
|
endLines.forEach(function(element){
|
|
if(stage.findOne("#line"+element).stroke() == "black"){
|
|
ter = false;
|
|
|
|
}
|
|
});
|
|
if(ter){
|
|
setTimeout(() => { alert("Niveau terminé"); }, 40);
|
|
}
|
|
}
|
|
|
|
|
|
|