diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2017-05-10 06:37:01 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2017-05-10 06:37:01 +0200 |
commit | 31221a3df74ff0b1a60f964d5ecbcd136f876151 (patch) | |
tree | c7f8050cb32afcba618d6138ed26985f0b039fc2 /backend/src/test/java | |
parent | Add proper algorithm to check if a card is playable (diff) | |
download | seven-wonders-31221a3df74ff0b1a60f964d5ecbcd136f876151.tar.gz seven-wonders-31221a3df74ff0b1a60f964d5ecbcd136f876151.tar.bz2 seven-wonders-31221a3df74ff0b1a60f964d5ecbcd136f876151.zip |
Add more complicated test for playability
Diffstat (limited to 'backend/src/test/java')
-rw-r--r-- | backend/src/test/java/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.java | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/backend/src/test/java/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.java b/backend/src/test/java/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.java index bad611af..ad1641c5 100644 --- a/backend/src/test/java/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.java +++ b/backend/src/test/java/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.java @@ -34,31 +34,35 @@ public class BestPriceCalculatorTest { @Test public void bestPrice_fixedResources_overridenCost() { - Board left = TestUtils.createBoard(ResourceType.WOOD); Board main = TestUtils.createBoard(ResourceType.STONE); + main.getTradingRules().setCost(ResourceType.WOOD, Provider.RIGHT_PLAYER, 1); + + Board left = TestUtils.createBoard(ResourceType.WOOD); Board right = TestUtils.createBoard(ResourceType.WOOD); Board opposite = TestUtils.createBoard(ResourceType.GLASS); - Table table = new Table(Arrays.asList(main, right, left, opposite)); + Table table = new Table(Arrays.asList(main, right, opposite, left)); - main.getTradingRules().setCost(ResourceType.WOOD, Provider.RIGHT_PLAYER, 1); Resources resources = new Resources(); resources.add(ResourceType.WOOD, 1); assertEquals(1, BestPriceCalculator.bestPrice(resources, table, 0)); assertEquals(0, BestPriceCalculator.bestPrice(resources, table, 1)); - assertEquals(0, BestPriceCalculator.bestPrice(resources, table, 2)); - assertEquals(2, BestPriceCalculator.bestPrice(resources, table, 3)); + assertEquals(2, BestPriceCalculator.bestPrice(resources, table, 2)); + assertEquals(0, BestPriceCalculator.bestPrice(resources, table, 3)); } @Test public void bestPrice_mixedResources_overridenCost() { Board left = TestUtils.createBoard(ResourceType.WOOD); + Board main = TestUtils.createBoard(ResourceType.STONE); + main.getTradingRules().setCost(ResourceType.WOOD, Provider.RIGHT_PLAYER, 1); + Board right = TestUtils.createBoard(ResourceType.ORE); right.getProduction().addChoice(ResourceType.WOOD, ResourceType.CLAY); + Table table = new Table(Arrays.asList(main, right, left)); - main.getTradingRules().setCost(ResourceType.WOOD, Provider.RIGHT_PLAYER, 1); Resources resources = new Resources(); resources.add(ResourceType.WOOD, 1); @@ -66,4 +70,27 @@ public class BestPriceCalculatorTest { assertEquals(0, BestPriceCalculator.bestPrice(resources, table, 1)); assertEquals(0, BestPriceCalculator.bestPrice(resources, table, 2)); } + + @Test + public void bestPrice_chooseCheapest() { + Board left = TestUtils.createBoard(ResourceType.WOOD); + + Board main = TestUtils.createBoard(ResourceType.WOOD); + main.getProduction().addChoice(ResourceType.ORE, ResourceType.CLAY); + main.getTradingRules().setCost(ResourceType.CLAY, Provider.RIGHT_PLAYER, 1); + + Board right = TestUtils.createBoard(ResourceType.WOOD); + right.getProduction().addFixedResource(ResourceType.ORE, 1); + right.getProduction().addFixedResource(ResourceType.CLAY, 1); + + Table table = new Table(Arrays.asList(main, right, left)); + + + Resources resources = new Resources(); + resources.add(ResourceType.ORE, 1); + resources.add(ResourceType.CLAY, 1); + assertEquals(1, BestPriceCalculator.bestPrice(resources, table, 0)); + assertEquals(0, BestPriceCalculator.bestPrice(resources, table, 1)); + assertEquals(4, BestPriceCalculator.bestPrice(resources, table, 2)); + } } |