diff options
Diffstat (limited to 'game-engine/src/test/java')
-rw-r--r-- | game-engine/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java | 45 |
1 files changed, 30 insertions, 15 deletions
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 10f5def0..0dff9dbe 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 @@ -7,6 +7,7 @@ import java.util.List; import org.luxons.sevenwonders.game.Settings; import org.luxons.sevenwonders.game.api.CustomizableSettings; +import org.luxons.sevenwonders.game.api.PlayerMove; import org.luxons.sevenwonders.game.api.Table; import org.luxons.sevenwonders.game.boards.Board; import org.luxons.sevenwonders.game.boards.Science; @@ -17,6 +18,8 @@ import org.luxons.sevenwonders.game.cards.Color; import org.luxons.sevenwonders.game.cards.Requirements; import org.luxons.sevenwonders.game.effects.Effect; import org.luxons.sevenwonders.game.effects.ScienceProgress; +import org.luxons.sevenwonders.game.moves.Move; +import org.luxons.sevenwonders.game.moves.MoveType; import org.luxons.sevenwonders.game.resources.BoughtResources; import org.luxons.sevenwonders.game.resources.Production; import org.luxons.sevenwonders.game.resources.Provider; @@ -81,15 +84,16 @@ public class TestUtils { } public static Wonder createWonder(ResourceType initialResource) { - WonderStage stage1 = new WonderStage(); - stage1.setRequirements(new Requirements()); - WonderStage stage2 = new WonderStage(); - stage1.setRequirements(new Requirements()); - WonderStage stage3 = new WonderStage(); - stage1.setRequirements(new Requirements()); + WonderStage stage1 = createWonderStage(); + WonderStage stage2 = createWonderStage(); + WonderStage stage3 = createWonderStage(); return new Wonder("Test Wonder " + initialResource.getSymbol(), initialResource, stage1, stage2, stage3); } + private static WonderStage createWonderStage(Effect... effects) { + return new WonderStage(new Requirements(), Arrays.asList(effects)); + } + public static Production createFixedProduction(ResourceType... producedTypes) { Production production = new Production(); Resources fixedProducedResources = production.getFixedResources(); @@ -128,29 +132,27 @@ public class TestUtils { } public static Card createCard(String name) { - return createCard(name, Color.BLUE, null); + return createCard(name, Color.BLUE); } public static Card createCard(Color color) { - return createCard("Test Card", color, null); + return createCard("Test Card", color); } public static Card createCard(Color color, Effect effect) { - List<Effect> effects = Collections.singletonList(effect); - return createCard("Test Card", color, effects); + return createCard("Test Card", color, effect); } private static Card createCard(int num, Color color) { - return createCard("Test Card " + num, color, null); + return createCard("Test Card " + num, color); } public static Card createGuildCard(int num, Effect effect) { - List<Effect> effects = Collections.singletonList(effect); - return createCard("Test Guild " + num, Color.PURPLE, effects); + return createCard("Test Guild " + num, Color.PURPLE, effect); } - private static Card createCard(String name, Color color, List<Effect> effects) { - Card card = new Card(name, color, new Requirements(), effects, null, null, "path/to/card/image"); + private static Card createCard(String name, Color color, Effect... effects) { + Card card = new Card(name, color, new Requirements(), Arrays.asList(effects), null, null, "path/to/card/image"); card.setBack(createCardBack()); return card; } @@ -210,4 +212,17 @@ public class TestUtils { board.addCard(card); card.applyTo(table, playerIndex, Collections.emptyList()); } + + public static Move createMove(int playerIndex, Card card, MoveType type, BoughtResources... boughtResources) { + PlayerMove playerMove = createPlayerMove(card, type, boughtResources); + return type.resolve(playerIndex, card, playerMove); + } + + private static PlayerMove createPlayerMove(Card card, MoveType type, BoughtResources... boughtResources) { + PlayerMove playerMove = new PlayerMove(); + playerMove.setCardName(card.getName()); + playerMove.setType(type); + playerMove.setBoughtResources(Arrays.asList(boughtResources)); + return playerMove; + } } |