<commit_before>/*** Created by Peter on 02.02.2015.*/

function heroMove(miniature, character) {
    var characterAPs = character.move;
    document.getElementById("movement_counter").innerHTML = "Очки ходу: " + characterAPs;
    var battleFieldCoords = $("#battle_field").offset();
    miniatureWaiting(miniature, battleFieldCoords);
    availableCells(miniature, battleFieldCoords, character, characterAPs);
}

function moveAction(miniature, currCoords, battleFieldCoords, character, characterAPs) {
    while (document.getElementById("battle_field").hasChildNodes()) {
        document.getElementById("battle_field").removeChild(document.getElementById("battle_field").childNodes[0]);
    }
    var heroMiniature;
    heroMiniature = document.createElement("DIV");
    heroMiniature.setAttribute("id", "hero_miniature");
    document.getElementById("battle_field").appendChild(heroMiniature);
    $("#" + miniature).offset({top: currCoords.top, left: currCoords.left});
    characterAPs--;
    document.getElementById("movement_counter").innerHTML = "Очки ходу: " + characterAPs;
    availableCells(miniature, battleFieldCoords, character, characterAPs);
}

function miniatureWaiting(miniature, battleFieldCoords) {
    $("#" + miniature).offset({top: battleFieldCoords.top, left: (battleFieldCoords.left + 60)});
    setInterval(function(){
        document.getElementById(miniature).style.opacity == 0.2 ?
            document.getElementById(miniature).style.opacity = 1.0 :
            document.getElementById(miniature).style.opacity = 0.2;
    }, 500);
}

function availableCells(miniature, battleFieldCoords, character, characterAPs) {
    var movementCell;
    var charCoords = $("#" + miniature).offset();
    tempCells(charCoords, battleFieldCoords, characterAPs);
    if (characterAPs > 0) {
        // movement UP
        if (charCoords.top !== (battleFieldCoords.top)) {
            movementCell = document.createElement("DIV");
            movementCell.setAttribute("id", "movement_cell_1");
            movementCell.setAttribute("class", "movement_cell");
            document.getElementById("battle_field").appendChild(movementCell);
            $("#movement_cell_1")
                .offset({top: (charCoords.top - 20), left: charCoords.left})
                .on("click", function () {
                    moveAction(miniature, $("#movement_cell_1").offset(), battleFieldCoords, character, characterAPs);
                });
        }
        // movement LEFT
        if (charCoords.left !== (battleFieldCoords.left)) {
            movementCell = document.createElement("DIV");
            movementCell.setAttribute("id", "movement_cell_2");
            movementCell.setAttribute("class", "movement_cell");
            document.getElementById("battle_field").appendChild(movementCell);
            $("#movement_cell_2")
                .offset({top: charCoords.top, left: (charCoords.left - 20)})
                .on("click", function () {
                    moveAction(miniature, $("#movement_cell_2").offset(), battleFieldCoords, character, characterAPs);
                });
        }
        // movement DOWN
        if (charCoords.top !== (battleFieldCoords.top + 220)) {
            movementCell = document.createElement("DIV");
            movementCell.setAttribute("id", "movement_cell_3");
            movementCell.setAttribute("class", "movement_cell");
            document.getElementById("battle_field").appendChild(movementCell);
            $("#movement_cell_3")
                .offset({top: (charCoords.top + 20), left: charCoords.left})
                .on("click", function () {
                    moveAction(miniature, $("#movement_cell_3").offset(), battleFieldCoords, character, characterAPs);
                });
        }
        // movement RIGHT
        if (charCoords.left !== (battleFieldCoords.left + 440)) {
            movementCell = document.createElement("DIV");
            movementCell.setAttribute("id", "movement_cell_4");
            movementCell.setAttribute("class", "movement_cell");
            document.getElementById("battle_field").appendChild(movementCell);
            $("#movement_cell_4")
                .offset({top: charCoords.top, left: (charCoords.left + 20)})
                .on("click", function () {
                    moveAction(miniature, $("#movement_cell_4").offset(), battleFieldCoords, character, characterAPs);
                });
        }
    }
    else {
        document.getElementById("movement_counter").innerHTML = "Очки ходу: ЗАКІНЧИЛИСЯ";
    }
}

