From c38e4fe4ade5796bb20d3f5b565da6533e14e4d1 Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Sat, 14 Jan 2017 02:27:09 +0100 Subject: Add actual points computation from copied guild --- .../java/org/luxons/sevenwonders/game/boards/Board.java | 4 ++++ .../sevenwonders/game/effects/SpecialAbility.java | 17 ++++++++++++++++- .../game/effects/SpecialAbilityActivation.java | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) (limited to 'src/main/java/org/luxons') 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); } } -- cgit