blob: e0015be7ff4962f6189d9311136034d08b4c0719 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
const order = document.getElementById("graphOrder");
//TODO: read in player's name
function createGame(length){
const game = {
size: length,
finished: false,
board: Array(length).fill(true),
turn: 0,
version: "0.0.0",
human_turn: false,
winner: ""
}
//TODO: create game in DOM
return game;
}
function humanPlay(game){
}
function renderGame(game){
//TODO: update game in DOM
}
function displayMessage(text){
}
async function sendGame(game){
let response = await fetch("https://jpappel.xyz/toggle/query", {
method: "POST",
body: JSON.stringify(game),
headers: {
"Accept": "application/json",
"Content-Type": "application/json; charset=UTF-8"
}
})
return JSON.parse(response.json())
}
function playGame(){
const length = order.valueAsNumber;
const game = createGame(length);
console.log(sendGame(game))
//while(!game.finished){
// game.nextTurn(game.turn);
//}
// displayMessage(game.result);
}
|