diff --git a/playerconfig.json b/playerconfig.json index 349a291..a7b104c 100644 --- a/playerconfig.json +++ b/playerconfig.json @@ -1,6 +1,6 @@ { "gold": 0, - "name": "Julia", + "name": "null", "hp": 10, "inventory": [ { @@ -20,5 +20,5 @@ "doesDamage": true } ], - "currentLocation": "Wald" + "currentLocation": "Berge" } \ No newline at end of file diff --git a/src/main/java/org/bitbiome/entities/Player.java b/src/main/java/org/bitbiome/entities/Player.java index 02bf2e6..de0977d 100644 --- a/src/main/java/org/bitbiome/entities/Player.java +++ b/src/main/java/org/bitbiome/entities/Player.java @@ -2,6 +2,9 @@ package org.bitbiome.entities; import org.bitbiome.classes.JsonParser; +import org.json.JSONArray; +import org.json.JSONObject; + import java.util.ArrayList; @@ -23,6 +26,14 @@ public class Player { hp = 100.0F; location = new Location(JsonParser.getJSONObject("src/main/resources/playerconfig.json").getString("currentLocation"), new ArrayList<>(), new ArrayList<>()); inventory = new ArrayList<>(); + JSONArray items = JsonParser.getJSONObject("src/main/resources/playerconfig.json").getJSONArray("inventory"); + for (int i = 0; i < items.length(); i++) { + JSONObject o = items.getJSONObject(i); + inventory.add(new Item(o.getString("name"), o.getBoolean("doesDamage"), o.getString("damage"), o.getInt("amount"), o.getInt("gold"))); + } + + + } public Player() { @@ -69,4 +80,7 @@ public class Player { public int setGold(int gold) { this.gold = gold; return gold; } + public void setInventory(ArrayList inventory) { + this.inventory = inventory; + } } diff --git a/src/main/resources/gameconfig.json b/src/main/resources/gameconfig.json index 058ad2f..c460a98 100644 --- a/src/main/resources/gameconfig.json +++ b/src/main/resources/gameconfig.json @@ -1,19 +1,19 @@ { "shopitems": [ { - "gold": 1000, - "amount": 1, - "name": "Heiliges Schwert der Engel" + "gold": 10, + "amount": 10, + "name": "Holz" }, { - "gold": 2, - "amount": 450, - "name": "Knochen" + "gold": 3, + "amount": 400, + "name": "Loewenkralle" }, { - "gold": 1, - "amount": 100, - "name": "Schnee" + "gold": 3, + "amount": 200, + "name": "Drachenhaut" } ], "locations": [ diff --git a/src/main/resources/items.json b/src/main/resources/items.json index e14b0b2..6329a39 100644 --- a/src/main/resources/items.json +++ b/src/main/resources/items.json @@ -1,4 +1,3 @@ -<<<<<<< HEAD [ { "name": "Holz", @@ -180,45 +179,4 @@ "amountShop": 700, "gold": 2 } -] -======= - - [ - { - "name": "Holz", - "damage": "1-3", - "crafting": true, - "doesDamage": true, - "durability": 1000, - "amountShop": 10, - "gold": 10 - }, - { - "name": "Heiliges Schwert der Engel", - "damage": "1000", - "crafting": false, - "doesDamage": true, - "durability": 1000, - "amountShop": 1, - "gold": 1000 - }, - { - "name": "Stein", - "damage": "5-10", - "crafting": true, - "doesDamage": true, - "durability": 1000, - "amountShop": 1500, - "gold": 2 - }, - { - "name": "Fell", - "damage": "0", - "crafting": true, - "doesDamage": false, - "durability": 1000, - "amountShop": 500, - "gold": 100 - } - ] ->>>>>>> 1ffe7490e8fd33b80231ec4852d6ca37658dcd5f +] \ No newline at end of file