public int getBarnPoints() { // note: pigHerd has no influence on barn points int points = adjoiningCityOfCarcassonne ? 4 : 0; points += 5 * adjoiningCastles.size(); if (getGame().hasCapability(SiegeCapability.class)) { for (CityScoreContext ctx : adjoiningCompletedCities.values()) { points += 4; if (ctx.isBesieged()) { // count city twice points += 4; } } } else { points += adjoiningCompletedCities.size() * 4; } return points; }
private void addAdjoiningCompletedCities(Feature[] adjoiningCities) { for (Feature feature : adjoiningCities) { if (feature instanceof City) { City c = (City) feature; CityScoreContext ctx = cityCache.get(c); if (ctx == null) { ctx = c.getScoreContext(); ctx.setCityCache(cityCache); c.walk(ctx); } if (ctx.isCompleted()) { adjoiningCompletedCities.put((City) ctx.getMasterFeature(), ctx); } } else if (feature instanceof Castle) { adjoiningCastles.add((Castle) feature.getMaster()); } } }
private int getPlayerPoints(Player player, int pointsPerCity) { int points = adjoiningCityOfCarcassonne ? pointsPerCity : 0; points += (pointsPerCity + 1) * adjoiningCastles.size(); // optimalization if (!getGame().hasCapability(SiegeCapability.class)) { points += pointsPerCity * adjoiningCompletedCities.size(); return points; } for (CityScoreContext ctx : adjoiningCompletedCities.values()) { points += pointsPerCity; if (ctx.isBesieged()) { // count city twice points += pointsPerCity; } } return points; }