<commit_before>
var socket = io();

var words = [
    {word:"word1", action:"bomb"},
    {word:"word2", action:"bomb"},
    {word:"word3", action:"bomb"},
    {word:"word4", action:"bomb"},
    {word:"word5", action:"bomb"},
    {word:"word6", action:"bomb"},
    {word:"word7", action:"bomb"},
    {word:"word8", action:"bomb"},
    {word:"word9", action:"bomb"},
    {word:"word10", action:"+3"},
    {word:"word11", action:"+2"}
];

var gifBombs = [
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"}
];

var players = [
    {name:"doofus", avatar:"img/doofus.png"},
    {name:"doggy", avatar:"img/doggy.png"},
    {name:"cat", avatar:"img/cat.png"}
];

var collectedGifBombs = [];

var currentPlayerTarget = players[0];

var me;

init();

function init() {
    
    // voice recognition
    var commandWord = "whatever";
    annyang.addCommands({commandWord: function(){alert("whatever!");}});
    
    var greeting = function(term) {
        console.log('say:', term);
        // $console.text(term);
        socketSend({event: 'chat', body: term});
    }
    
    //$console.text(term);
    
    //socketSend({event: 'chat', body: term});
    
    //annyang.start({ autoRestart: false, continuous: false });
    var commands = {
      // By defining a part of the following command as optional, annyang will respond to both:
      // "say hello to my little friend" as well as "say hello friend"
      'say *term': greeting
    };

    // Add our commands to annyang
    annyang.addCommands(commands);
    annyang.debug();
    // Start listening. You can call this here, or attach this call to an event, button, etc.
    annyang.start({ autoRestart: true });
    annyang.addCommands({"hello": function(){alert("hi!");}});
    annyang.addCommands({"monkey": function(){alert("goodbye!");}});
}


// multiplayer socket.io shit

function socketSend(message){
    socket.emit('message', message);
}

socket.on('message', function(message){
    alert("message received:" + message.body);
  console.log(message);
    switch(message.event) {
    case "chat":
        console.log("word received thru socket: " + message.body);
    break;
    case "setPlayer":
        me = getPlayerByName(message.body).name;
    break;
    case "removeCommand":
        removeCommand(message.body); // would be a commandName
    break;
    case "gifBomb":
        if(message.body.target == "all") {
            receiveGifBomb(message.body); // would be a gifName
        } else {
            if (me == getPlayerByName(message.body.target)){
                receiveGifBomb(message.body); // would be a gifName
            }
        }
    break;
    }
});


// game functions

function registerPlayers() {
    // numPlayers gets set from reading how many in the socket
    var numPlayers = 3;
    for(var i=0; i<numPlayers; i++) {
        
    }
}

function addGifBombToArsenal(gifName) {
    var gifBomb = getGifBombByName(gifName);
    collectedGifBombs.push(gifBomb);
    addCommand(gifBomb.name, function(){
        sendGifBomb(gifBomb.name, currentPlayerTarget);
    });
}

function sendGifBomb(gifName, target) {
    var gifBomb = getGifBombByName(gifName);

    // socket code
    if(target == "all") {

    }
}

function receiveGifBomb(gifName) {
    for(var i=0; i<gifBombs.length; i++) {
        if(gifName == gifBombs[i].name) {
            // ui display Gif fullscreen
        }
    }
}

////////////////////////////
// util functions
function getGifBombByName(gifName) {
    for(var i=0; i<gifBombs.length; i++) {<commit_msg>add test words at top of engine.js<commit_after>
var socket = io();

var words = [
    {word:"supercalifragilisticexpialidocious", action:"bomb"},
    {word:"silly", action:"bomb"},
    {word:"penis", action:"bomb"},
    {word:"nipple", action:"bomb"},
    {word:"shocker", action:"bomb"},
    {word:"dildo", action:"bomb"},
    {word:"socket", action:"bomb"},
    {word:"pickle", action:"bomb"},
    {word:"stank", action:"bomb"},
    {word:"twat", action:"bomb"},
    {word:"snatch", action:"bomb"},
    {word:"thong", action:"+3"},
    {word:"spank", action:"+2"}
];

var gifBombs = [
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"},
    {name:"cat", src:"img/cat.gif"}
];

var players = [
    {name:"doofus", avatar:"img/doofus.png"},
    {name:"doggy", avatar:"img/doggy.png"},
    {name:"cat", avatar:"img/cat.png"}
];

var collectedGifBombs = [];

var currentPlayerTarget = players[0];

var me;

init();

function init() {
    // voice recognition
    annyang.start({ autoRestart: true });
    
    for(var i=0; i<words.length; i++) {
        var word = words[i].word
        annyang.addCommands({[word]: function(){alert("word matched!");}});
    }
    
    var greeting = function(term) {
        console.log('say:', term);
        // $console.text(term);
        socketSend({event: 'chat', body: term});
    }
    
    var commands = {
      // By defining a part of the following command as optional, annyang will respond to both:
      // "say hello to my little friend" as well as "say hello friend"
      'say *term': greeting
    };
    
    // Add our commands to annyang
    
    annyang.debug();
    
    // Start listening. You can call this here, or attach this call to an event, button, etc.
    annyang.addCommands(commands);
    //annyang.start({ autoRestart: false, continuous: false });
}


// multiplayer socket.io shit

function socketSend(message){
    socket.emit('message', message);
}

socket.on('message', function(message){
    switch(message.event) {
    case "chat":
        console.log("word received thru socket: " + message.body);
    break;
    case "setPlayer":
        me = getPlayerByName(message.body).name;
    break;
    case "removeCommand":
        removeCommand(message.body); // would be a commandName
    break;
    case "gifBomb":
        if(message.body.target == "all") {
            receiveGifBomb(message.body.gifName); // would be a gifName
        } else {
            if (me == getPlayerByName(message.body.target)){
                receiveGifBomb(message.body.gifName); // would be a gifName
            }
        }
    break;
    }
});


// game functions

function registerPlayers() {
    // numPlayers gets set from reading how many in the socket
    var numPlayers = 3;
    for(var i=0; i<numPlayers; i++) {
        
    }
}

function addGifBombToArsenal(gifName) {
    var gifBomb = getGifBombByName(gifName);
    collectedGifBombs.push(gifBomb);
    addCommand(gifBomb.name, function(){
        sendGifBomb(gifBomb.name, currentPlayerTarget);
    });
}

function sendGifBomb(gifName, target) {
    var gifBomb = getGifBombByName(gifName);

    // socket code
    socketSend({event: 'gifBomb', body: {target: target, gifName: gifName}});
}

function receiveGifBomb(gifName) {
    for(var i=0; i<gifBombs.length; i++) {
        if(gifName == gifBombs[i].name) {
            // ui display Gif fullscreen
        }
    }
}

////////////////////////////
// util functions
function getGifBombByName(gifName) {
    for(var i=0; i<gifBombs.length; i++) {
{'fraction_non_alphanumeric': 0.1853708702918113, 'fraction_numerical': 0.0035994343745982776, 'mean_word_length': 2.888055972013993, 'pattern_counts': {'":': 10, '<': 10, '<?xml version=': 0, '>': 3, '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': '2315002', 'n_tokens_mistral': 2659, 'n_tokens_neox': 2618, 'n_words': 559}