diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2018-04-25 23:32:54 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2018-04-25 23:32:54 +0200 |
commit | ed3daff06c74243aacf5754a7f6ffec3d0018425 (patch) | |
tree | c7d0222a8ef97e2fe13bc36f9459691434730c66 /game-engine/src/test | |
parent | Make wonder activation pay for requirements (diff) | |
download | seven-wonders-ed3daff06c74243aacf5754a7f6ffec3d0018425.tar.gz seven-wonders-ed3daff06c74243aacf5754a7f6ffec3d0018425.tar.bz2 seven-wonders-ed3daff06c74243aacf5754a7f6ffec3d0018425.zip |
Extract move creation in GameTest
Diffstat (limited to 'game-engine/src/test')
-rw-r--r-- | game-engine/src/test/java/org/luxons/sevenwonders/game/GameTest.java | 17 | ||||
-rw-r--r-- | game-engine/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java | 6 |
2 files changed, 7 insertions, 16 deletions
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 e504126d..b9b399bb 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 @@ -91,26 +91,17 @@ public class GameTest { private static PlayerMove createPlayCardMove(PlayerTurnInfo turnInfo) { for (HandCard handCard : turnInfo.getHand()) { if (handCard.isFree()) { - return createMove(handCard, MoveType.PLAY); + return TestUtils.createPlayerMove(handCard.getCard().getName(), MoveType.PLAY); } } - return createMove(turnInfo.getHand().get(0), MoveType.DISCARD); + HandCard firstCardInHand = turnInfo.getHand().get(0); + return TestUtils.createPlayerMove(firstCardInHand.getCard().getName(), MoveType.DISCARD); } private static PlayerMove createPickGuildMove(PlayerTurnInfo turnInfo) { List<Card> neighbourGuilds = turnInfo.getNeighbourGuildCards(); assertNotNull(neighbourGuilds); String cardName = neighbourGuilds.isEmpty() ? null : neighbourGuilds.get(0).getName(); - PlayerMove move = new PlayerMove(); - move.setCardName(cardName); - move.setType(MoveType.COPY_GUILD); - return move; - } - - private static PlayerMove createMove(HandCard handCard, MoveType type) { - PlayerMove move = new PlayerMove(); - move.setCardName(handCard.getCard().getName()); - move.setType(type); - return move; + return TestUtils.createPlayerMove(cardName, MoveType.COPY_GUILD); } } diff --git a/game-engine/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java b/game-engine/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java index 137dd3d7..34b2e74f 100644 --- a/game-engine/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java +++ b/game-engine/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java @@ -220,13 +220,13 @@ public class TestUtils { } public static Move createMove(int playerIndex, Card card, MoveType type, BoughtResources... boughtResources) { - PlayerMove playerMove = createPlayerMove(card, type, boughtResources); + PlayerMove playerMove = createPlayerMove(card.getName(), type, boughtResources); return type.resolve(playerIndex, card, playerMove); } - private static PlayerMove createPlayerMove(Card card, MoveType type, BoughtResources... boughtResources) { + public static PlayerMove createPlayerMove(String cardName, MoveType type, BoughtResources... boughtResources) { PlayerMove playerMove = new PlayerMove(); - playerMove.setCardName(card.getName()); + playerMove.setCardName(cardName); playerMove.setType(type); playerMove.setBoughtResources(Arrays.asList(boughtResources)); return playerMove; |