diff --git a/.gitignore b/.gitignore
index a5d9a21..c15a9a2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,6 @@ hs_err_pid*
replay_pid*
.DS_Store
/.idea/
-/.out/
-/.target/
+/out/
+/target/
*.iml
\ No newline at end of file
diff --git a/build-project.sh b/build-project.sh
index 3891e04..46a589c 100644
--- a/build-project.sh
+++ b/build-project.sh
@@ -1,3 +1,3 @@
mvn test
-java src/main/java/org/example/Main.java
\ No newline at end of file
+mvn compile exec:java -Dexec.mainClass="org.bitbiome.Main"
diff --git a/pom.xml b/pom.xml
index 227f1c5..bd143b9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- org.example
+ org.bitbiome
BitBiome
1.0-SNAPSHOT
@@ -24,6 +24,13 @@
test
+
+
+ org.json
+ json
+ 20180130
+
+
diff --git a/src/main/java/org/bitbiome/Boot.java b/src/main/java/org/bitbiome/Boot.java
new file mode 100644
index 0000000..590ef38
--- /dev/null
+++ b/src/main/java/org/bitbiome/Boot.java
@@ -0,0 +1,23 @@
+package org.bitbiome;
+
+import org.bitbiome.commands.CommandListener;
+
+public class Boot {
+
+ private CommandListener cmdListener;
+ public static Boot instance;
+ public Boot() {
+ instance = this;
+ cmdListener = new CommandListener();
+ InteractionLoop game = new InteractionLoop();
+ game.run();
+ }
+
+ public CommandListener getCmdListener(){
+ return cmdListener;
+ }
+
+}
+
+
+
diff --git a/src/main/java/org/bitbiome/InteractionLoop.java b/src/main/java/org/bitbiome/InteractionLoop.java
new file mode 100644
index 0000000..e2a1cd0
--- /dev/null
+++ b/src/main/java/org/bitbiome/InteractionLoop.java
@@ -0,0 +1,21 @@
+package org.bitbiome;
+
+import java.util.Scanner;
+
+public class InteractionLoop {
+
+ Scanner input = new Scanner(System.in);
+
+ public void run() {
+ boolean isRunning = true;
+ while (isRunning) {
+ String line = input.nextLine().toLowerCase();
+ if (!Boot.instance.getCmdListener().perform(line.toLowerCase().split(" ")[0], input, isRunning, line)) {
+ System.out.println("Unknown Command");
+ }
+ }
+ }
+
+
+
+}
diff --git a/src/main/java/org/bitbiome/JsonParser.java b/src/main/java/org/bitbiome/JsonParser.java
new file mode 100644
index 0000000..5852e7e
--- /dev/null
+++ b/src/main/java/org/bitbiome/JsonParser.java
@@ -0,0 +1,30 @@
+package org.bitbiome;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+
+import java.io.InputStream;
+
+public class JsonParser {
+ public static JSONObject getJSONObject(String fileName) {
+ String resourceName = "./../../" + fileName;
+ InputStream is = JsonParser.class.getResourceAsStream(resourceName);
+ if (is == null) {
+ throw new NullPointerException("Cannot find resource file " + resourceName);
+ }
+
+ JSONTokener tokener = new JSONTokener(is);
+ JSONObject object = new JSONObject(tokener);
+ System.out.println("Name: " + object.getString("name"));
+
+ System.out.println("Inventory: ");
+ JSONArray inventory = object.getJSONArray("inventory");
+
+ for (int i = 0; i < inventory.length(); i++) {
+ JSONObject invObj = inventory.getJSONObject(i);
+ System.out.println(" - " + invObj.getString("name"));
+ }
+ return object;
+ }
+}
diff --git a/src/main/java/org/bitbiome/Main.java b/src/main/java/org/bitbiome/Main.java
new file mode 100644
index 0000000..e614ea5
--- /dev/null
+++ b/src/main/java/org/bitbiome/Main.java
@@ -0,0 +1,12 @@
+package org.bitbiome;
+
+
+public class Main {
+
+
+ public static void main(String[] args) {
+ //JSONObject playerConfig = JsonParser.getJSONObject("playerconfig.json");
+ new Boot();
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/bitbiome/commands/CommandAPI.java b/src/main/java/org/bitbiome/commands/CommandAPI.java
new file mode 100644
index 0000000..d3a67c6
--- /dev/null
+++ b/src/main/java/org/bitbiome/commands/CommandAPI.java
@@ -0,0 +1,8 @@
+package org.bitbiome.commands;
+
+import java.util.Scanner;
+
+public interface CommandAPI {
+ public void performCommand(Scanner scanner, boolean isRunning, String message);
+
+}
diff --git a/src/main/java/org/bitbiome/commands/CommandListener.java b/src/main/java/org/bitbiome/commands/CommandListener.java
new file mode 100644
index 0000000..2e62105
--- /dev/null
+++ b/src/main/java/org/bitbiome/commands/CommandListener.java
@@ -0,0 +1,35 @@
+package org.bitbiome.commands;
+
+import java.util.HashMap;
+import java.util.Scanner;
+
+public class CommandListener {
+
+ private HashMap commands;
+
+ public CommandListener() {
+ commands = new HashMap<>();
+
+ commands.put("help", new HelpCommand());
+
+ commands.put("exit", new QuitCommand());
+ commands.put("quit", new QuitCommand());
+ }
+
+ public HashMap returnCommands() {
+ return commands;
+ }
+
+
+ public boolean perform(String command, Scanner scanner, boolean isRunning, String message) {
+
+ CommandAPI cmd;
+ if ((cmd = commands.get(command)) != null) {
+ cmd.performCommand(scanner, isRunning, message);
+ return true;
+ }
+ return false;
+ }
+
+
+}
diff --git a/src/main/java/org/bitbiome/commands/HelpCommand.java b/src/main/java/org/bitbiome/commands/HelpCommand.java
new file mode 100644
index 0000000..4d88e3a
--- /dev/null
+++ b/src/main/java/org/bitbiome/commands/HelpCommand.java
@@ -0,0 +1,23 @@
+package org.bitbiome.commands;
+
+import org.bitbiome.Boot;
+
+import java.util.HashMap;
+import java.util.Scanner;
+
+public class HelpCommand implements CommandAPI {
+
+
+ @Override
+ public void performCommand(Scanner scanner, boolean isRunning, String message) {
+ System.out.println(getHelpMessage());
+ }
+
+ public static String getHelpMessage() {
+ StringBuilder outputMessage = new StringBuilder();
+ outputMessage.append("Hier ist eine Liste der Commands:\n").append("- help -> Gibt diese Nachricht aus\n").append("- exit/quit -> Beendet das Spiel\n");
+
+ return outputMessage.toString();
+ }
+
+}
diff --git a/src/main/java/org/bitbiome/commands/QuitCommand.java b/src/main/java/org/bitbiome/commands/QuitCommand.java
new file mode 100644
index 0000000..d969852
--- /dev/null
+++ b/src/main/java/org/bitbiome/commands/QuitCommand.java
@@ -0,0 +1,16 @@
+package org.bitbiome.commands;
+
+import java.util.Scanner;
+
+public class QuitCommand implements CommandAPI {
+
+ @Override
+ public void performCommand(Scanner scanner, boolean isRunning, String message) {
+ System.out.println(getQuitMessage());
+ System.exit(0);
+ }
+
+ public static String getQuitMessage() {
+ return "You quitted!";
+ }
+}
diff --git a/src/main/java/org/example/Main.java b/src/main/java/org/example/Main.java
deleted file mode 100644
index 0050cd6..0000000
--- a/src/main/java/org/example/Main.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.example;
-
-public class Main {
-
-
- public static void main(String[] args) {
- System.out.println("Hello World!");
- }
- public static int getLucky() {
- return 7;
- }
-
-}
\ No newline at end of file
diff --git a/src/main/resources/crafting.json b/src/main/resources/crafting.json
new file mode 100644
index 0000000..0e0dcd2
--- /dev/null
+++ b/src/main/resources/crafting.json
@@ -0,0 +1,3 @@
+{
+
+}
\ No newline at end of file
diff --git a/src/main/resources/gameconfig.json b/src/main/resources/gameconfig.json
new file mode 100644
index 0000000..a29ef19
--- /dev/null
+++ b/src/main/resources/gameconfig.json
@@ -0,0 +1,38 @@
+{
+ "shopitems": [
+ {
+ "name": "Holz",
+ "amount": 10,
+ "gold": 10
+ },
+ {
+ "name": "Heiliges Schwert der Engel",
+ "amount": 1,
+ "gold": 1000
+ },
+ {
+ "name": "Stein",
+ "amount": 5,
+ "gold": 100
+ }
+ ],
+ "locations": [
+ {
+ "name": "Wald",
+ "items": [
+ "Holz",
+ "Stein"
+ ],
+ "mobs": [
+ {
+ "name": "Big Foot",
+ "hp": 50,
+ "damage": "10-15",
+ "items": [
+ "Fell"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/main/resources/items.json b/src/main/resources/items.json
new file mode 100644
index 0000000..85b3f26
--- /dev/null
+++ b/src/main/resources/items.json
@@ -0,0 +1,26 @@
+[
+ {
+ "name": "Holz",
+ "damage": "1-3",
+ "crafting": true,
+ "durability": 1000
+ },
+ {
+ "name": "Heiliges Schwert der Engel",
+ "damage": "1000",
+ "crafting": false,
+ "durability": 1000
+ },
+ {
+ "name": "Stein",
+ "damage": "5-10",
+ "crafting": true,
+ "durability": 1000
+ },
+ {
+ "name": "Fell",
+ "damage": "0",
+ "crafting": true,
+ "durability": 1000
+ }
+]
\ No newline at end of file
diff --git a/src/main/resources/playerconfig.json b/src/main/resources/playerconfig.json
new file mode 100644
index 0000000..1a2c55e
--- /dev/null
+++ b/src/main/resources/playerconfig.json
@@ -0,0 +1,17 @@
+{
+ "name": "null",
+ "gold": 0,
+ "hp": 10,
+ "currentLocation": "Wald",
+ "inventory": [
+ {
+ "name": "Holz",
+ "amount": "5",
+ "durability": 1000
+ },{
+ "name": "Stein",
+ "amount": "5",
+ "durability": 1000
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/test/java/org/bitbiome/commands/HelpCommandTest.java b/src/test/java/org/bitbiome/commands/HelpCommandTest.java
new file mode 100644
index 0000000..75006ed
--- /dev/null
+++ b/src/test/java/org/bitbiome/commands/HelpCommandTest.java
@@ -0,0 +1,15 @@
+package org.bitbiome.commands;
+
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class HelpCommandTest {
+
+ @Test
+ public void testHelpCommand() {
+ String helpMessage = HelpCommand.getHelpMessage();
+ assertEquals("Hier ist eine Liste der Commands:\n- help -> Gibt diese Nachricht aus\n- exit/quit -> Beendet das Spiel\n", helpMessage);
+ }
+
+
+}
diff --git a/src/test/java/org/bitbiome/commands/QuitCommandTest.java b/src/test/java/org/bitbiome/commands/QuitCommandTest.java
new file mode 100644
index 0000000..67a368e
--- /dev/null
+++ b/src/test/java/org/bitbiome/commands/QuitCommandTest.java
@@ -0,0 +1,15 @@
+package org.bitbiome.commands;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class QuitCommandTest {
+
+
+ @Test
+ public void testQuitCommand() {
+ assertEquals("You quitted!", QuitCommand.getQuitMessage());
+ }
+
+}
diff --git a/src/test/java/org/example/TestMain.java b/src/test/java/org/example/TestMain.java
deleted file mode 100644
index 1417521..0000000
--- a/src/test/java/org/example/TestMain.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.example;
-
-import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-public class TestMain {
-
- @Test
- public void testLucky() {
- assertEquals(7, Main.getLucky());
- }
-
-}