diff options
author | Joffrey Bion <joffrey.bion@amadeus.com> | 2018-07-06 13:59:33 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@amadeus.com> | 2018-07-06 14:16:57 +0200 |
commit | 5615172249c3e1a95f6e03333fd7e456bd5db5ca (patch) | |
tree | ba1c20dc199c89da4ac2791f0369bde7c07fbfc1 | |
parent | Update yarn.lock (diff) | |
download | seven-wonders-5615172249c3e1a95f6e03333fd7e456bd5db5ca.tar.gz seven-wonders-5615172249c3e1a95f6e03333fd7e456bd5db5ca.tar.bz2 seven-wonders-5615172249c3e1a95f6e03333fd7e456bd5db5ca.zip |
Prevent PICK_NEIGHBOUR_GUILD action if no guild to pick
3 files changed, 9 insertions, 2 deletions
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<HandCard> hand, Board board) { if (endOfGameReached() && board.hasSpecial(SpecialAbility.COPY_GUILD)) { - return Action.PICK_NEIGHBOR_GUILD; + List<Card> 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; } diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java index ff34dc27..02531cde 100644 --- a/game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java +++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java @@ -24,6 +24,7 @@ import org.luxons.sevenwonders.game.resources.Resources; import org.luxons.sevenwonders.game.test.TestUtils; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; @@ -119,7 +120,8 @@ public class GameTest { private static PlayerMove createPickGuildMove(PlayerTurnInfo turnInfo) { List<Card> neighbourGuilds = turnInfo.getNeighbourGuildCards(); assertNotNull(neighbourGuilds); - String cardName = neighbourGuilds.isEmpty() ? null : neighbourGuilds.get(0).getName(); + assertFalse(neighbourGuilds.isEmpty()); + String cardName = neighbourGuilds.get(0).getName(); return TestUtils.createPlayerMove(cardName, MoveType.COPY_GUILD); } } |