From 5615172249c3e1a95f6e03333fd7e456bd5db5ca Mon Sep 17 00:00:00 2001 From: Joffrey Bion Date: Fri, 6 Jul 2018 13:59:33 +0200 Subject: Prevent PICK_NEIGHBOUR_GUILD action if no guild to pick --- game-engine/src/main/java/org/luxons/sevenwonders/game/Game.java | 3 ++- .../src/main/java/org/luxons/sevenwonders/game/boards/Board.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'game-engine/src/main') diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/Game.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/Game.java index ed11913b..853d7490 100644 --- a/game-engine/src/main/java/org/luxons/sevenwonders/game/Game.java +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/Game.java @@ -95,7 +95,8 @@ public class Game { private Action determineAction(List hand, Board board) { if (endOfGameReached() && board.hasSpecial(SpecialAbility.COPY_GUILD)) { - return Action.PICK_NEIGHBOR_GUILD; + List neighbourGuildCards = table.getNeighbourGuildCards(board.getPlayerIndex()); + return neighbourGuildCards.isEmpty() ? Action.WAIT : Action.PICK_NEIGHBOR_GUILD; } else if (hand.size() == 1 && board.hasSpecial(SpecialAbility.PLAY_LAST_CARD)) { return Action.PLAY_LAST; } else if (hand.size() == 2 && board.hasSpecial(SpecialAbility.PLAY_LAST_CARD)) { diff --git a/game-engine/src/main/java/org/luxons/sevenwonders/game/boards/Board.java b/game-engine/src/main/java/org/luxons/sevenwonders/game/boards/Board.java index a59bbfae..23ce5da5 100644 --- a/game-engine/src/main/java/org/luxons/sevenwonders/game/boards/Board.java +++ b/game-engine/src/main/java/org/luxons/sevenwonders/game/boards/Board.java @@ -57,6 +57,10 @@ public class Board { this.publicProduction.addFixedResource(wonder.getInitialResource(), 1); } + public int getPlayerIndex() { + return playerIndex; + } + public Wonder getWonder() { return wonder; } -- cgit