Skip to content

Commit

Permalink
multiple barns - don't stack
Browse files Browse the repository at this point in the history
  • Loading branch information
farin committed Aug 22, 2021
1 parent fa79e61 commit b46021e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/com/jcloisterzone/reducers/ScoreFieldBarn.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,18 @@ public GameState apply(GameState state) {

PointsExpression expr = field.getBarnPoints(state);
List<ReceivedPoints> receivedPoints = List.empty();
java.util.Set<Player> scoredPlayers = new java.util.HashSet<>();

for (Tuple2<Special, FeaturePointer> t : barns) {
Barn barn = (Barn) t._1;
playerPoints = playerPoints.put(barn.getPlayer(), expr);
receivedPoints = receivedPoints.append(new ReceivedPoints(expr, barn.getPlayer(), t._2));
Player player = barn.getPlayer();
if (scoredPlayers.contains(player)) {
// player has multiple barns on same field, score only once (special meeples doesn't stack)
continue;
}
playerPoints = playerPoints.put(player, expr);
receivedPoints = receivedPoints.append(new ReceivedPoints(expr, player, t._2));
scoredPlayers.add(player);
}

return (new AddPoints(receivedPoints, true, isFinal)).apply(state);
Expand Down

0 comments on commit b46021e

Please sign in to comment.