package dungeonmania.goals;
import org.json.JSONArray;
import org.json.JSONObject;
Copyright By PowCoder代写 加微信 powcoder
public class GoalFactory {
public static Goal createGoal(JSONObject jsonGoal, JSONObject config) {
JSONArray subgoals;
switch (jsonGoal.getString(“goal”)) {
case “AND”:
subgoals = jsonGoal.getJSONArray(“subgoals”);
return new Goal(
createGoal(subgoals.getJSONObject(0), config),
createGoal(subgoals.getJSONObject(1), config)
case “OR”:
subgoals = jsonGoal.getJSONArray(“subgoals”);
return new Goal(
createGoal(subgoals.getJSONObject(0), config),
createGoal(subgoals.getJSONObject(1), config)
case “exit”:
return new Goal(“exit”);
case “boulders”:
return new Goal(“boulders”);
case “treasure”:
int treasureGoal = config.optInt(“treasure_goal”, 1);
return new Goal(“treasure”, treasureGoal);
return null;
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com