summaryrefslogtreecommitdiff
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-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
6 files changed, 16 insertions, 42 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;
-}
bgstack15