function initAll() {
    darkMode();
    setLang("fr");
    dysFont();

}

var mobile = false;
var switchs = [], lineCount = [], logiques = [], lines = [], endLines = [], end, switchsInfo = [], switchsInfoCopy = [], lineRemove = [];
var width = window.innerWidth - window.innerWidth / 100 * 30;
var height = window.innerHeight /2.5;
var stage = new Konva.Stage({
    container: 'setting_container',
    width: width,
    height: height,
});
var layer = new Konva.Layer();
tutoCreateLayer();

function tutoCreateLayer() {
    isTuto = true;
    width = window.innerWidth - window.innerWidth / 100 * 30;
    stage = new Konva.Stage({
        container: 'setting_container',
        width: width,
        height: height,
    });
    stage.add(layer);

    colonneTot = 1;
    numberPerColonne = [1];
    var logiqueCount = 0;

    for (let i = 0; i < colonneTot; i++) {
        liveColonneNumber.push([]);
    }
    insertLogiqueColonne("logique1", "et", 0);
    calculNombreSwitch();
    switchCreator(numberOfSwitch);
    createAllLinkSwitch();

    initAllSwitch();
    createEnd();
    initEnd();
}

function resetAllTabs() {
    switchs = [], lineCount = [], logiques = [], lines = [], endLines = [], end, switchsInfo = [], switchsInfoCopy = [], lineRemove = [];
    width = window.innerWidth - window.innerWidth / 100 * 10;
    height = window.innerHeight /1.5;
    timeEnd = 5;

    numberOfSwitch = 0;

    colonneTot = 0;
    numberPerColonne = [];
    liveColonneNumber = [];

    layer.destroyChildren();
}

function gameOne() {
    isTuto = false;
    stage = new Konva.Stage({
        container: 'play_container',
        /*rotation: -90,
        x: 20,
        y: 1000,*/
        width: width,
        height: height,
    });
    stage.add(layer);
    initTimer();
    colonneTot = 2;
    numberPerColonne = [2,1];
    var logiqueCount = 0;

    for (let i = 0; i < colonneTot; i++) {
        liveColonneNumber.push([]);
    }
    for (let i = 0; i < colonneTot; i++) {
        for (let j = 0; j < numberPerColonne[i]; j++) {
            logiqueCount++;
            let type = null;
            switch (getRandomArbitrary(0, 4)) {
                case 0:
                    type = "et";
                    break;
                case 1:
                    type = "ou";
                    break;
                case 2:
                    type = "etnon";
                    break;
                case 3:
                    type = "nonou";
                    break;
            }
            insertLogiqueColonne("logique" + logiqueCount, type, i);
        }
    }
    
    logiques.forEach(function (element) {
        createLinkAuto(element.name);
    });
    calculNombreSwitch();
    switchCreator(numberOfSwitch);
    createAllLinkSwitch();

    initAllSwitch();
    createEnd();
    initEnd();

    checkAllSortieLogique();
}