47 lines
1.6 KiB
Java
47 lines
1.6 KiB
Java
import java.io.IOException;
|
|
|
|
import javax.script.ScriptEngine;
|
|
import javax.script.ScriptException;
|
|
|
|
import org.graalvm.polyglot.Context;
|
|
import org.graalvm.polyglot.Engine;
|
|
import org.graalvm.polyglot.HostAccess;
|
|
|
|
import com.oracle.truffle.js.scriptengine.GraalJSScriptEngine;
|
|
|
|
import game.logic.GameLogic;
|
|
import game.logic.Parser;
|
|
import game.state.CircularLocationException;
|
|
import startup.Environment;
|
|
import startup.LoadStuff;
|
|
|
|
public class Main {
|
|
public static void main(String[] args) throws IOException {
|
|
|
|
LoadStuff loadStuff = new LoadStuff();
|
|
loadStuff.load(Environment.instance);
|
|
|
|
ScriptEngine jse = GraalJSScriptEngine.create(
|
|
Engine.newBuilder().option("engine.WarnInterpreterOnly", "false").build(),
|
|
Context.newBuilder("js").allowHostAccess(HostAccess.ALL).allowHostClassLookup(s -> true));
|
|
try {
|
|
// Entity t = new Entity("test");
|
|
jse.put("test", new Object());
|
|
jse.eval("console.log(test.toString());");
|
|
} catch (ScriptException e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
|
|
Parser parser = new Parser();
|
|
try (GameLogic logic = new GameLogic(parser)) {
|
|
logic.loadGameState("games/damnCoolTextAdventureFTW/game.json",
|
|
"games/damnCoolTextAdventureFTW/initialSave.json");
|
|
logic.mainLoop();
|
|
} catch (CircularLocationException ex) {
|
|
System.err.println("You messed up you game state: " + ex.getMessage());
|
|
ex.printStackTrace();
|
|
}
|
|
}
|
|
}
|