Browse Source

edited player constructor

added to arrayList inventory the items of file playerconfig
remotes/origin/Julia
Juliakn66 2 years ago
parent
commit
c204733e70
  1. 11
      src/main/java/org/bitbiome/entities/Player.java

11
src/main/java/org/bitbiome/entities/Player.java

@ -2,6 +2,9 @@ package org.bitbiome.entities;
import org.bitbiome.classes.CreateLocations;
import org.bitbiome.classes.JsonParser;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
@ -20,6 +23,14 @@ public class Player {
hp = 100.0F;
location = new Location(jp.getJSONObject("playerconfig.json").getString("currentLocation"), new ArrayList<>(), new ArrayList<>());
inventory = new ArrayList<>();
JSONArray items = jp.getJSONObject("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.getFloat("damage"), o.getInt("amount")));
}
}
public String getName() {

Loading…
Cancel
Save