<commit_before>var io              = require("socket.io");
var gameState       = require("../gameState");
var gameManager     = require("../gameManager");
var Player          = require("../models/Player");
var colors          = require("colors");

exports.addPlayer = function(playerName,socket){
    var newPlayer = new Player(playerName,socket);
    gameState.players.push(newPlayer);
    console.log(playerName + " has joined the lobby.".magenta);

    newPlayer.socket.emit("me",{
        "me": newPlayer.getLobbyInfo(),
        "lobby": gameState.getLobbyState()
    });

    //Let everyone else know
    newPlayer.socket.broadcast.emit("lobby_state",gameState.getLobbyState());

    var playerReady = function(){
        //Make the player ready
        newPlayer.isReady = true;
        console.log(newPlayer.name + " is ready. " + readyPlayerCount() + "/" + gameState.players.length);

        //Call start game if everyone is ready
        if(gameState.players.length > 0 && readyPlayerCount() === gameState.players.length){
            gameManager.startGame();
        }
    };<commit_msg>Emitting lobby state on player ready<commit_after>var io              = require("socket.io");
var gameState       = require("../gameState");
var gameManager     = require("../gameManager");
var Player          = require("../models/Player");
var colors          = require("colors");

exports.addPlayer = function(playerName,socket){
    var newPlayer = new Player(playerName,socket);
    gameState.players.push(newPlayer);
    console.log(playerName + " has joined the lobby.".magenta);

    newPlayer.socket.emit("me",{
        "me": newPlayer.getLobbyInfo(),
        "lobby": gameState.getLobbyState()
    });

    //Let everyone else know
    newPlayer.socket.emit("lobby_state",gameState.getLobbyState());

    var playerReady = function(){
        //Make the player ready
        newPlayer.isReady = true;
        console.log(newPlayer.name + " is ready. " + readyPlayerCount() + "/" + gameState.players.length);

        newPlayer.socket.emit("lobby_state",gameState.getLobbyState());

        //Call start game if everyone is ready
        if(gameState.players.length > 0 && readyPlayerCount() === gameState.players.length){
            gameManager.startGame();
        }
    };
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.0008764241893076249, 'mean_word_length': 2.856418918918919, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 5, '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': '3376083', 'n_tokens_mistral': 649, 'n_tokens_neox': 639, 'n_words': 132}