import * as env from "/scripts/env.js" import * as status from "/scripts/net/status.js" import {game} from "/scripts/game/game.js" import {render} from "/scripts/display/draw.js" import { changeScene } from "/scripts/interface/scene.js" import { illegalAction } from "/scripts/interface/common/illegalaction.js" export var socket = io.connect(env.IP_ADDRESS); export function joinGame(data){ socket.emit('joinGame', data); } export function createGame(data){ socket.emit('createGame', data); } export function clickCanvas(data) { socket.emit('clickCanvas', data); } function leaveGame(socket){ socket.emit('leaveGame', {}); } socket.on('connect', function(data){ status.connected() }) socket.on('disconnect', function(data){ status.disconnected() }) socket.on('message', function(data) { const mess = document.getElementById("message") mess.textContent = `${data}` }) socket.on('illegalAction', function(data){ let action illegalAction(data) switch (data) { case 1: action = "You must be in game to do this." changeScene("mainmenu"); game.reset(); break; } }) socket.on('metadata', function(data){ console.log(data) }); socket.on('inGame', function(data){ if (!game.status) {changeScene("game")} game.status = true; }) socket.on('sync', function (sync){ game.world = sync.world; console.log(game.world) render() })