<commit_before>var
PlayerCollection = function() {
var playerCollection = {},
    players = [],
    currentIndex 
    ;
    
    playerCollection.addPlayer = function(player) {
        players.push(player);
    };
    
    playerCollection.reset = function() {
        currentIndex = 0;
    };
    
    playerCollection.getCurrentPlayer = function() {
        return players[currentIndex];
    };
    
    playerCollection.next = function() {
        currentIndex = (currentIndex + 1) % players.length;
        return players[currentIndex];
    };
    
    playerCollection.notifyAll = function(event, data) {
        var i;
        for (i = players.length - 1; i >= 0; i--) {
            players[i].notify(event, data);
        }
    };
    
    playerCollection.notifyOthers = function(event, data, player) {
        var i;
        for (i = players.length - 1; i >= 0; i--) {
            if (players[i] != player) {
                players[i].notify(event, data);
            }
        }        
    };
    
    playerCollection.length = function() {
        return players.length;
    }
    
    
    playerCollection.reset();
    
    return playerCollection;
}
;

module.exports = PlayerCollection;<commit_msg>PlayerCollection: reverse turn supported, minor jslint changes<commit_after>var
PlayerCollection = function() {
var playerCollection = {},
    players = [],
    currentIndex,
    nextPlayerOffset = 1,
    getNextPlayerIndex = function() {
        var nextPlayerIndex = currentIndex + nextPlayerOffset,
            mod = players.length
            ;
        
        // % is the remainder operator in javascript, not the modulo
        // we have to do this little trick to handle the
        // 0 -> -1 transition.
        return (((nextPlayerIndex % mod) + mod) % mod);
    }
    ;
    
    playerCollection.addPlayer = function(player) {
        players.push(player);
    };
    
    playerCollection.reset = function() {
        currentIndex = 0;
    };
    
    playerCollection.getCurrentPlayer = function() {
        return players[currentIndex];
    };
    
    playerCollection.getNextPlayer = function() {
        return players[getNextPlayerIndex()];    
    };
    
    playerCollection.next = function() {
        currentIndex = getNextPlayerIndex();
        return players[currentIndex];
    };
    
    playerCollection.reverseTurn = function() {
        nextPlayerOffset *= (-1);
    };
    
    playerCollection.notifyAll = function(event, data) {
        var i;
        for (i = 0; i < players.length; i++) {
            players[i].notify(event, data);
        }
    };
    
    playerCollection.notifyOthers = function(event, data, player) {
        var i;
        for (i = players.length - 1; i >= 0; i--) {
            if (players[i] !== player) {
                players[i].notify(event, data);
            }
        }        
    };
    
    playerCollection.length = function() {
        return players.length;
    };
    
    
    playerCollection.reset();
    
    return playerCollection;
}
;

module.exports = PlayerCollection;
{'fraction_non_alphanumeric': 0.11599869664385794, 'fraction_numerical': 0.004561746497230368, 'mean_word_length': 1.9293893129770991, 'pattern_counts': {'":': 0, '<': 4, '<?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': '6800517', 'n_tokens_mistral': 850, 'n_tokens_neox': 841, 'n_words': 181}