diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/luxons/sevenwonders/game/effects/BoardElementType.java | 26 | ||||
-rw-r--r-- | src/main/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.java | 13 |
2 files changed, 26 insertions, 13 deletions
diff --git a/src/main/java/org/luxons/sevenwonders/game/effects/BoardElementType.java b/src/main/java/org/luxons/sevenwonders/game/effects/BoardElementType.java index f2bc2f38..34cab4a4 100644 --- a/src/main/java/org/luxons/sevenwonders/game/effects/BoardElementType.java +++ b/src/main/java/org/luxons/sevenwonders/game/effects/BoardElementType.java @@ -1,5 +1,29 @@ package org.luxons.sevenwonders.game.effects; +import java.util.List; + +import org.luxons.sevenwonders.game.boards.Board; +import org.luxons.sevenwonders.game.cards.Color; + public enum BoardElementType { - CARD, WONDER_LEVEL, DEFEAT_TOKEN + CARD { + @Override + int getElementCount(Board board, List<Color> colors) { + return board.getNbCardsOfColor(colors); + } + }, + WONDER_LEVEL { + @Override + int getElementCount(Board board, List<Color> colors) { + return board.getWonderLevel(); + } + }, + DEFEAT_TOKEN { + @Override + int getElementCount(Board board, List<Color> colors) { + return board.getNbDefeatTokens(); + } + }; + + abstract int getElementCount(Board board, List<Color> colors); } 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 2796b63a..37db3532 100644 --- a/src/main/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.java +++ b/src/main/java/org/luxons/sevenwonders/game/effects/BonusPerBoardElement.java @@ -84,17 +84,6 @@ public class BonusPerBoardElement implements Effect { } private int computeNbOfMatchingElementsIn(Board board) { - switch (type) { - case CARD: - return board.getNbCardsOfColor(colors); - case WONDER_LEVEL: - return board.getWonderLevel(); - case DEFEAT_TOKEN: - return board.getNbDefeatTokens(); - } - throw new UnsupportedBoardElementType(); - } - - private class UnsupportedBoardElementType extends RuntimeException { + return type.getElementCount(board, colors); } } |