-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (29 loc) · 881 Bytes
/
app.js
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
import boards from "./boards.js";
import move from "./move.js";
import httpServe from "./serve.js";
import wsServe from "./servews.js";
import test from "./test.js";
import captures from "./captures.js";
import pineapples from "./pineapples.js";
test();
const world = {};
function restart() {
if (!!world.boardId) delete world[world.boardId];
const newBoard = boards.createNewBoard();
world.boardId = newBoard.id;
world[world.boardId] = newBoard;
}
async function sendUpdates() {
const board = world[world.boardId];
board.head = new Date().toISOString();
if (board.gamestart + board.segfaultingIn <= new Date().getTime()) {
restart();
}
await move.moveCoders(board);
captures.checkCaptures(board);
//pineapples.spawnPineapple(board);
}
httpServe.serve();
wsServe.startWebsocket(world);
restart();
setInterval(sendUpdates, world[world.boardId].freq);