<commit_before>var Cell = require('./Cell');

function Virus() {
    Cell.apply(this, Array.prototype.slice.call(arguments));
	
    this.cellType = 2;
}

module.exports = Virus;
Virus.prototype = new Cell();

Virus.prototype.calcMove = function () {
    // Only for player controlled movement
}

Virus.prototype.feed = function(feeder,gameServer) {
    this.setAngle(feeder.getAngle()); // Set direction if the virus explodes
    this.mass += 14; // 7 cells to burst the virus
    gameServer.removeNode(feeder);
	
    // Check if the virus is going to explode
    if (this.mass >= gameServer.config.virusBurstMass) {
        this.mass = gameServer.config.virusStartMass; // Reset mass
        gameServer.shootVirus(this);
    }
	
}

// Main Functions

Virus.prototype.onConsume = function(consumer,gameServer) {
    var client = consumer.owner;
    var maxSplits = Math.floor(consumer.mass/16) - 1; // Maximum amount of splits
    var numSplits = gameServer.config.playerMaxCells - client.cells.length; // Get number of splits
    numSplits = Math.min(numSplits,maxSplits);
    var splitMass = Math.min(consumer.mass/(numSplits + 1), 32); // Maximum size of new splits
    
    // Add mass to the cell if its not splitting
    if (numSplits <= 0) {
        cell.addMass(this.mass);
        return;
    }
    
    // Big cells will split into cells larger than 32 mass (1/4 of their mass)
    var bigSplits = 0;
    var endMass = consumer.mass - (numSplits * splitMass);
    if ((endMass > 300) && (numSplits > 0)) {
        bigSplits++;
        numSplits--;
    } 
    if ((endMass > 1200) && (numSplits > 0)) {
        bigSplits++;
        numSplits--;
    }
    
    // Splitting<commit_msg>Fixed crash when eating 2nd virus<commit_after>var Cell = require('./Cell');

function Virus() {
    Cell.apply(this, Array.prototype.slice.call(arguments));
	
    this.cellType = 2;
}

module.exports = Virus;
Virus.prototype = new Cell();

Virus.prototype.calcMove = function () {
    // Only for player controlled movement
}

Virus.prototype.feed = function(feeder,gameServer) {
    this.setAngle(feeder.getAngle()); // Set direction if the virus explodes
    this.mass += 14; // 7 cells to burst the virus
    gameServer.removeNode(feeder);
	
    // Check if the virus is going to explode
    if (this.mass >= gameServer.config.virusBurstMass) {
        this.mass = gameServer.config.virusStartMass; // Reset mass
        gameServer.shootVirus(this);
    }
	
}

// Main Functions

Virus.prototype.onConsume = function(consumer,gameServer) {
    var client = consumer.owner;
    var maxSplits = Math.floor(consumer.mass/16) - 1; // Maximum amount of splits
    var numSplits = gameServer.config.playerMaxCells - client.cells.length; // Get number of splits
    numSplits = Math.min(numSplits,maxSplits);
    var splitMass = Math.min(consumer.mass/(numSplits + 1), 32); // Maximum size of new splits
    
    // Add mass to the cell if its not splitting
    if (numSplits <= 0) {
        consumer.addMass(this.mass);
        return;
    }
    
    // Big cells will split into cells larger than 32 mass (1/4 of their mass)
    var bigSplits = 0;
    var endMass = consumer.mass - (numSplits * splitMass);
    if ((endMass > 300) && (numSplits > 0)) {
        bigSplits++;
        numSplits--;
    } 
    if ((endMass > 1200) && (numSplits > 0)) {
        bigSplits++;
        numSplits--;
    }
    
    // Splitting
{'fraction_non_alphanumeric': 0.12316715542521994, 'fraction_numerical': 0.014956011730205278, 'mean_word_length': 2.667741935483871, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '1149082', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1040, 'n_words': 286}