summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/Settings.java2
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/data/GameDefinitionLoader.java11
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/data/definitions/CardDefinition.java18
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/data/definitions/WonderDefinition.java17
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/data/definitions/WonderSide.java5
-rw-r--r--src/main/java/org/luxons/sevenwonders/game/wonders/WonderSide.java5
-rw-r--r--src/main/resources/org/luxons/sevenwonders/game/data/wonders.json870
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionLoaderTest.java16
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionTest.java26
-rw-r--r--src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java19
10 files changed, 518 insertions, 471 deletions
diff --git a/src/main/java/org/luxons/sevenwonders/game/Settings.java b/src/main/java/org/luxons/sevenwonders/game/Settings.java
index b3ee2232..ecd22d24 100644
--- a/src/main/java/org/luxons/sevenwonders/game/Settings.java
+++ b/src/main/java/org/luxons/sevenwonders/game/Settings.java
@@ -2,7 +2,7 @@ package org.luxons.sevenwonders.game;
import java.util.Random;
-import org.luxons.sevenwonders.game.wonders.WonderSide;
+import org.luxons.sevenwonders.game.data.definitions.WonderSide;
public class Settings {
diff --git a/src/main/java/org/luxons/sevenwonders/game/data/GameDefinitionLoader.java b/src/main/java/org/luxons/sevenwonders/game/data/GameDefinitionLoader.java
index 977bb100..30457d86 100644
--- a/src/main/java/org/luxons/sevenwonders/game/data/GameDefinitionLoader.java
+++ b/src/main/java/org/luxons/sevenwonders/game/data/GameDefinitionLoader.java
@@ -7,9 +7,6 @@ import java.io.Reader;
import java.lang.reflect.Type;
import java.util.List;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.reflect.TypeToken;
import org.luxons.sevenwonders.game.data.definitions.DecksDefinition;
import org.luxons.sevenwonders.game.data.definitions.WonderDefinition;
import org.luxons.sevenwonders.game.data.serializers.NumericEffectSerializer;
@@ -27,6 +24,10 @@ import org.luxons.sevenwonders.game.resources.ResourceType;
import org.luxons.sevenwonders.game.resources.Resources;
import org.springframework.stereotype.Component;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+
@Component
public class GameDefinitionLoader {
@@ -41,14 +42,14 @@ public class GameDefinitionLoader {
private final GameDefinition gameDefinition;
public GameDefinitionLoader() {
- gameDefinition = new GameDefinition(loadWonders(), loadDecks());
+ gameDefinition = load();
}
public GameDefinition getGameDefinition() {
return gameDefinition;
}
- public static GameDefinition load() {
+ private static GameDefinition load() {
return new GameDefinition(loadWonders(), loadDecks());
}
diff --git a/src/main/java/org/luxons/sevenwonders/game/data/definitions/CardDefinition.java b/src/main/java/org/luxons/sevenwonders/game/data/definitions/CardDefinition.java
index 48853899..f469ca4f 100644
--- a/src/main/java/org/luxons/sevenwonders/game/data/definitions/CardDefinition.java
+++ b/src/main/java/org/luxons/sevenwonders/game/data/definitions/CardDefinition.java
@@ -31,23 +31,7 @@ public class CardDefinition implements Definition<Card> {
return new Card(name, color, requirements, effect.create(settings), chainParent, chainChildren, image);
}
- public String getName() {
- return name;
- }
-
- public Color getColor() {
- return color;
- }
-
- public Map<Integer, Integer> getCountPerNbPlayer() {
+ Map<Integer, Integer> getCountPerNbPlayer() {
return countPerNbPlayer;
}
-
- public String getImage() {
- return image;
- }
-
- public void setImage(String image) {
- this.image = image;
- }
}
diff --git a/src/main/java/org/luxons/sevenwonders/game/data/definitions/WonderDefinition.java b/src/main/java/org/luxons/sevenwonders/game/data/definitions/WonderDefinition.java
index 4d0f411d..2dfe7bb7 100644
--- a/src/main/java/org/luxons/sevenwonders/game/data/definitions/WonderDefinition.java
+++ b/src/main/java/org/luxons/sevenwonders/game/data/definitions/WonderDefinition.java
@@ -1,6 +1,7 @@
package org.luxons.sevenwonders.game.data.definitions;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
import org.luxons.sevenwonders.game.Settings;
@@ -12,32 +13,20 @@ public class WonderDefinition implements Definition<Wonder> {
private String name;
- private WonderSideDefinition a;
-
- private WonderSideDefinition b;
+ private Map<WonderSide, WonderSideDefinition> sides;
@Override
public Wonder create(Settings settings) {
Wonder wonder = new Wonder();
wonder.setName(name);
- WonderSideDefinition wonderSideDef = pickSide(settings);
+ WonderSideDefinition wonderSideDef = sides.get(settings.getWonderSide());
wonder.setInitialResource(wonderSideDef.getInitialResource());
wonder.setStages(wonderSideDef.createStages(settings));
wonder.setImage(wonderSideDef.getImage());
return wonder;
}
- private WonderSideDefinition pickSide(Settings settings) {
- switch (settings.getWonderSide()){
- case A:
- return a;
- case B:
- return b;
- }
- throw new IllegalArgumentException("Unsupported wonder side " + settings.getWonderSide());
- }
-
public static class WonderSideDefinition {
private ResourceType initialResource;
diff --git a/src/main/java/org/luxons/sevenwonders/game/data/definitions/WonderSide.java b/src/main/java/org/luxons/sevenwonders/game/data/definitions/WonderSide.java
new file mode 100644
index 00000000..9cfeb767
--- /dev/null
+++ b/src/main/java/org/luxons/sevenwonders/game/data/definitions/WonderSide.java
@@ -0,0 +1,5 @@
+package org.luxons.sevenwonders.game.data.definitions;
+
+public enum WonderSide {
+ A, B;
+}
diff --git a/src/main/java/org/luxons/sevenwonders/game/wonders/WonderSide.java b/src/main/java/org/luxons/sevenwonders/game/wonders/WonderSide.java
deleted file mode 100644
index 4a59e648..00000000
--- a/src/main/java/org/luxons/sevenwonders/game/wonders/WonderSide.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package org.luxons.sevenwonders.game.wonders;
-
-public enum WonderSide {
- A, B;
-}
diff --git a/src/main/resources/org/luxons/sevenwonders/game/data/wonders.json b/src/main/resources/org/luxons/sevenwonders/game/data/wonders.json
index eb04b90e..9b4d0587 100644
--- a/src/main/resources/org/luxons/sevenwonders/game/data/wonders.json
+++ b/src/main/resources/org/luxons/sevenwonders/game/data/wonders.json
@@ -1,501 +1,515 @@
[
{
"name": "alexandria",
- "a": {
- "initialResource": "G",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "SS"
- },
- "effects": {
- "points": 3
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "OO"
- },
- "effects": {
- "production": "W/S/O/C"
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "GG"
+ "sides": {
+ "A": {
+ "initialResource": "G",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "SS"
+ },
+ "effects": {
+ "points": 3
+ }
},
- "effects": {
- "points": 7
- }
- }
- ],
- "image": "alexandriaA.png"
- },
- "b": {
- "initialResource": "G",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "CC"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "OO"
+ },
+ "effects": {
+ "production": "W/S/O/C"
+ }
},
- "effects": {
- "production": "W/S/O/C"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "GG"
+ },
+ "effects": {
+ "points": 7
+ }
}
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "WW"
+ ],
+ "image": "alexandriaA.png"
+ },
+ "B": {
+ "initialResource": "G",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "CC"
+ },
+ "effects": {
+ "production": "W/S/O/C"
+ }
},
- "effects": {
- "production": "G/P/L"
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "SSS"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "WW"
+ },
+ "effects": {
+ "production": "G/P/L"
+ }
},
- "effects": {
- "points": 7
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "SSS"
+ },
+ "effects": {
+ "points": 7
+ }
}
- }
- ],
- "image": "alexandriaB.png"
+ ],
+ "image": "alexandriaB.png"
+ }
}
},
{
"name": "babylon",
- "a": {
- "initialResource": "C",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "CC"
- },
- "effects": {
- "points": 3
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "WWW"
- },
- "effects": {
- "science": "any"
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "CCCC"
+ "sides": {
+ "A": {
+ "initialResource": "C",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "CC"
+ },
+ "effects": {
+ "points": 3
+ }
},
- "effects": {
- "points": 7
- }
- }
- ],
- "image": "babylonA.png"
- },
- "b": {
- "initialResource": "C",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "CL"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "WWW"
+ },
+ "effects": {
+ "science": "any"
+ }
},
- "effects": {
- "points": 3
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "CCCC"
+ },
+ "effects": {
+ "points": 7
+ }
}
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "WWG"
+ ],
+ "image": "babylonA.png"
+ },
+ "B": {
+ "initialResource": "C",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "CL"
+ },
+ "effects": {
+ "points": 3
+ }
},
- "effects": {
- "action": "PLAY_LAST_CARD"
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "CCCP"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "WWG"
+ },
+ "effects": {
+ "action": "PLAY_LAST_CARD"
+ }
},
- "effects": {
- "science": "any"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "CCCP"
+ },
+ "effects": {
+ "science": "any"
+ }
}
- }
- ],
- "image": "babylonB.png"
+ ],
+ "image": "babylonB.png"
+ }
}
},
{
"name": "ephesos",
- "a": {
- "initialResource": "P",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "SS"
- },
- "effects": {
- "points": 3
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "WW"
- },
- "effects": {
- "gold": 9
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "PP"
+ "sides": {
+ "A": {
+ "initialResource": "P",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "SS"
+ },
+ "effects": {
+ "points": 3
+ }
},
- "effects": {
- "points": 7
- }
- }
- ],
- "image": "ephesosA.png"
- },
- "b": {
- "initialResource": "P",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "SS"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "WW"
+ },
+ "effects": {
+ "gold": 9
+ }
},
- "effects": {
- "gold": 4,
- "points": 2
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "PP"
+ },
+ "effects": {
+ "points": 7
+ }
}
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "WW"
+ ],
+ "image": "ephesosA.png"
+ },
+ "B": {
+ "initialResource": "P",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "SS"
+ },
+ "effects": {
+ "gold": 4,
+ "points": 2
+ }
},
- "effects": {
- "gold": 4,
- "points": 3
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "GPL"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "WW"
+ },
+ "effects": {
+ "gold": 4,
+ "points": 3
+ }
},
- "effects": {
- "gold": 4,
- "points": 5
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "GPL"
+ },
+ "effects": {
+ "gold": 4,
+ "points": 5
+ }
}
- }
- ],
- "image": "ephesosB.png"
+ ],
+ "image": "ephesosB.png"
+ }
}
},
{
"name": "gizah",
- "a": {
- "initialResource": "S",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "SS"
- },
- "effects": {
- "points": 3
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "WWW"
- },
- "effects": {
- "points": 5
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "SSSS"
+ "sides": {
+ "A": {
+ "initialResource": "S",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "SS"
+ },
+ "effects": {
+ "points": 3
+ }
},
- "effects": {
- "points": 7
- }
- }
- ],
- "image": "gizahA.png"
- },
- "b": {
- "initialResource": "S",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "WW"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "WWW"
+ },
+ "effects": {
+ "points": 5
+ }
},
- "effects": {
- "points": 3
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "SSSS"
+ },
+ "effects": {
+ "points": 7
+ }
}
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "SSS"
+ ],
+ "image": "gizahA.png"
+ },
+ "B": {
+ "initialResource": "S",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "WW"
+ },
+ "effects": {
+ "points": 3
+ }
},
- "effects": {
- "points": 5
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "CCC"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "SSS"
+ },
+ "effects": {
+ "points": 5
+ }
},
- "effects": {
- "points": 5
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "SSSSP"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "CCC"
+ },
+ "effects": {
+ "points": 5
+ }
},
- "effects": {
- "points": 7
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "SSSSP"
+ },
+ "effects": {
+ "points": 7
+ }
}
- }
- ],
- "image": "gizahB.png"
+ ],
+ "image": "gizahB.png"
+ }
}
},
{
"name": "halikarnassus",
- "a": {
- "initialResource": "L",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "CC"
- },
- "effects": {
- "points": 3
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "OOO"
- },
- "effects": {
- "action": "PLAY_DISCARDED"
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "LL"
+ "sides": {
+ "A": {
+ "initialResource": "L",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "CC"
+ },
+ "effects": {
+ "points": 3
+ }
},
- "effects": {
- "points": 7
- }
- }
- ],
- "image": "halikarnassusA.png"
- },
- "b": {
- "initialResource": "L",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "OO"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "OOO"
+ },
+ "effects": {
+ "action": "PLAY_DISCARDED"
+ }
},
- "effects": {
- "points": 2,
- "action": "PLAY_DISCARDED"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "LL"
+ },
+ "effects": {
+ "points": 7
+ }
}
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "CCC"
+ ],
+ "image": "halikarnassusA.png"
+ },
+ "B": {
+ "initialResource": "L",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "OO"
+ },
+ "effects": {
+ "points": 2,
+ "action": "PLAY_DISCARDED"
+ }
},
- "effects": {
- "points": 1,
- "action": "PLAY_DISCARDED"
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "GPL"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "CCC"
+ },
+ "effects": {
+ "points": 1,
+ "action": "PLAY_DISCARDED"
+ }
},
- "effects": {
- "action": "PLAY_DISCARDED"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "GPL"
+ },
+ "effects": {
+ "action": "PLAY_DISCARDED"
+ }
}
- }
- ],
- "image": "halikarnassusB.png"
+ ],
+ "image": "halikarnassusB.png"
+ }
}
},
{
"name": "olympia",
- "a": {
- "initialResource": "W",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "WW"
- },
- "effects": {
- "points": 3
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "SS"
- },
- "effects": {
- "action": "ONE_FREE"
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "OO"
+ "sides": {
+ "A": {
+ "initialResource": "W",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "WW"
+ },
+ "effects": {
+ "points": 3
+ }
},
- "effects": {
- "points": 7
- }
- }
- ],
- "image": "olympiaA.png"
- },
- "b": {
- "initialResource": "W",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "WW"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "SS"
+ },
+ "effects": {
+ "action": "ONE_FREE"
+ }
},
- "effects": {
- "discount": {
- "resourceTypes": "WSOC",
- "providers": [
- "LEFT_PLAYER",
- "RIGHT_PLAYER"
- ],
- "discountedPrice": 1
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "OO"
+ },
+ "effects": {
+ "points": 7
}
}
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "SS"
+ ],
+ "image": "olympiaA.png"
+ },
+ "B": {
+ "initialResource": "W",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "WW"
+ },
+ "effects": {
+ "discount": {
+ "resourceTypes": "WSOC",
+ "providers": [
+ "LEFT_PLAYER",
+ "RIGHT_PLAYER"
+ ],
+ "discountedPrice": 1
+ }
+ }
},
- "effects": {
- "points": 5
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "OOL"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "SS"
+ },
+ "effects": {
+ "points": 5
+ }
},
- "effects": {
- "action": "COPY_GUILD"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "OOL"
+ },
+ "effects": {
+ "action": "COPY_GUILD"
+ }
}
- }
- ],
- "image": "olympiaB.png"
+ ],
+ "image": "olympiaB.png"
+ }
}
},
{
"name": "rhodos",
- "a": {
- "initialResource": "O",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "WW"
- },
- "effects": {
- "points": 3
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "CCC"
- },
- "effects": {
- "military": 2
- }
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "OOOO"
+ "sides": {
+ "A": {
+ "initialResource": "O",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "WW"
+ },
+ "effects": {
+ "points": 3
+ }
},
- "effects": {
- "points": 7
- }
- }
- ],
- "image": "rhodosA.png"
- },
- "b": {
- "initialResource": "O",
- "stages": [
- {
- "requirements": {
- "gold": 0,
- "resources": "SSS"
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "CCC"
+ },
+ "effects": {
+ "military": 2
+ }
},
- "effects": {
- "gold": 3,
- "military": 1,
- "points": 3
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "OOOO"
+ },
+ "effects": {
+ "points": 7
+ }
}
- },
- {
- "requirements": {
- "gold": 0,
- "resources": "OOOO"
+ ],
+ "image": "rhodosA.png"
+ },
+ "B": {
+ "initialResource": "O",
+ "stages": [
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "SSS"
+ },
+ "effects": {
+ "gold": 3,
+ "military": 1,
+ "points": 3
+ }
},
- "effects": {
- "gold": 4,
- "military": 1,
- "points": 4
+ {
+ "requirements": {
+ "gold": 0,
+ "resources": "OOOO"
+ },
+ "effects": {
+ "gold": 4,
+ "military": 1,
+ "points": 4
+ }
}
- }
- ],
- "image": "rhodosB.png"
+ ],
+ "image": "rhodosB.png"
+ }
}
}
] \ No newline at end of file
diff --git a/src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionLoaderTest.java b/src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionLoaderTest.java
new file mode 100644
index 00000000..b38afd49
--- /dev/null
+++ b/src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionLoaderTest.java
@@ -0,0 +1,16 @@
+package org.luxons.sevenwonders.game.data;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class GameDefinitionLoaderTest {
+
+ @Test
+ public void successfulLoad() throws Exception {
+ GameDefinitionLoader loader = new GameDefinitionLoader();
+ GameDefinition gameDefinition = loader.getGameDefinition();
+ assertNotNull(gameDefinition);
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionTest.java b/src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionTest.java
new file mode 100644
index 00000000..d610d793
--- /dev/null
+++ b/src/test/java/org/luxons/sevenwonders/game/data/GameDefinitionTest.java
@@ -0,0 +1,26 @@
+package org.luxons.sevenwonders.game.data;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.luxons.sevenwonders.game.Game;
+import org.luxons.sevenwonders.game.Player;
+import org.luxons.sevenwonders.game.Settings;
+import org.luxons.sevenwonders.game.test.TestUtils;
+
+import static org.junit.Assert.*;
+
+public class GameDefinitionTest {
+
+ @Test
+ public void successfulGameInit() throws Exception {
+ GameDefinition gameDefinition = new GameDefinitionLoader().getGameDefinition();
+ assertNotNull(gameDefinition);
+
+ Settings settings = new Settings();
+ settings.setNbPlayers(7);
+ List<Player> players = TestUtils.createPlayers(7);
+ Game game = gameDefinition.initGame(0, settings, players);
+ assertNotNull(game);
+ }
+} \ No newline at end of file
diff --git a/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java b/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java
index 66a8e7c6..3717d3ad 100644
--- a/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java
+++ b/src/test/java/org/luxons/sevenwonders/game/test/TestUtils.java
@@ -3,6 +3,7 @@ package org.luxons.sevenwonders.game.test;
import java.util.ArrayList;
import java.util.List;
+import org.luxons.sevenwonders.game.Player;
import org.luxons.sevenwonders.game.Settings;
import org.luxons.sevenwonders.game.api.Table;
import org.luxons.sevenwonders.game.boards.Board;
@@ -30,10 +31,26 @@ public class TestUtils {
return boards;
}
+ public static List<Player> createPlayers(int count) {
+ List<Player> players = new ArrayList<>(count);
+ for (int i = 0; i < count; i++) {
+ String userName = "testUser" + i;
+ String displayName = "Test User " + i;
+ Player player = new Player(displayName, userName);
+ players.add(player);
+ }
+ return players;
+ }
+
public static Board createBoard(ResourceType initialResource) {
Settings settings = new Settings();
Wonder wonder = new Wonder("Test Wonder " + initialResource.getSymbol(), initialResource);
- return new Board(wonder, null, settings);
+
+ String userName = "testUser" + initialResource.getSymbol();
+ String displayName = "Test User " + initialResource.getSymbol();
+ Player player = new Player(displayName, userName);
+
+ return new Board(wonder, player, settings);
}
public static Board createBoard(ResourceType initialResource, ResourceType... production) {
bgstack15