function tempCells (charCoords, battleFieldCoords, characterAPs) {
    var i;
    var tempCell;
    var counter;
    var offsetVal;
    var offsetTop;
    var lineWidth;
    var lineWidthFinal;
    function check(tempCellCoords, lineWidth, battleFieldCoords) {
        if (tempCellCoords.top < battleFieldCoords.top ||
            tempCellCoords.top > battleFieldCoords.top + 220) {
            document.getElementById("battle_field").removeChild(document.getElementById("temp_cell_1"));<commit_msg>Gamebook day-34-2<commit_after>/*** Created by Peter on 02.02.2015.*/

function heroMove(miniature, character) {
    var characterAPs = character.move;
    document.getElementById("movement_counter").innerHTML = "Очки ходу: " + characterAPs;
    var battleFieldCoords = $("#battle_field").offset();
    miniatureWaiting(miniature, battleFieldCoords);
    availableCells(miniature, battleFieldCoords, character, characterAPs);
}

function moveAction(miniature, currCoords, battleFieldCoords, character, characterAPs) {
    while (document.getElementById("battle_field").hasChildNodes()) {
        document.getElementById("battle_field").removeChild(document.getElementById("battle_field").childNodes[0]);
    }
    var heroMiniature;
    heroMiniature = document.createElement("DIV");
    heroMiniature.setAttribute("id", "hero_miniature");
    document.getElementById("battle_field").appendChild(heroMiniature);
    $("#" + miniature).offset({top: currCoords.top, left: currCoords.left});
    characterAPs--;
    document.getElementById("movement_counter").innerHTML = "Очки ходу: " + characterAPs;
    availableCells(miniature, battleFieldCoords, character, characterAPs);
}

function miniatureWaiting(miniature, battleFieldCoords) {
    $("#" + miniature).offset({top: battleFieldCoords.top, left: (battleFieldCoords.left + 60)});
    setInterval(function(){
        document.getElementById(miniature).style.opacity == 0.2 ?
            document.getElementById(miniature).style.opacity = 1.0 :
            document.getElementById(miniature).style.opacity = 0.2;
    }, 500);
}

function availableCells(miniature, battleFieldCoords, character, characterAPs) {
    var movementCell;
    var charCoords = $("#" + miniature).offset();
    tempCells(charCoords, battleFieldCoords, characterAPs);
    if (characterAPs > 0) {
        // movement UP
        if (charCoords.top !== (battleFieldCoords.top)) {
            movementCell = document.createElement("DIV");
            movementCell.setAttribute("id", "movement_cell_1");
            movementCell.setAttribute("class", "movement_cell");
            document.getElementById("battle_field").appendChild(movementCell);
            $("#movement_cell_1")
                .offset({top: (charCoords.top - 20), left: charCoords.left})
                .on("click", function () {
                    moveAction(miniature, $("#movement_cell_1").offset(), battleFieldCoords, character, characterAPs);
                });
        }
        // movement LEFT
        if (charCoords.left !== (battleFieldCoords.left)) {
            movementCell = document.createElement("DIV");
            movementCell.setAttribute("id", "movement_cell_2");
            movementCell.setAttribute("class", "movement_cell");
            document.getElementById("battle_field").appendChild(movementCell);
            $("#movement_cell_2")
                .offset({top: charCoords.top, left: (charCoords.left - 20)})
                .on("click", function () {
                    moveAction(miniature, $("#movement_cell_2").offset(), battleFieldCoords, character, characterAPs);
                });
        }
        // movement DOWN
        if (charCoords.top !== (battleFieldCoords.top + 220)) {
            movementCell = document.createElement("DIV");
            movementCell.setAttribute("id", "movement_cell_3");
            movementCell.setAttribute("class", "movement_cell");
            document.getElementById("battle_field").appendChild(movementCell);
            $("#movement_cell_3")
                .offset({top: (charCoords.top + 20), left: charCoords.left})
                .on("click", function () {
                    moveAction(miniature, $("#movement_cell_3").offset(), battleFieldCoords, character, characterAPs);
                });
        }
        // movement RIGHT
        if (charCoords.left !== (battleFieldCoords.left + 440)) {
            movementCell = document.createElement("DIV");
            movementCell.setAttribute("id", "movement_cell_4");
            movementCell.setAttribute("class", "movement_cell");
            document.getElementById("battle_field").appendChild(movementCell);
            $("#movement_cell_4")
                .offset({top: charCoords.top, left: (charCoords.left + 20)})
                .on("click", function () {
                    moveAction(miniature, $("#movement_cell_4").offset(), battleFieldCoords, character, characterAPs);
                });
        }
    }
    else {
        document.getElementById("movement_counter").innerHTML = "Очки ходу: ЗАКІНЧИЛИСЯ";
        enemyTurn();
    }
}

function tempCells (charCoords, battleFieldCoords, characterAPs) {
    var i;
    var tempCell;
    var counter;
    var offsetVal;
    var offsetTop;
    var lineWidth;
    var lineWidthFinal;
    function check(tempCellCoords, lineWidth, battleFieldCoords) {
        if (tempCellCoords.top < battleFieldCoords.top ||
            tempCellCoords.top > battleFieldCoords.top + 220) {
            document.getElementById("battle_field").removeChild(document.getElementById("temp_cell_1"));
{'fraction_non_alphanumeric': 0.13381465730392642, 'fraction_numerical': 0.010384729502522005, 'mean_word_length': 3.0561572402727637, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6028951', 'n_tokens_mistral': 2887, 'n_tokens_neox': 2804, 'n_words': 447}