summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/game/resources/BestPriceCalculatorTest.java39
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));
+ }
}
bgstack15