diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2017-01-14 02:27:09 +0100 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2017-01-14 02:27:09 +0100 |
commit | c38e4fe4ade5796bb20d3f5b565da6533e14e4d1 (patch) | |
tree | e31ee9f96f70b3f3b6e59124d6b9318319895677 | |
parent | Add gold points to score computation (diff) | |
download | seven-wonders-c38e4fe4ade5796bb20d3f5b565da6533e14e4d1.tar.gz seven-wonders-c38e4fe4ade5796bb20d3f5b565da6533e14e4d1.tar.bz2 seven-wonders-c38e4fe4ade5796bb20d3f5b565da6533e14e4d1.zip |
Add actual points computation from copied guild
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); } } |