|
|
@ -2,13 +2,19 @@ package org.bitbiome.classes; |
|
|
|
|
|
|
|
import org.bitbiome.entities.Location; |
|
|
|
import org.bitbiome.entities.Player; |
|
|
|
import org.json.JSONArray; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
public class TravelEngine { |
|
|
|
|
|
|
|
private Location location; |
|
|
|
private JSONArray locations; |
|
|
|
JsonParser jp; |
|
|
|
private Player player; |
|
|
|
|
|
|
|
public TravelEngine(Player player) { |
|
|
|
jp = new JsonParser(); |
|
|
|
locations = jp.getJSONObject("../gameconfig.json").getJSONArray("locations"); |
|
|
|
this.player = player; |
|
|
|
} |
|
|
|
|
|
|
@ -20,4 +26,17 @@ public class TravelEngine { |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
} |