text: (function() {
  
  var checkVersion = Dagaz.Model.checkVersion;
  
  Dagaz.Model.checkVersion = function(design, name, value) {
    if (name != "longgammon-goal") {
        checkVersion(design, name, value);
    }
  }
  
  var checkGoals = Dagaz.Model.checkGoals;
  
  Dagaz.Model.checkGoals = function(design, board, player) {
    var enemies = 0; var friends = 0;
    _.each(design.allPositions(), function(pos) {
        if (!design.inZone(4, player, pos)) return;
        var piece = board.getPiece(pos);
        if (piece !== null) {
            if (piece.player != player) {
                enemies++;
            } else {
                friends++;
            }
        }
    });
    if (enemies < 1) {
        return -1;
    }
    if (friends < 1) {
        return 1;
    }
    return checkGoals(design, board, player);
  }
  
  })();
  