summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2016-12-07 04:52:44 +0100
committerJoffrey BION <joffrey.bion@gmail.com>2016-12-08 02:10:10 +0100
commit3651553d82c66fabf96fd590a248089b4a51e7bd (patch)
tree1cd9415de9cb32164eea888092f25e568152f674 /src/test/java
parentFirst draft of resource production elements (diff)
downloadseven-wonders-3651553d82c66fabf96fd590a248089b4a51e7bd.tar.gz
seven-wonders-3651553d82c66fabf96fd590a248089b4a51e7bd.tar.bz2
seven-wonders-3651553d82c66fabf96fd590a248089b4a51e7bd.zip
First draft of the game engine: boards, card effects, costs
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java53
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java81
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/resources/ProductionTest.java2
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/resources/ResourcesTest.java38
4 files changed, 154 insertions, 20 deletions
diff --git a/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java b/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java
new file mode 100644
index 00000000..db11c466
--- /dev/null
+++ b/src/test/java/org/luxons/sevenwonders/game/cards/CardTest.java
@@ -0,0 +1,53 @@
+package org.luxons.sevenwonders.game.cards;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.luxons.sevenwonders.game.Settings;
+import org.luxons.sevenwonders.game.boards.Board;
+import org.luxons.sevenwonders.game.effects.ProductionIncrease;
+import org.luxons.sevenwonders.game.resources.ResourceType;
+import org.luxons.sevenwonders.game.wonders.Wonder;
+
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertEquals;
+
+public class CardTest {
+
+ private Board board;
+
+ private Board leftBoard;
+
+ private Board rightBoard;
+
+ private Card treeFarmCard;
+
+ @Before
+ public void initBoard() {
+ Settings settings = new Settings();
+ board = new Board(new Wonder(ResourceType.WOOD), settings);
+ leftBoard = new Board(new Wonder(ResourceType.STONE), settings);
+ rightBoard = new Board(new Wonder(ResourceType.PAPYRUS), settings);
+
+ Requirements treeFarmRequirements = new Requirements();
+ treeFarmRequirements.setGoldCost(1);
+
+ ProductionIncrease treeFarmEffect = new ProductionIncrease();
+ treeFarmEffect.getProduction().addChoice(ResourceType.WOOD, ResourceType.CLAY);
+
+ treeFarmCard = new Card("Tree Farm", Color.BROWN, treeFarmRequirements, treeFarmEffect);
+ }
+
+ @Test
+ public void testInitialBoard() {
+ assertEquals(3, board.getGold());
+ }
+
+ @Test
+ public void playCardCostingMoney() {
+ board.setGold(3);
+ treeFarmCard.play(board, leftBoard, rightBoard);
+ assertEquals(2, board.getGold());
+ assertTrue(board.getPlayedCards().contains(treeFarmCard));
+ }
+
+}
diff --git a/src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java b/src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java
new file mode 100644
index 00000000..51a7a192
--- /dev/null
+++ b/src/test/java/org/luxons/sevenwonders/game/effects/EffectTest.java
@@ -0,0 +1,81 @@
+package org.luxons.sevenwonders.game.effects;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.luxons.sevenwonders.game.Settings;
+import org.luxons.sevenwonders.game.boards.Board;
+import org.luxons.sevenwonders.game.resources.ResourceType;
+import org.luxons.sevenwonders.game.resources.Resources;
+import org.luxons.sevenwonders.game.wonders.Wonder;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class EffectTest {
+
+ private static final int INITIAL_GOLD = 3;
+
+ private Board board;
+
+ private Board leftBoard;
+
+ private Board rightBoard;
+
+ private Resources resources1Stone1Wood;
+
+ private Resources resources2Stones;
+
+ private Resources resources2Stones3Clay;
+
+ @Before
+ public void init() {
+ Settings settings = new Settings();
+ settings.setInitialGold(INITIAL_GOLD);
+
+ board = new Board(new Wonder(ResourceType.WOOD), settings);
+ leftBoard = new Board(new Wonder(ResourceType.STONE), settings);
+ rightBoard = new Board(new Wonder(ResourceType.PAPYRUS), settings);
+
+ resources1Stone1Wood = new Resources();
+ resources1Stone1Wood.add(ResourceType.STONE, 1);
+ resources1Stone1Wood.add(ResourceType.WOOD, 1);
+
+ resources2Stones = new Resources();
+ resources2Stones.add(ResourceType.STONE, 2);
+
+ resources2Stones3Clay = new Resources();
+ resources2Stones3Clay.add(ResourceType.STONE, 2);
+ resources2Stones3Clay.add(ResourceType.CLAY, 3);
+ }
+
+ @Test
+ public void testInitialBoard() {
+ assertEquals(3, board.getGold());
+ }
+
+ @Test
+ public void testGoldIncrease() {
+ GoldIncrease effect = new GoldIncrease();
+ effect.setAmount(6);
+ effect.apply(board, leftBoard, rightBoard);
+ assertEquals(INITIAL_GOLD + 6, board.getGold());
+ assertEquals(INITIAL_GOLD, leftBoard.getGold());
+ assertEquals(INITIAL_GOLD, rightBoard.getGold());
+ }
+
+ @Test
+ public void testProductionIncrease_standard() {
+ ProductionIncrease effect = new ProductionIncrease();
+ effect.getProduction().addAll(resources2Stones3Clay);
+ effect.apply(board, leftBoard, rightBoard);
+ assertTrue(board.getProduction().contains(resources2Stones3Clay));
+ }
+
+ @Test
+ public void testProductionIncrease_choice() {
+ ProductionIncrease effect = new ProductionIncrease();
+ effect.getProduction().addChoice(ResourceType.ORE, ResourceType.STONE);
+ effect.apply(board, leftBoard, rightBoard);
+ assertTrue(board.getProduction().contains(resources1Stone1Wood));
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/luxons/sevenwonders/game/resources/ProductionTest.java b/src/test/java/org/luxons/sevenwonders/game/resources/ProductionTest.java
index 58b82dc1..f5c7c719 100644
--- a/src/test/java/org/luxons/sevenwonders/game/resources/ProductionTest.java
+++ b/src/test/java/org/luxons/sevenwonders/game/resources/ProductionTest.java
@@ -150,7 +150,7 @@ public class ProductionTest {
@Test
public void contains_multipleChoices_moreThanEnough() throws Exception {
Production production = new Production();
- production.addChoice(ResourceType.LINEN, ResourceType.GLASS, ResourceType.PAPYRUS);
+ production.addChoice(ResourceType.LOOM, ResourceType.GLASS, ResourceType.PAPYRUS);
production.addChoice(ResourceType.STONE, ResourceType.ORE);
production.addChoice(ResourceType.STONE, ResourceType.WOOD);
assertTrue(production.contains(resources1Stone1Wood));
diff --git a/src/test/java/org/luxons/sevenwonders/game/resources/ResourcesTest.java b/src/test/java/org/luxons/sevenwonders/game/resources/ResourcesTest.java
index efcea74e..fc4bb909 100644
--- a/src/test/java/org/luxons/sevenwonders/game/resources/ResourcesTest.java
+++ b/src/test/java/org/luxons/sevenwonders/game/resources/ResourcesTest.java
@@ -61,7 +61,7 @@ public class ResourcesTest {
assertEquals(3, resources.getQuantity(ResourceType.CLAY));
assertEquals(0, resources.getQuantity(ResourceType.ORE));
assertEquals(0, resources.getQuantity(ResourceType.GLASS));
- assertEquals(0, resources.getQuantity(ResourceType.LINEN));
+ assertEquals(0, resources.getQuantity(ResourceType.LOOM));
}
@Test
@@ -79,7 +79,7 @@ public class ResourcesTest {
assertEquals(3, resources.getQuantity(ResourceType.CLAY));
assertEquals(0, resources.getQuantity(ResourceType.ORE));
assertEquals(0, resources.getQuantity(ResourceType.GLASS));
- assertEquals(0, resources.getQuantity(ResourceType.LINEN));
+ assertEquals(0, resources.getQuantity(ResourceType.LOOM));
}
@Test
@@ -97,7 +97,7 @@ public class ResourcesTest {
assertEquals(9, resources.getQuantity(ResourceType.CLAY));
assertEquals(0, resources.getQuantity(ResourceType.ORE));
assertEquals(0, resources.getQuantity(ResourceType.GLASS));
- assertEquals(0, resources.getQuantity(ResourceType.LINEN));
+ assertEquals(0, resources.getQuantity(ResourceType.LOOM));
}
@Test
@@ -115,7 +115,7 @@ public class ResourcesTest {
assertEquals(9, resources.getQuantity(ResourceType.CLAY));
assertEquals(4, resources.getQuantity(ResourceType.ORE));
assertEquals(0, resources.getQuantity(ResourceType.GLASS));
- assertEquals(0, resources.getQuantity(ResourceType.LINEN));
+ assertEquals(0, resources.getQuantity(ResourceType.LOOM));
}
@Test
@@ -218,7 +218,7 @@ public class ResourcesTest {
assertEquals(3, diff.getQuantity(ResourceType.CLAY));
assertEquals(0, diff.getQuantity(ResourceType.ORE));
assertEquals(0, diff.getQuantity(ResourceType.GLASS));
- assertEquals(0, diff.getQuantity(ResourceType.LINEN));
+ assertEquals(0, diff.getQuantity(ResourceType.LOOM));
}
@Test
@@ -232,7 +232,7 @@ public class ResourcesTest {
assertEquals(0, diff.getQuantity(ResourceType.CLAY));
assertEquals(0, diff.getQuantity(ResourceType.ORE));
assertEquals(0, diff.getQuantity(ResourceType.GLASS));
- assertEquals(0, diff.getQuantity(ResourceType.LINEN));
+ assertEquals(0, diff.getQuantity(ResourceType.LOOM));
}
@Test
@@ -250,7 +250,7 @@ public class ResourcesTest {
assertEquals(0, diff.getQuantity(ResourceType.CLAY));
assertEquals(0, diff.getQuantity(ResourceType.ORE));
assertEquals(0, diff.getQuantity(ResourceType.GLASS));
- assertEquals(0, diff.getQuantity(ResourceType.LINEN));
+ assertEquals(0, diff.getQuantity(ResourceType.LOOM));
}
@Test
@@ -268,7 +268,7 @@ public class ResourcesTest {
assertEquals(1, diff.getQuantity(ResourceType.CLAY));
assertEquals(0, diff.getQuantity(ResourceType.ORE));
assertEquals(0, diff.getQuantity(ResourceType.GLASS));
- assertEquals(0, diff.getQuantity(ResourceType.LINEN));
+ assertEquals(0, diff.getQuantity(ResourceType.LOOM));
}
@Test
@@ -285,7 +285,7 @@ public class ResourcesTest {
assertEquals(1, diff.getQuantity(ResourceType.CLAY));
assertEquals(0, diff.getQuantity(ResourceType.ORE));
assertEquals(0, diff.getQuantity(ResourceType.GLASS));
- assertEquals(0, diff.getQuantity(ResourceType.LINEN));
+ assertEquals(0, diff.getQuantity(ResourceType.LOOM));
}
@Test
@@ -302,7 +302,7 @@ public class ResourcesTest {
assertEquals(0, diff.getQuantity(ResourceType.CLAY));
assertEquals(0, diff.getQuantity(ResourceType.ORE));
assertEquals(0, diff.getQuantity(ResourceType.GLASS));
- assertEquals(0, diff.getQuantity(ResourceType.LINEN));
+ assertEquals(0, diff.getQuantity(ResourceType.LOOM));
}
@Test
@@ -322,22 +322,22 @@ public class ResourcesTest {
Resources resources = new Resources();
Resources resources2 = new Resources();
- resources2.add(ResourceType.LINEN, 5);
+ resources2.add(ResourceType.LOOM, 5);
Resources diff = resources.minus(resources2);
- assertEquals(0, diff.getQuantity(ResourceType.LINEN));
+ assertEquals(0, diff.getQuantity(ResourceType.LOOM));
}
@Test
public void minus_someOfATypeWithZero() {
Resources resources = new Resources();
- resources.add(ResourceType.LINEN, 0);
+ resources.add(ResourceType.LOOM, 0);
Resources resources2 = new Resources();
- resources2.add(ResourceType.LINEN, 5);
+ resources2.add(ResourceType.LOOM, 5);
Resources diff = resources.minus(resources2);
- assertEquals(0, diff.getQuantity(ResourceType.LINEN));
+ assertEquals(0, diff.getQuantity(ResourceType.LOOM));
}
@Test
@@ -349,7 +349,7 @@ public class ResourcesTest {
@Test
public void isEmpty_singleZeroElement() {
Resources resources = new Resources();
- resources.add(ResourceType.LINEN, 0);
+ resources.add(ResourceType.LOOM, 0);
assertTrue(resources.isEmpty());
}
@@ -358,14 +358,14 @@ public class ResourcesTest {
Resources resources = new Resources();
resources.add(ResourceType.WOOD, 0);
resources.add(ResourceType.ORE, 0);
- resources.add(ResourceType.LINEN, 0);
+ resources.add(ResourceType.LOOM, 0);
assertTrue(resources.isEmpty());
}
@Test
public void isEmpty_singleElementMoreThanZero() {
Resources resources = new Resources();
- resources.add(ResourceType.LINEN, 3);
+ resources.add(ResourceType.LOOM, 3);
assertFalse(resources.isEmpty());
}
@@ -373,7 +373,7 @@ public class ResourcesTest {
public void isEmpty_mixedZeroAndNonZeroElements() {
Resources resources = new Resources();
resources.add(ResourceType.WOOD, 0);
- resources.add(ResourceType.LINEN, 3);
+ resources.add(ResourceType.LOOM, 3);
assertFalse(resources.isEmpty());
}
bgstack15