diff --git a/.idea/misc.xml b/.idea/misc.xml
index 57cdb8e..25d34a4 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,5 +1,5 @@
-
+
\ No newline at end of file
diff --git a/android/android.iml b/android/android.iml
index 98e3fa5..217c060 100644
--- a/android/android.iml
+++ b/android/android.iml
@@ -4,7 +4,7 @@
-
+
@@ -17,8 +17,6 @@
generateDebugSources
-
-
diff --git a/core/build.gradle b/core/build.gradle
index d9b0752..c5099a0 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -6,6 +6,7 @@ sourceCompatibility = 1.8
sourceSets {
main {
java.srcDirs = [ "src/" ]
+ resources.srcDirs= ["resources/"]
}
test {
java.srcDirs = ["test/"]
@@ -13,9 +14,12 @@ sourceSets {
}
dependencies {
+ api "com.badlogicgames.gdx:gdx:$gdxVersion"
+
+ implementation 'se.koc:zutil:1.0.236'
+
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.5.2"
testImplementation "org.junit.platform:junit-platform-runner:1.5.2"
- api "com.badlogicgames.gdx:gdx:$gdxVersion"
}
test {
diff --git a/core/resources/data/ground_types.json b/core/resources/data/ground_types.json
new file mode 100644
index 0000000..25ec708
--- /dev/null
+++ b/core/resources/data/ground_types.json
@@ -0,0 +1,5 @@
+{
+ "1": {
+ "name": "Grass"
+ }
+}
\ No newline at end of file
diff --git a/core/src/se/cookery/world/Block.java b/core/src/se/cookery/world/Block.java
index 2ff0032..8911b28 100644
--- a/core/src/se/cookery/world/Block.java
+++ b/core/src/se/cookery/world/Block.java
@@ -6,11 +6,15 @@ package se.cookery.world;
* The class contains items, land type and world height information
*/
public class Block {
+ // Constants
+
/**
* The size of a block in units of squares. The block is a square with size BLOCK_SIZE x BLOCK_SIZE.
**/
public static final int BLOCK_SIZE = 20;
+ // Variables
+
private long offset_x = 0;
private long offset_y = 0;
private byte[][] height = new byte[BLOCK_SIZE][BLOCK_SIZE];
diff --git a/core/src/se/cookery/world/Ground.java b/core/src/se/cookery/world/Ground.java
deleted file mode 100644
index f251c76..0000000
--- a/core/src/se/cookery/world/Ground.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package se.cookery.world;
-
-/**
- * Class representing a ground material type.
- */
-public class Ground {
- private int id;
-}
diff --git a/core/src/se/cookery/world/GroundFactory.java b/core/src/se/cookery/world/GroundFactory.java
deleted file mode 100644
index 4a75e2f..0000000
--- a/core/src/se/cookery/world/GroundFactory.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package se.cookery.world;
-
-import java.security.InvalidParameterException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class GroundFactory {
- public static Map groundTypes = new HashMap<>();
-
-
- public static Ground get(int id) {
- if (0 > id || id > groundTypes.size())
- throw new InvalidParameterException("Provided id " + id + " is not associated dwith a ground type.");
- return groundTypes.get(id);
- }
-}
diff --git a/core/src/se/cookery/world/GroundType.java b/core/src/se/cookery/world/GroundType.java
new file mode 100644
index 0000000..32069eb
--- /dev/null
+++ b/core/src/se/cookery/world/GroundType.java
@@ -0,0 +1,18 @@
+package se.cookery.world;
+
+/**
+ * Class representing a ground material type.
+ */
+public class GroundType {
+ // Variables
+
+ private int id;
+ private String name;
+
+
+ protected GroundType() {}
+
+ public String getName() {
+ return null;
+ }
+}
diff --git a/core/src/se/cookery/world/GroundTypeFactory.java b/core/src/se/cookery/world/GroundTypeFactory.java
new file mode 100644
index 0000000..e88bcd6
--- /dev/null
+++ b/core/src/se/cookery/world/GroundTypeFactory.java
@@ -0,0 +1,28 @@
+package se.cookery.world;
+
+import com.badlogic.gdx.utils.JsonReader;
+
+import java.security.InvalidParameterException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class GroundTypeFactory {
+ // Constants
+
+ public static final String RESOURCE_GROUND_TYPE = "data/ground_types.json";
+
+ // Variables
+
+ public static Map groundTypes = new HashMap<>();
+
+
+ public static void initialize() {
+
+ }
+
+ public static GroundType get(int id) {
+ if (0 > id || id > groundTypes.size())
+ throw new InvalidParameterException("Provided id " + id + " is not associated with a ground type.");
+ return groundTypes.get(id);
+ }
+}
diff --git a/core/src/se/cookery/world/World.java b/core/src/se/cookery/world/World.java
index dd6ec03..0143ac7 100644
--- a/core/src/se/cookery/world/World.java
+++ b/core/src/se/cookery/world/World.java
@@ -6,6 +6,8 @@ import java.util.Map;
import java.util.TreeMap;
public class World {
+ // Variables
+
private Map> worldBlocks = new TreeMap<>();
private WorldGenerator generator;
diff --git a/core/test/se/cookery/world/GroundFactoryTest.java b/core/test/se/cookery/world/GroundTypeFactoryTest.java
similarity index 50%
rename from core/test/se/cookery/world/GroundFactoryTest.java
rename to core/test/se/cookery/world/GroundTypeFactoryTest.java
index d32b2ad..57358a6 100644
--- a/core/test/se/cookery/world/GroundFactoryTest.java
+++ b/core/test/se/cookery/world/GroundTypeFactoryTest.java
@@ -6,16 +6,24 @@ import java.security.InvalidParameterException;
import static org.junit.jupiter.api.Assertions.*;
-class GroundFactoryTest {
+class GroundTypeFactoryTest {
+
+ @Test
+ void invalidIDTest() {
+ assertThrows(InvalidParameterException.class, () -> {
+ GroundTypeFactory.get(-1);
+ });
+
+ assertThrows(InvalidParameterException.class, () -> {
+ GroundTypeFactory.get(500);
+ });
+ }
@Test
void get() {
- assertThrows(InvalidParameterException.class, () -> {
- GroundFactory.get(-1);
- });
-
- assertThrows(InvalidParameterException.class, () -> {
- GroundFactory.get(500);
- });
+ GroundType ground = GroundTypeFactory.get(0);
+ assertNotNull(ground);
+ assertSame(ground, GroundTypeFactory.get(0));
+ assertEquals("Grass", ground.getName());
}
}
\ No newline at end of file