<commit_before>var playerName;
var playerNameInput = document.getElementById('playerNameInput');
var socket;
var KEY_ENTER = 13;


function startGame() {
    playerName = playerNameInput.value.replace(/(<([^>]+)>)/ig, '');
    document.getElementById('gameAreaWrapper').style.display = 'block';
    document.getElementById('startMenuWrapper').style.display = 'none';
    socket = io();
    SetupSocket(socket);
    animloop();
}

// check if nick is valid alphanumeric characters (and underscores)
function validNick() {
    var regex = /^\w*$/;
    console.log("Regex Test", regex.exec(playerNameInput.value));
    return regex.exec(playerNameInput.value) !== null;
}

window.onload = function() {
    'use strict';

    var btn = document.getElementById('startButton'),
        nickErrorText = document.querySelector('#startMenu .input-error');

    btn.onclick = function () {

        // check if the nick is valid
        if (validNick()) {
            startGame();
        } else {
            nickErrorText.style.display = 'inline';
        }
    };

    playerNameInput.addEventListener('keypress', function (e) {
        var key = e.which || e.keyCode;

        if (key === KEY_ENTER) {
            if (validNick()) {
                startGame();
            } else {
                nickErrorText.style.display = 'inline';
            }
        }
    });
};

// Canvas
var screenWidth = window.innerWidth;
var screenHeight = window.innerHeight;
var gameWidth = screenWidth * 10;
var gameHeight = screenHeight * 10;
var xoffset = -gameWidth;
var yoffset = -gameHeight;

var gameStart = false;
var disconnected = false;
var died = false;
var kicked = false;

var startPingTime = 0;

var chatCommands = {};
var backgroundColor = '#EEEEEE';

var foodConfig = {
    border: 0,
    borderColor: '#f39c12',
    fillColor: '#f1c40f',
    size: 10
};

var playerConfig = {
    border: 15,
    textColor: '#FFFFFF',
    textBorder: '#000000',
    textBorderSize: 3,
    defaultSize: 30
};

var enemyConfig = {
    border: 15,
    textColor: '#FFFFFF',
    textBorder: '#000000',
    textBorderSize: 3,
    defaultSize: 30
};

var player = {
    id: -1,
    x: gameWidth / 2, y: gameHeight / 2,
    mass: 0, speed: 20,
    //TODO: exclude width and height out of player package
    screenWidth: screenWidth,
    screenHeight: screenHeight,
    gameWidth: gameWidth,
    gameHeight: gameHeight
};

var foods = [];
var enemies = [];
var target = {x: player.x, y: player.y};

var c = document.getElementById('cvs');
c.addEventListener('mousemove', gameInput, false);
c.width = screenWidth; c.height = screenHeight;
c.addEventListener('mouseout', outOfBounds, false);

// register when the mouse goes off the canvas
function outOfBounds() {
    target = { x : screenWidth / 2, y : screenHeight / 2 };
}



var graph = c.getContext('2d');

var chatInput = document.getElementById('chatInput');
chatInput.addEventListener('keypress', sendChat);

// Chat
function addChatLine(name, text) {<commit_msg>Decreased max speed so it's like Original Agar.io<commit_after>var playerName;
var playerNameInput = document.getElementById('playerNameInput');
var socket;
var KEY_ENTER = 13;


function startGame() {
    playerName = playerNameInput.value.replace(/(<([^>]+)>)/ig, '');
    document.getElementById('gameAreaWrapper').style.display = 'block';
    document.getElementById('startMenuWrapper').style.display = 'none';
    socket = io();
    SetupSocket(socket);
    animloop();
}

// check if nick is valid alphanumeric characters (and underscores)
function validNick() {
    var regex = /^\w*$/;
    console.log("Regex Test", regex.exec(playerNameInput.value));
    return regex.exec(playerNameInput.value) !== null;
}

window.onload = function() {
    'use strict';

    var btn = document.getElementById('startButton'),
        nickErrorText = document.querySelector('#startMenu .input-error');

    btn.onclick = function () {

        // check if the nick is valid
        if (validNick()) {
            startGame();
        } else {
            nickErrorText.style.display = 'inline';
        }
    };

    playerNameInput.addEventListener('keypress', function (e) {
        var key = e.which || e.keyCode;

        if (key === KEY_ENTER) {
            if (validNick()) {
                startGame();
            } else {
                nickErrorText.style.display = 'inline';
            }
        }
    });
};

// Canvas
var screenWidth = window.innerWidth;
var screenHeight = window.innerHeight;
var gameWidth = screenWidth * 10;
var gameHeight = screenHeight * 10;
var xoffset = -gameWidth;
var yoffset = -gameHeight;

var gameStart = false;
var disconnected = false;
var died = false;
var kicked = false;

var startPingTime = 0;

var chatCommands = {};
var backgroundColor = '#EEEEEE';

var foodConfig = {
    border: 0,
    borderColor: '#f39c12',
    fillColor: '#f1c40f',
    size: 10
};

var playerConfig = {
    border: 15,
    textColor: '#FFFFFF',
    textBorder: '#000000',
    textBorderSize: 3,
    defaultSize: 30
};

var enemyConfig = {
    border: 15,
    textColor: '#FFFFFF',
    textBorder: '#000000',
    textBorderSize: 3,
    defaultSize: 30
};

var player = {
    id: -1,
    x: gameWidth / 2, y: gameHeight / 2,
    mass: 0, speed: 8,
    //TODO: exclude width and height out of player package
    screenWidth: screenWidth,
    screenHeight: screenHeight,
    gameWidth: gameWidth,
    gameHeight: gameHeight
};

var foods = [];
var enemies = [];
var target = {x: player.x, y: player.y};

var c = document.getElementById('cvs');
c.addEventListener('mousemove', gameInput, false);
c.width = screenWidth; c.height = screenHeight;
c.addEventListener('mouseout', outOfBounds, false);

// register when the mouse goes off the canvas
function outOfBounds() {
    target = { x : screenWidth / 2, y : screenHeight / 2 };
}



var graph = c.getContext('2d');

var chatInput = document.getElementById('chatInput');
chatInput.addEventListener('keypress', sendChat);

// Chat
function addChatLine(name, text) {
{'fraction_non_alphanumeric': 0.13652217239661185, 'fraction_numerical': 0.015778109948513537, 'mean_word_length': 3.104976141785958, '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': '1406492', 'n_tokens_mistral': 1904, 'n_tokens_neox': 1797, 'n_words': 487}