Browse Source

Edited TravelEngine, added getLocationList and locationExist method

remotes/origin/locations
David Hermann 2 years ago
parent
commit
157ceabc59
  1. 21
      src/main/java/org/bitbiome/classes/TravelEngine.java

21
src/main/java/org/bitbiome/classes/TravelEngine.java

@ -2,13 +2,19 @@ package org.bitbiome.classes;
import org.bitbiome.entities.Location; import org.bitbiome.entities.Location;
import org.bitbiome.entities.Player; import org.bitbiome.entities.Player;
import org.json.JSONArray;
import java.util.ArrayList;
public class TravelEngine { public class TravelEngine {
private Location location;
private JSONArray locations;
JsonParser jp;
private Player player; private Player player;
public TravelEngine(Player player) { public TravelEngine(Player player) {
jp = new JsonParser();
locations = jp.getJSONObject("../gameconfig.json").getJSONArray("locations");
this.player = player; this.player = player;
} }
@ -20,4 +26,17 @@ public class TravelEngine {
return player; return player;
} }
public JSONArray getLocationList() {
return locations;
}
public boolean locationExists(String name) {
boolean found = false;
for (int i = 0; i < locations.length(); i++)
if (locations.getJSONObject(i).getString("name").equals(name)) {
found = true;
}
return found;
}
} }
Loading…
Cancel
Save