|
|
@ -14,6 +14,8 @@ import java.util.Iterator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Scanner; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue; |
|
|
|
|
|
|
|
public class Model { |
|
|
|
|
|
|
|
private static int SIZE = 9; |
|
|
@ -40,6 +42,7 @@ public class Model { |
|
|
|
return difficulty; |
|
|
|
} |
|
|
|
|
|
|
|
//1=easy, 2=medium, 3=hard |
|
|
|
public void setDifficulty(int difficulty) { |
|
|
|
this.difficulty = difficulty; |
|
|
|
} |
|
|
@ -121,15 +124,35 @@ public class Model { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void loadNewEasy() { |
|
|
|
String s = loadAllData(); |
|
|
|
JSONParser jsonParser = new JSONParser(); |
|
|
|
public void loadNewEasy(int p) { |
|
|
|
|
|
|
|
String data = Model.loadAllData(); |
|
|
|
|
|
|
|
setDifficulty(1); |
|
|
|
|
|
|
|
JSONParser parser = new JSONParser(); |
|
|
|
JSONObject jsonObject = null; |
|
|
|
|
|
|
|
try { |
|
|
|
JSONObject parse = (JSONObject) jsonParser.parse(s); |
|
|
|
jsonObject = (JSONObject) parser.parse(data); |
|
|
|
} catch (ParseException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
assertTrue(false, "parsing went wrong"); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
JSONArray easyGame = (JSONArray) jsonObject.get("easyGame"); |
|
|
|
|
|
|
|
JSONObject jsonObjectEasyGame = (JSONObject) easyGame.get(p); |
|
|
|
|
|
|
|
// Model modelEasy = new Model(jsonObjectEasyGame, new GameField(360)); |
|
|
|
// System.out.println(modelEasy); |
|
|
|
|
|
|
|
jsonToModel(jsonObjectEasyGame); |
|
|
|
|
|
|
|
} catch (IndexOutOfBoundsException e) { |
|
|
|
throw e; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void loadNewMedium() { |
|
|
@ -301,7 +324,6 @@ public class Model { |
|
|
|
JSONArray jsonArrayHard = new JSONArray(); |
|
|
|
jsonArrayHard.add(jsonObjectHard); |
|
|
|
|
|
|
|
|
|
|
|
jsonObjectRoot.put("easyGame", jsonArrayEasy); |
|
|
|
jsonObjectRoot.put("mediumGame", jsonArrayMedium); |
|
|
|
jsonObjectRoot.put("hardGame", jsonArrayHard); |
|
|
|