From b46021ed267c89cd4060d1aebddb7675da189ac9 Mon Sep 17 00:00:00 2001 From: Roman Krejcik Date: Sun, 22 Aug 2021 14:05:40 +0200 Subject: [PATCH] multiple barns - don't stack --- .../com/jcloisterzone/reducers/ScoreFieldBarn.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/jcloisterzone/reducers/ScoreFieldBarn.java b/src/main/java/com/jcloisterzone/reducers/ScoreFieldBarn.java index 08793ad3..1110fcc9 100644 --- a/src/main/java/com/jcloisterzone/reducers/ScoreFieldBarn.java +++ b/src/main/java/com/jcloisterzone/reducers/ScoreFieldBarn.java @@ -39,11 +39,18 @@ public GameState apply(GameState state) { PointsExpression expr = field.getBarnPoints(state); List receivedPoints = List.empty(); + java.util.Set scoredPlayers = new java.util.HashSet<>(); for (Tuple2 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);