summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/boards/Board.java4
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbility.java17
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.java2
3 files changed, 21 insertions, 2 deletions
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 85820e8d..31bb6c9f 100644
--- a/src/main/java/org/luxons/sevenwonders/game/boards/Board.java
+++ b/src/main/java/org/luxons/sevenwonders/game/boards/Board.java
@@ -125,6 +125,10 @@ public class Board {
this.copiedGuild = copiedGuild;
}
+ public Card getCopiedGuild() {
+ return copiedGuild;
+ }
+
public PlayerScore computePoints(Table table) {
PlayerScore score = new PlayerScore(player, gold);
score.put(ScoreCategory.CIVIL, computePointsForCards(table, Color.BLUE));
diff --git a/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbility.java b/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbility.java
index f5e0a0e7..02f80714 100644
--- a/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbility.java
+++ b/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbility.java
@@ -1,6 +1,8 @@
package org.luxons.sevenwonders.game.effects;
+import org.luxons.sevenwonders.game.api.Table;
import org.luxons.sevenwonders.game.boards.Board;
+import org.luxons.sevenwonders.game.cards.Card;
public enum SpecialAbility {
/**
@@ -23,9 +25,22 @@ public enum SpecialAbility {
* The player can, at the end of the game, “copy” a Guild of his or her choice (purple card), built by one of his or
* her two neighboring cities.
*/
- COPY_GUILD;
+ COPY_GUILD {
+ @Override
+ public int computePoints(Table table, int playerIndex) {
+ Card copiedGuild = table.getBoard(playerIndex).getCopiedGuild();
+ if (copiedGuild == null) {
+ throw new IllegalStateException("The copied Guild has not been chosen, cannot compute points");
+ }
+ return copiedGuild.getEffects().stream().mapToInt(e -> computePoints(table, playerIndex)).sum();
+ }
+ };
protected void apply(Board board) {
board.addSpecial(this);
}
+
+ public int computePoints(Table table, int playerIndex) {
+ return 0;
+ }
}
diff --git a/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.java b/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.java
index 18e7496f..a5953c2f 100644
--- a/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.java
+++ b/src/main/java/org/luxons/sevenwonders/game/effects/SpecialAbilityActivation.java
@@ -21,6 +21,6 @@ public class SpecialAbilityActivation implements Effect {
@Override
public int computePoints(Table table, int playerIndex) {
- return 0;
+ return specialAbility.computePoints(table, playerIndex);
}
}
bgstack15