if (!(feature instanceof Farm)) {
return new DeploymentCheckResult("The barn must be placed only on a farm.");
}
Farm farm = (Farm) feature;
FarmScoreContext ctx = farm.getScoreContext();
ctx.setCityCache(new HashMap<City, CityScoreContext>());
farm.walk(ctx);
if (!farm.getTile().getGame().hasRule(CustomRule.MULTI_BARN_ALLOWED)) {
for (Special m : ctx.getSpecialMeeples()) {
if (m instanceof Barn) {
return new DeploymentCheckResult("Another barn is already placed on the farm.");
}
}
}
//all ok - score non barn meeples
for (Player owner : ctx.getMajorOwners()) {
int points = ctx.getPoints(owner);
game.scoreFeature(points, ctx, owner);
}
for (Meeple m : ctx.getMeeples()) {
m.undeploy(false);
}
return super.isDeploymentAllowed(feature);
}