<commit_before>/**
 * Created by ryan on 30/03/16.
 */
var Events = require('polyball/shared/model/behaviors/Events');

/**
 *
 * @param config
 * @property {model} config.model
 * @constructor
 */
var GoalBehavior = function(config){

    var handleCollision = function(event){
        var player = config.model.getPlayer(event.ball.lastTouchedID);
        player.score += 1;
    };

    // extended
    this.connect = function () {
        config.model.getWorld().on(Events.ballGoalCollision, handleCollision, this);
    };
<commit_msg>Fixed server crash on player disconnect - goal scoring. Closes #178<commit_after>/**
 * Created by ryan on 30/03/16.
 */
var Events = require('polyball/shared/model/behaviors/Events');

/**
 *
 * @param config
 * @property {model} config.model
 * @constructor
 */
var GoalBehavior = function(config){

    var handleCollision = function(event){
        var player = config.model.getPlayer(event.ball.lastTouchedID);
        if (player != null){
            player.score += 1;
        }
    };

    // extended
    this.connect = function () {
        config.model.getWorld().on(Events.ballGoalCollision, handleCollision, this);
    };

{'fraction_non_alphanumeric': 0.1423699914748508, 'fraction_numerical': 0.014492753623188406, 'mean_word_length': 2.9662162162162162, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2228065', 'n_tokens_mistral': 372, 'n_tokens_neox': 352, 'n_words': 76}