33 lines
1013 B
Java
33 lines
1013 B
Java
package com.bernard.greposimu;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStreamReader;
|
|
import java.util.stream.Collectors;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
import com.bernard.greposimu.controller.JSONReader;
|
|
import com.bernard.greposimu.model.game.GameConfig;
|
|
|
|
public class GrepoSimu {
|
|
|
|
public static GameConfig makeGameData() throws IOException {
|
|
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
|
|
try (InputStream is = classLoader.getResourceAsStream("gamedata.json")) {
|
|
if (is == null) return null;
|
|
try (InputStreamReader isr = new InputStreamReader(is);
|
|
BufferedReader reader = new BufferedReader(isr)) {
|
|
|
|
// Reading the file
|
|
String json = reader.lines().collect(Collectors.joining(System.lineSeparator()));
|
|
|
|
JSONObject obj = new JSONObject(json);
|
|
|
|
return JSONReader.makeGameConfig(obj);
|
|
}
|
|
}
|
|
}
|
|
}
|