From 83d30bfd16d313d06545d1dfe60c78d250bdb7ca Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Sat, 10 Dec 2016 11:23:58 +0100 Subject: Add multiple card colors support for BonusPerBoardElement --- src/main/java/org/luxons/sevenwonders/game/boards/Board.java | 4 ++-- .../sevenwonders/game/effects/BonusPerBoardElement.java | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/main/java/org/luxons/sevenwonders') diff --git a/src/main/java/org/luxons/sevenwonders/game/boards/Board.java b/src/main/java/org/luxons/sevenwonders/game/boards/Board.java index c327ed72..b405a566 100644 --- a/src/main/java/org/luxons/sevenwonders/game/boards/Board.java +++ b/src/main/java/org/luxons/sevenwonders/game/boards/Board.java @@ -49,8 +49,8 @@ public class Board { playedCards.add(card); } - public int getNbCardsOfColor(Color color) { - return (int) playedCards.stream().filter(c -> c.getColor() == color).count(); + public int getNbCardsOfColor(List colorFilter) { + return (int) playedCards.stream().filter(c -> colorFilter.contains(c.getColor())).count(); } public Production getProduction() { diff --git a/src/main/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.java b/src/main/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.java index f876328c..57b83054 100644 --- a/src/main/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.java +++ b/src/main/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.java @@ -17,7 +17,7 @@ public class BonusPerBoardElement implements Effect { private BoardElementType type; // only relevant if type=CARD - private Color color; + private List colors; public List getBoards() { return boards; @@ -51,12 +51,12 @@ public class BonusPerBoardElement implements Effect { this.type = type; } - public Color getColor() { - return color; + public List getColors() { + return colors; } - public void setColor(Color color) { - this.color = color; + public void setColors(List colors) { + this.colors = colors; } @Override @@ -87,7 +87,7 @@ public class BonusPerBoardElement implements Effect { private int computeNbOfMatchingElementsIn(Board board) { switch (type) { case CARD: - return board.getNbCardsOfColor(color); + return board.getNbCardsOfColor(colors); case WONDER_LEVEL: return board.getWonderLevel(); case DEFEAT_TOKEN: -- cgit