planet-wars/frontend/www/index.js
2019-09-14 10:48:20 +02:00

16 lines
431 B
JavaScript

import { Game } from "planetwars";
const URL = window.location.origin+window.location.pathname;
const LOCATION = URL.substring(0, URL.lastIndexOf("/") + 1);
const game_location = LOCATION + "static/game.json";
fetch(game_location)
.then((r) => r.text())
.then((response) => {
console.log(response);
let game = Game.new(response);
console.log(game.turn_count());
}).catch(console.error);