<commit_before>var http = require('http'),
fs = require('fs'),
url = require('url'),
blackjack = require('./lib/blackjack');


var Server = {}
var users = [];

Server.getGame = function (socket, data, callback) {
socket.get('game', function (err, game) {
    callback(socket, game);
});
}

Server.deal = function (socket, data) {
console.log('deal');
Server.getGame(socket, data, function (socket, game) {
    if (!game.isInProgress()) {
        game.newGame();
    }
    socket.emit('deal', game.toJson());
});
}
Server.stand = function (socket, data) {
console.log('stand');
Server.getGame(socket, data, function (socket, game) {
    game.stand();
    socket.emit('stand', game.toJson());
});
}

Server.hit = function (socket, data) {
console.log('hit');
Server.getGame(socket, data, function (socket, game) {
    game.hit();
    socket.emit('hit', game.toJson());
});
}
function getUsers () {
   var userNames = [];
   for(var name in users) {
     if(users[name]) {
       userNames.push(name);  
     }
   }
   return userNames;
}

<<<<<<< HEAD

Server.registerSocketIO = function (io) {
io.sockets.on('connection', function (socket) {
  console.log('User connected'); //logs user connection
 socket.on('adduser', function (user) {
        socket.user = user;
        users.push(user);
        updateClients();
=======
Server.bet = function(socket, data) {
    console.log('bet');
    Server.getGame(socket, data, function(socket, game) {
        game.bet();
        socket.emit('bet', game.toJson());
    });
}

Server.registerSocketIO = function (io) {
    io.sockets.on('connection', function (socket) {
        console.log('User connected');
        socket.set('game', blackjack.newGame())

        socket.on('deal', function (data) {
            Server.deal(socket, data);
        });
        socket.on('stand', function (data) {
            Server.stand(socket, data);
        });
        socket.on('hit', function (data) {
            Server.hit(socket, data);
        });
        socket.on('disconnect', function (socket) {
            console.log('User disconnected');
        });
        socket.on('bet', function(data) {
            Server.bet(socket, data);
        });
>>>>>>> 76106708eafd9f8409e3fdd82d2e2772ac1cd3d7
    });
 //dont touch below
    socket.set('game', blackjack.newGame())

    socket.on('deal', function (data) {
        Server.deal(socket, data);
    });

    socket.on('stand', function (data) {
        Server.stand(socket, data);
    });

    socket.on('hit', function (data) {
        Server.hit(socket, data);
    });

    socket.on('disconnect', function (socket) {<commit_msg>removed weird stuff<commit_after>var http = require('http'),
fs = require('fs'),
url = require('url'),
blackjack = require('./lib/blackjack');


var Server = {}
var users = [];

Server.getGame = function (socket, data, callback) {
socket.get('game', function (err, game) {
    callback(socket, game);
});
}

Server.deal = function (socket, data) {
console.log('deal');
Server.getGame(socket, data, function (socket, game) {
    if (!game.isInProgress()) {
        game.newGame();
    }
    socket.emit('deal', game.toJson());
});
}
Server.stand = function (socket, data) {
console.log('stand');
Server.getGame(socket, data, function (socket, game) {
    game.stand();
    socket.emit('stand', game.toJson());
});
}

Server.hit = function (socket, data) {
console.log('hit');
Server.getGame(socket, data, function (socket, game) {
    game.hit();
    socket.emit('hit', game.toJson());
});
}
function getUsers () {
   var userNames = [];
   for(var name in users) {
     if(users[name]) {
       userNames.push(name);  
     }
   }
   return userNames;
}



Server.registerSocketIO = function (io) {
io.sockets.on('connection', function (socket) {
  console.log('User connected'); //logs user connection
 socket.on('adduser', function (user) {
        socket.user = user;
        users.push(user);
        updateClients();

Server.bet = function(socket, data) {
    console.log('bet');
    Server.getGame(socket, data, function(socket, game) {
        game.bet();
        socket.emit('bet', game.toJson());
    });
}

Server.registerSocketIO = function (io) {
    io.sockets.on('connection', function (socket) {
        console.log('User connected');
        socket.set('game', blackjack.newGame())

        socket.on('deal', function (data) {
            Server.deal(socket, data);
        });
        socket.on('stand', function (data) {
            Server.stand(socket, data);
        });
        socket.on('hit', function (data) {
            Server.hit(socket, data);
        });
        socket.on('disconnect', function (socket) {
            console.log('User disconnected');
        });
        socket.on('bet', function(data) {
            Server.bet(socket, data);
        });
    });
 //dont touch below
    socket.set('game', blackjack.newGame())

    socket.on('deal', function (data) {
        Server.deal(socket, data);
    });

    socket.on('stand', function (data) {
        Server.stand(socket, data);
    });

    socket.on('hit', function (data) {
        Server.hit(socket, data);
    });

    socket.on('disconnect', function (socket) {
{'fraction_non_alphanumeric': 0.18327539590575512, 'fraction_numerical': 0.004634994206257242, 'mean_word_length': 2.8998493975903616, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '4835698', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1598, 'n_words': 330}