<commit_before>/// / socket stuff.
function setupSocket(socket) {

    // Handle error.
    socket.on('connect_failed', function () {
        socket.close();
        disconnected = true;
    });

    socket.on('disconnect', function () {
        socket.close();
        disconnected = true;
    });

    // Handle connection.
    socket.on('welcome', function (playerSettings) {
        player = playerSettings;

        player.name = playerName;
        player.screenWidth = screenWidth;
        player.screenHeight = screenHeight;
        player.target = target;
        console.log('Player');
        console.log(player);
        document.getElementById('munitionPoint').innerHTML = player.munitions;
        document.getElementById('lifePoint').innerHTML = player.life;
        socket.emit('gotit', player);
        gameStart = true;

        gameCanvas.focus();
    });

    socket.on('gameSetup', function (data) {
        gameWidth = data.gameWidth;
        gameHeight = data.gameHeight;

        resize();
    });

    socket.on('leaderboard', function (data) {
        leaderboard = data.leaderboard;
        var status = '<span class="title">Connected</span>';
        miniMapFrame.clearRect(0, 0, gameWidth, gameHeight);
        var pictoWidth = 8, pictoHeight = 8;

        if (screenWidth >= 320 && screenWidth <= 767) {
            pictoWidth = pictoHeight = 30;
        }
        for (var i = 0; i < leaderboard.length; i++) {
            status += '<br />';
            if (leaderboard[i].id == player.id) {
                if (leaderboard[i].name.length !== 0) {
                    status += '<span class="me">' + (i + 1) + '. ' + leaderboard[i].name + "</span>";
                    miniMapFrame.fillStyle = "#00FF00";

                } else {
                    status += '<span class="me">' + (i + 1) + ". An unnamed cell</span>";
                }
            } else {
                if (leaderboard[i].name.length !== 0) {
                    status += (i + 1) + '. ' + leaderboard[i].name;
                    miniMapFrame.fillStyle = "#FF0000";

                } else
                    status += (i + 1) + '. An unnamed cell';
            }
            if (!leaderboard[i].isInSuperVessel || leaderboard[i].isDisplayer) {
                if (leaderboard[i].isDisplayer)
                    miniMapFrame.fillStyle = "#FFFFFF";

                miniMapFrame.fillRect(0.98 * miniMap.width * leaderboard[i].x / gameWidth, 0.97 * miniMap.height * leaderboard[i].y / gameHeight, pictoWidth, pictoHeight);
            }
        }
        //status += '<br />Players: ' + data.players;
        document.getElementById('status').innerHTML = status;
    });

    // Handle movement.
    socket.on('serverTellPlayerMove', function (userData, foodsList, massList, virusList, objectList) {
        var playerData;
        for (var i = 0; i < userData.length; i++) {
            if (typeof(userData[i].id) == "undefined") {
                playerData = userData[i];

                i = userData.length;
            }
        }
        if (playerType == 'player') {
            if (playerData) {
                var xoffset = player.x - playerData.x;
                var yoffset = player.y - playerData.y;
                player.x = playerData.x;
                player.y = playerData.y;
                player.hue = playerData.hue;
                player.massTotal = playerData.massTotal;
                player.cells = playerData.cells;
                player.xoffset = isNaN(xoffset) ? 0 : xoffset;<commit_msg>minimap interface begin<commit_after>/// / socket stuff.
function setupSocket(socket) {

    // Handle error.
    socket.on('connect_failed', function () {
        socket.close();
        disconnected = true;
    });

    socket.on('disconnect', function () {
        socket.close();
        disconnected = true;
    });

    // Handle connection.
    socket.on('welcome', function (playerSettings) {
        player = playerSettings;

        player.name = playerName;
        player.screenWidth = screenWidth;
        player.screenHeight = screenHeight;
        player.target = target;
        console.log('Player');
        console.log(player);
        document.getElementById('munitionPoint').innerHTML = player.munitions;
        document.getElementById('lifePoint').innerHTML = player.life;
        socket.emit('gotit', player);
        gameStart = true;

        gameCanvas.focus();
    });

    socket.on('gameSetup', function (data) {
        gameWidth = data.gameWidth;
        gameHeight = data.gameHeight;

        resize();
    });

    socket.on('leaderboard', function (data) {
        leaderboard = data.leaderboard;
        var status = '<span class="title">Connected</span>';
        miniMapFrame.clearRect(0, 0, gameWidth, gameHeight);
        var pictoWidth = 8, pictoHeight = 8;

        if (screenWidth >= 320 && screenWidth <= 767) {
            pictoWidth = pictoHeight = 30;
        }
        for (var i = 0; i < leaderboard.length; i++) {
            status += '<br />';
            //The point in miniMap that present me
            if (leaderboard[i].id == player.id) {
                if (leaderboard[i].name.length !== 0) {
                    status += '<span class="me">' + (i + 1) + '. ' + leaderboard[i].name + "</span>";
                    miniMapFrame.fillStyle = "#00FF00";

                } else {
                    status += '<span class="me">' + (i + 1) + ". An unnamed cell</span>";
                }
            }
            //The point in miniMap that present the other players
            else {
                if (leaderboard[i].name.length !== 0) {
                    status += (i + 1) + '. ' + leaderboard[i].name;
                    miniMapFrame.fillStyle = "#FF0000";

                } else
                    status += (i + 1) + '. An unnamed cell';
            }
            //The point in miniMap that present the super vaisseau
            if (!leaderboard[i].isInSuperVessel || leaderboard[i].isDisplayer) {
                if (leaderboard[i].isDisplayer)
                    miniMapFrame.fillStyle = "#FFFFFF";

                miniMapFrame.fillRect(0.98 * miniMap.width * leaderboard[i].x / gameWidth, 0.97 * miniMap.height * leaderboard[i].y / gameHeight, pictoWidth, pictoHeight);
            }
        }
        //status += '<br />Players: ' + data.players;
        document.getElementById('status').innerHTML = status;
    });

    // Handle movement.
    socket.on('serverTellPlayerMove', function (userData, foodsList, massList, virusList, objectList) {
        var playerData;
        for (var i = 0; i < userData.length; i++) {
            if (typeof(userData[i].id) == "undefined") {
                playerData = userData[i];

                i = userData.length;
            }
        }
        if (playerType == 'player') {
            if (playerData) {
                var xoffset = player.x - playerData.x;
                var yoffset = player.y - playerData.y;
                player.x = playerData.x;
                player.y = playerData.y;
                player.hue = playerData.hue;
                player.massTotal = playerData.massTotal;
                player.cells = playerData.cells;
                player.xoffset = isNaN(xoffset) ? 0 : xoffset;
{'fraction_non_alphanumeric': 0.1354625550660793, 'fraction_numerical': 0.009636563876651983, 'mean_word_length': 1.733258088788563, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, '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': '3272385', 'n_tokens_mistral': 2120, 'n_tokens_neox': 1961, 'n_words': 430}