diff --git a/Pixerif.ttf b/Pixerif.ttf
new file mode 100644
index 0000000..5ced489
Binary files /dev/null and b/Pixerif.ttf differ
diff --git a/index.js b/index.js
deleted file mode 100644
index e6cbdbb..0000000
--- a/index.js
+++ /dev/null
@@ -1,175 +0,0 @@
-const worldgen = require("./worldgen.js")
-const util = require("./util.js")
-const log = require("./log.js")
-const {performance} = require('perf_hooks');
-const gridSize = [32, 32];
-const perlinScale = 4;
-var express = require('express');
-log.setMode(0);
-process.title = "Server"
-setInterval(function(){ updateInfo()},5000)
-
-function updateInfo() {
- log.setInfo(server.games)
-}
-
-class Player {
- constructor(id, name, color) {
- this.id = id;
- this.name = name;
- this.color = color;
- }
-}
-
-class Server {
- constructor(){
- this.games = [];
- }
- getGameByName(name, create) {
- const game = this.games.filter(obj => obj.name == name)[0]
- if (game === undefined && create) {
- this.addGame(name);
- // Oh no.... This cant be good code.
- // Coming back to it two months later. Horrible, but I don't know how to fix it. Maybe I'll leave it as an ancient artifact.
- return this.getGameByName(name);
- }
- return game
- }
-
- addGame(name) {
- const game = new Game(name);
- this.games.push(game);
- return game
- }
- removeGame(name) {
- this.games = this.games.filter(obj => obj.name != name);
- log.log("removed game - " + name)
- // Broken?
- }
-
- getAllIDs() {
- let ids = []
- for (let i = 0; i < this.games.length; i++) {
- for (let j = 0; j < this.games[i].players.length; j++) {
- ids.push(this.games[i].players[j].id)
- }
- }
- return ids
- }
-
- joinClientToGame(room, nick, id, client) {
- if (this.getAllIDs().includes(id)) {
- return client.illegalAction(22)
- }
- if (nick.length > 9) {
- return client.illegalAction(21)
- }
- const game = this.getGameByName(room, true);
- if (game.addPlayer(id, nick) == false) {
- this.removeGame(game)
- return client.illegalAction(20)
- }
-
- client.join(game.name)
- client.game = game;
- return true
- }
-
-
-}
-
-class Game {
- constructor(name) {
- this.name = name;
- this.players = [];
- this.world = worldgen.generateWorld(gridSize);
- }
-
- addPlayer(id, name) {
- if (this.getAllNames().includes(name)) return false
- var color = "blue"
- const player = new Player(id, name, color);
- this.players.push(player);
- return true
- }
-
- removePlayer(id) {
- this.players = this.players.filter(obj => obj.id != id);
- log.log("removed player - " + id)
- if (this.players.length < 1) {
- server.removeGame(this.name);
- }
- }
-
- getPlayerByID(id) {
- const player = this.players.filter(obj => obj.id == id)[0]
- return player
- }
-
- getAllIDs() {
- let ids = []
- for (let i = 0; i < this.players.length; i++) {
- ids.push(this.players[i].id)
- }
- return ids
- }
- getAllNames() {
- let names = []
- for (let i = 0; i < this.players.length; i++) {
- names.push(this.players[i].name)
- }
- return names
- }
-}
-var server = new Server();
-
-
-var app = express() //Static resources server
-app.use(express.static(__dirname + '/www/'));
-var webServer = app.listen(8082, function () {
- var port = webServer.address().port;
- log.logRight(0, `Server running at port ${port}`, "bright");
-});
-
-var io = require('socket.io')(webServer);/* Connection events */
-io.on('connection', function(client) {
-
- client.illegalAction = function(action) {
- client.emit('illegalAction', action)
-
- }
-
- log.log('User connected', 'FgGreen');
-
- client.on('disconnect', function(){
- if (!server.getAllIDs().includes(client.id)) return client.illegalAction(22)
- log.log(client.id + ' disconnected.', 'FgCyan')
- client.game.removePlayer(client.id)
- })
-
- client.on('joinGame', function(data){
- if(!server.joinClientToGame(data.room, data.name, client.id, client)) return
- io.to(client.game.name).emit('sync',{world: client.game.world})
- log.log(`${client.id} joined the game as ${data.name} requesting to join room: ${data.room}`, 'FgMagenta');
- client.emit('inGame', true)
- })
- client.on('leaveGame', function(data){
- log.log(client.id + ' disconnected.')
- client.game.removePlayer(client.id)
- io.to(client.game.name).emit('playerList', client.game.players)
- })
-
-
- client.on('clickCanvas', function(data){
- if (!server.getAllIDs().includes(client.id)) return client.illegalAction(1)
- const xu = util.clamp(data.tilePosition[0], 0, gridSize[0])
- const yu = util.clamp(data.tilePosition[1], 0, gridSize[1])
-
- if (!Number.isInteger(xu) || !Number.isInteger(yu)) return client.illegalAction(23)
-
- client.game.world[xu][yu].structure = data.structure
- io.to(client.game.name).emit('sync',{world: client.game.world})
- })
-
-
- });
diff --git a/index.mjs b/index.mjs
new file mode 100644
index 0000000..94fa5ca
--- /dev/null
+++ b/index.mjs
@@ -0,0 +1,10 @@
+import * as log from "./scripts/log.mjs"
+import "./scripts/roomManager.mjs"
+import "./scripts/server/netcode.mjs"
+import {roomManager} from "./scripts/roomManager.mjs"
+log.setMode(1);
+setInterval(function(){ updateInfo()},5000)
+
+function updateInfo() {
+ log.setInfo(roomManager.games)
+}
diff --git a/package-lock.json b/package-lock.json
index 311b43d..032d77c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -30,9 +30,9 @@
"integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw=="
},
"node_modules/@types/node": {
- "version": "17.0.30",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.30.tgz",
- "integrity": "sha512-oNBIZjIqyHYP8VCNAV9uEytXVeXG2oR0w9lgAXro20eugRQfY002qr3CUl6BAe+Yf/z3CRjPdz27Pu6WWtuSRw=="
+ "version": "18.0.0",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.0.0.tgz",
+ "integrity": "sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA=="
},
"node_modules/accepts": {
"version": "1.3.8",
@@ -49,7 +49,7 @@
"node_modules/array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
- "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
+ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
"node_modules/base64id": {
"version": "2.0.0",
@@ -137,7 +137,7 @@
"node_modules/cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
- "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
+ "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
},
"node_modules/cors": {
"version": "2.8.5",
@@ -179,12 +179,12 @@
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
- "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
+ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
},
"node_modules/encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
- "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=",
+ "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
"engines": {
"node": ">= 0.8"
}
@@ -249,12 +249,12 @@
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
- "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
+ "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
- "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=",
+ "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"engines": {
"node": ">= 0.6"
}
@@ -328,7 +328,7 @@
"node_modules/fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
- "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=",
+ "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
"engines": {
"node": ">= 0.6"
}
@@ -339,13 +339,13 @@
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"node_modules/get-intrinsic": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz",
- "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==",
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.2.tgz",
+ "integrity": "sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==",
"dependencies": {
"function-bind": "^1.1.1",
"has": "^1.0.3",
- "has-symbols": "^1.0.1"
+ "has-symbols": "^1.0.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
@@ -415,7 +415,7 @@
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
- "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=",
+ "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
"engines": {
"node": ">= 0.6"
}
@@ -423,12 +423,12 @@
"node_modules/merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
- "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
+ "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w=="
},
"node_modules/methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
- "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=",
+ "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
"engines": {
"node": ">= 0.6"
}
@@ -466,7 +466,7 @@
"node_modules/ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
- "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
},
"node_modules/negotiator": {
"version": "0.6.3",
@@ -479,15 +479,15 @@
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
- "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
+ "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/object-inspect": {
- "version": "1.12.0",
- "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz",
- "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==",
+ "version": "1.12.2",
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz",
+ "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
@@ -514,7 +514,7 @@
"node_modules/path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
- "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
+ "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
},
"node_modules/proxy-addr": {
"version": "2.0.7",
@@ -649,9 +649,9 @@
}
},
"node_modules/socket.io": {
- "version": "4.5.0",
- "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.5.0.tgz",
- "integrity": "sha512-slTYqU2jCgMjXwresG8grhUi/cC6GjzmcfqArzaH3BN/9I/42eZk9yamNvZJdBfTubkjEdKAKs12NEztId+bUA==",
+ "version": "4.5.1",
+ "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.5.1.tgz",
+ "integrity": "sha512-0y9pnIso5a9i+lJmsCdtmTTgJFFSvNQKDnPQRz28mGNnxbmqYg2QPtJTLFxhymFZhAIn50eHAKzJeiNaKr+yUQ==",
"dependencies": {
"accepts": "~1.3.4",
"base64id": "~2.0.0",
@@ -727,7 +727,7 @@
"node_modules/socket.js": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/socket.js/-/socket.js-0.1.4.tgz",
- "integrity": "sha1-9CfaaFPXVnPsM2X2kYAMopQ2Cj4="
+ "integrity": "sha512-2JqBbfPOslz48eSRibPa98123V2iR5vxWBQt7w3pSxEgCMOHafNqmjpdZLpwcXe6y6H+Mj0MablR1VXfU4NN2Q=="
},
"node_modules/statuses": {
"version": "2.0.1",
@@ -760,7 +760,7 @@
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
- "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=",
+ "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"engines": {
"node": ">= 0.8"
}
@@ -768,7 +768,7 @@
"node_modules/utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
- "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=",
+ "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
"engines": {
"node": ">= 0.4.0"
}
@@ -776,7 +776,7 @@
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
- "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=",
+ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"engines": {
"node": ">= 0.8"
}
@@ -819,9 +819,9 @@
"integrity": "sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw=="
},
"@types/node": {
- "version": "17.0.30",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.30.tgz",
- "integrity": "sha512-oNBIZjIqyHYP8VCNAV9uEytXVeXG2oR0w9lgAXro20eugRQfY002qr3CUl6BAe+Yf/z3CRjPdz27Pu6WWtuSRw=="
+ "version": "18.0.0",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.0.0.tgz",
+ "integrity": "sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA=="
},
"accepts": {
"version": "1.3.8",
@@ -835,7 +835,7 @@
"array-flatten": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
- "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
+ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
},
"base64id": {
"version": "2.0.0",
@@ -901,7 +901,7 @@
"cookie-signature": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
- "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
+ "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
},
"cors": {
"version": "2.8.5",
@@ -933,12 +933,12 @@
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
- "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
+ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
},
"encodeurl": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
- "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
+ "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w=="
},
"engine.io": {
"version": "6.2.0",
@@ -985,12 +985,12 @@
"escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
- "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
+ "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
},
"etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
- "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
+ "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg=="
},
"express": {
"version": "4.18.1",
@@ -1052,7 +1052,7 @@
"fresh": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
- "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
+ "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="
},
"function-bind": {
"version": "1.1.1",
@@ -1060,13 +1060,13 @@
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"get-intrinsic": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz",
- "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==",
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.2.tgz",
+ "integrity": "sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==",
"requires": {
"function-bind": "^1.1.1",
"has": "^1.0.3",
- "has-symbols": "^1.0.1"
+ "has-symbols": "^1.0.3"
}
},
"has": {
@@ -1115,17 +1115,17 @@
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
- "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
+ "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ=="
},
"merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
- "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
+ "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w=="
},
"methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
- "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
+ "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w=="
},
"mime": {
"version": "1.6.0",
@@ -1148,7 +1148,7 @@
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
- "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
},
"negotiator": {
"version": "0.6.3",
@@ -1158,12 +1158,12 @@
"object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
- "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
+ "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="
},
"object-inspect": {
- "version": "1.12.0",
- "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz",
- "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g=="
+ "version": "1.12.2",
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz",
+ "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ=="
},
"on-finished": {
"version": "2.4.1",
@@ -1181,7 +1181,7 @@
"path-to-regexp": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
- "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
+ "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
},
"proxy-addr": {
"version": "2.0.7",
@@ -1280,9 +1280,9 @@
}
},
"socket.io": {
- "version": "4.5.0",
- "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.5.0.tgz",
- "integrity": "sha512-slTYqU2jCgMjXwresG8grhUi/cC6GjzmcfqArzaH3BN/9I/42eZk9yamNvZJdBfTubkjEdKAKs12NEztId+bUA==",
+ "version": "4.5.1",
+ "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.5.1.tgz",
+ "integrity": "sha512-0y9pnIso5a9i+lJmsCdtmTTgJFFSvNQKDnPQRz28mGNnxbmqYg2QPtJTLFxhymFZhAIn50eHAKzJeiNaKr+yUQ==",
"requires": {
"accepts": "~1.3.4",
"base64id": "~2.0.0",
@@ -1340,7 +1340,7 @@
"socket.js": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/socket.js/-/socket.js-0.1.4.tgz",
- "integrity": "sha1-9CfaaFPXVnPsM2X2kYAMopQ2Cj4="
+ "integrity": "sha512-2JqBbfPOslz48eSRibPa98123V2iR5vxWBQt7w3pSxEgCMOHafNqmjpdZLpwcXe6y6H+Mj0MablR1VXfU4NN2Q=="
},
"statuses": {
"version": "2.0.1",
@@ -1364,17 +1364,17 @@
"unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
- "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
+ "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ=="
},
"utils-merge": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
- "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
+ "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA=="
},
"vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
- "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
+ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="
},
"ws": {
"version": "8.2.3",
diff --git a/package.json b/package.json
index 70a2013..a1ac1e5 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "empires",
"version": "1.0.0",
"description": "",
- "main": "index.js",
+ "main": "index.mjs",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
diff --git a/pixerif.woff2 b/pixerif.woff2
new file mode 100644
index 0000000..800b678
Binary files /dev/null and b/pixerif.woff2 differ
diff --git a/scripts/env.mjs b/scripts/env.mjs
new file mode 100644
index 0000000..b4c6537
--- /dev/null
+++ b/scripts/env.mjs
@@ -0,0 +1 @@
+export const port = 8082;
diff --git a/scripts/game.mjs b/scripts/game.mjs
new file mode 100644
index 0000000..29383df
--- /dev/null
+++ b/scripts/game.mjs
@@ -0,0 +1,54 @@
+import {Player} from "./player.mjs"
+import * as log from "./log.mjs"
+import {roomManager} from "./roomManager.mjs"
+import { World} from "./world/world.mjs"
+
+export class Game {
+ constructor(name) {
+ this.name = name;
+ this.players = [];
+ this.world = new World([32,32])
+ }
+
+ addPlayer(id, name) {
+ if (this.getAllNames().includes(name)) return false
+ var color = 1
+ const player = new Player(id, name, color);
+ this.players.push(player);
+ return player
+ }
+
+ removePlayerByID(id) {
+ this.players = this.players.filter(obj => obj.id != id);
+ log.log("removed player - " + id)
+ if (this.players.length < 1) {
+ roomManager.removeGame(this.name);
+ }
+ }
+
+ getAllIDs() {
+ let ids = []
+ for (let i = 0; i < this.players.length; i++) {
+ ids.push(this.players[i].id)
+ }
+ return ids
+ }
+ getAllNames() {
+ let names = []
+ for (let i = 0; i < this.players.length; i++) {
+ names.push(this.players[i].name)
+ }
+ return names
+ }
+
+ getSettings() {
+ const settings =
+ {
+ mines: this.world.mines,
+ dimensions: this.world.dimensions,
+ name: this.name
+ }
+ return settings
+
+ }
+}
diff --git a/log.js b/scripts/log.mjs
similarity index 86%
rename from log.js
rename to scripts/log.mjs
index 6a61510..85d6759 100644
--- a/log.js
+++ b/scripts/log.mjs
@@ -1,14 +1,14 @@
-const os = require("os")
+import * as os from "os"
var mode = 0
var logs = []
var rightView = [0,1,2,3,4,5,6]
var info = [[],[]]
-function setMode(type) {
+export function setMode(type) {
mode = type
}
-function updateLog() {
+export function updateLog() {
if (mode) return
let templogs = logs;
@@ -53,12 +53,9 @@ for (var i = 0; i < templogs.length; i++ ) {
}
}
-function logRight(line, text) {
- rightView[line] = text;
- updateLog();
-}
-function log(string, color) {
+
+export function log(string, color) {
if (mode) return console.log(string)
if (string == undefined) return;
var prefix = '';
@@ -118,7 +115,7 @@ logs.push(newString)
updateLog();
}
-function setInfo (players){
+export function setInfo (players){
if (mode) return false
if (players != undefined) {
info[0] = players;
@@ -126,5 +123,3 @@ if (players != undefined) {
}
}
-
-module.exports = {log, updateLog, setInfo, setMode, logRight}
diff --git a/scripts/player.mjs b/scripts/player.mjs
new file mode 100644
index 0000000..2720897
--- /dev/null
+++ b/scripts/player.mjs
@@ -0,0 +1,7 @@
+export class Player {
+ constructor(id, name, color) {
+ this.id = id;
+ this.name = name;
+ this.color = color;
+ }
+}
diff --git a/scripts/roomManager.mjs b/scripts/roomManager.mjs
new file mode 100644
index 0000000..78414cd
--- /dev/null
+++ b/scripts/roomManager.mjs
@@ -0,0 +1,64 @@
+import {Game} from "./game.mjs"
+import * as log from "./log.mjs"
+import {IllegalAction} from "./server/illegalAction.mjs"
+class RoomManager {
+ constructor(){
+ this.games = [];
+ }
+ getGameByName(name, create) {
+ const game = this.games.filter(obj => obj.name == name)[0]
+ if (game === undefined && create) {
+ this.addGame(name);
+ // Oh no.... This cant be good code.
+ // Coming back to it two months later. Horrible, but I don't know how to fix it. Maybe I'll leave it as an ancient artifact.
+ return this.getGameByName(name);
+ }
+ return game
+ }
+
+ addGame(name, settings) {
+ const game = new Game(name, settings);
+ this.games.push(game);
+ return game
+ }
+ removeGame(name) {
+ this.games = this.games.filter(obj => obj.name != name);
+ log.log("removed game - " + name)
+ // Broken?
+ }
+
+ getAllIDs() {
+ let ids = []
+ for (let i = 0; i < this.games.length; i++) {
+ for (let j = 0; j < this.games[i].players.length; j++) {
+ ids.push(this.games[i].players[j].id)
+ }
+ }
+ return ids
+ }
+
+ joinClientToGame(room, nick, id, client) {
+ if (this.getAllIDs().includes(id)) {
+ return new IllegalAction(id, 22)
+ }
+ if (nick.length > 9) {
+ return new IllegalAction(id, 21)
+ }
+ const game = this.getGameByName(room, true);
+ const player = game.addPlayer(id, nick);
+ if (player === false) {
+ this.removeGame(game)
+ return new IllegalAction(id, 20)
+ }
+
+ client.join(game.name)
+ client.game = game;
+ client.player = player
+ return true
+ }
+
+
+}
+
+
+export var roomManager = new RoomManager();
diff --git a/scripts/server/illegalAction.mjs b/scripts/server/illegalAction.mjs
new file mode 100644
index 0000000..e790256
--- /dev/null
+++ b/scripts/server/illegalAction.mjs
@@ -0,0 +1,11 @@
+import {io} from "./io.mjs"
+export class IllegalAction {
+ constructor(id, action){
+ this.action = action
+ this.id = id
+ this.sendIllegalAction();
+ }
+ sendIllegalAction() {
+ io.to(this.id).emit('illegalAction', this.action)
+ }
+}
diff --git a/scripts/server/io.mjs b/scripts/server/io.mjs
new file mode 100644
index 0000000..040adc3
--- /dev/null
+++ b/scripts/server/io.mjs
@@ -0,0 +1,4 @@
+import {webServer} from "./server.mjs"
+import { Server } from "socket.io";
+
+export const io = new Server(webServer, {});
diff --git a/scripts/server/netcode.mjs b/scripts/server/netcode.mjs
new file mode 100644
index 0000000..fbc9817
--- /dev/null
+++ b/scripts/server/netcode.mjs
@@ -0,0 +1,55 @@
+import {IllegalAction} from "./illegalAction.mjs"
+import * as log from "../log.mjs"
+import {roomManager} from "../roomManager.mjs"
+import {io} from "./io.mjs"
+var oldWorld = 0
+
+io.on('connection', function(client){
+ connected(client)
+});
+
+
+function connected(client) {
+ client.sync = function() {
+ const tempWorld = client.game.world.obfuscate();
+ io.to(client.game.name).emit('sync',{world: tempWorld})
+ }
+
+ client.sendMeta = function() {
+ const roomSettings = client.game.getSettings();
+ const roomPlayers = client.game.players; // Dont send client id's to everyone, TODO
+ const metadata = {players: roomPlayers, settings: roomSettings}
+ io.to(client.game.name).emit('metadata', metadata)
+ }
+
+ client.game = "";
+ client.player = "";
+
+ client.on('disconnect', function(){
+ if (!roomManager.getAllIDs().includes(client.id)) return new IllegalAction(client.id, 22)
+ log.log(client.id + ' disconnected.', 'FgCyan')
+ client.game.removePlayerByID(client.id)
+ client.sendMeta();
+ })
+
+ client.on('joinGame', function(data){
+ if(!roomManager.joinClientToGame(data.room, data.name, client.id, client)) return
+ client.sync()
+ log.log(`${client.id} joined the game as ${data.name} requesting to join room: ${data.room}`, 'FgMagenta');
+ client.emit('inGame', true)
+ client.sendMeta()
+ })
+ client.on('leaveGame', function(data){
+ log.log(client.id + ' disconnected.')
+ client.game.removePlayerByID(client.id)
+
+ })
+
+
+ client.on('clickCanvas', function(data){
+ if (!roomManager.getAllIDs().includes(client.id)) return new IllegalAction(client.id, 1)
+ client.game.world.click([data.tilePosition[0],data.tilePosition[1]], data.mode, client.player)
+
+ client.sync()
+ })
+}
diff --git a/scripts/server/server.mjs b/scripts/server/server.mjs
new file mode 100644
index 0000000..67a5665
--- /dev/null
+++ b/scripts/server/server.mjs
@@ -0,0 +1,10 @@
+import path from 'path';
+import express from "express"
+import { port } from "../env.mjs"
+var app = express()
+
+const __dirname = path.resolve(path.dirname(''));
+app.use(express.static(__dirname + '/www/'));
+export var webServer = app.listen(port, function () {
+ var port = webServer.address().port;
+});
diff --git a/scripts/util.mjs b/scripts/util.mjs
new file mode 100644
index 0000000..34f6929
--- /dev/null
+++ b/scripts/util.mjs
@@ -0,0 +1,6 @@
+export function randomNumber(min, max) {
+ return Math.floor(Math.random() * (max - min) + min);
+}
+export function clamp(number, min, max) {
+ return Math.max(min, Math.min(number, max));
+}
diff --git a/scripts/world/flagger.mjs b/scripts/world/flagger.mjs
new file mode 100644
index 0000000..e76946d
--- /dev/null
+++ b/scripts/world/flagger.mjs
@@ -0,0 +1,22 @@
+
+export function flag(data, location, player) {
+ let tile = data[location[0]][location[1]]
+
+ if (!tile.mask || tile.color === 0) return data
+ const color = player.color * 1
+ console.log(player)
+
+ switch (tile.flag) {
+ case (0):
+ tile.flag = color;
+ break;
+ case (color):
+ tile.flag = color + 16;
+ break;
+ default:
+ tile.flag = 0;
+ }
+ console.log(tile.flag)
+ data[location[0]][location[1]] = tile
+ return data;
+}
diff --git a/scripts/world/generator.mjs b/scripts/world/generator.mjs
new file mode 100644
index 0000000..8652e68
--- /dev/null
+++ b/scripts/world/generator.mjs
@@ -0,0 +1,42 @@
+import * as util from "../util.mjs"
+const searchLoc =
+// [
+// [0, 2],
+// [-1, 1], [0, 1], [1, 1],
+// [-2,0], [-1, 0],/*Start*/[1, 0], [2,0],
+// [-1,-1], [0,-1], [1,-1],
+// [0,-2]
+//
+// ]
+[
+ [-1,1], [0,1], [1,1],
+ [-1,0], [1,0],
+ [-1,-1],[0,-1],[1,-1]
+]
+
+export function generate(world, avoidLocation){
+ var minesPlanted = 0;
+ while (minesPlanted < world.mines || !(minesPlanted <= world.dimensions[0]*world.dimensions[1]-15)) {
+ const x = util.randomNumber(0,world.dimensions[0])
+ const y = util.randomNumber(0,world.dimensions[1])
+ var suitable = true;
+ searchLoc.forEach(loc => {
+ const tempx = x + loc[0]
+ const tempy = y + loc[1]
+ if (tempx === avoidLocation[0] && tempy === avoidLocation[1]) {
+ suitable = false;
+ }
+ })
+ // console.log([x,y] + ":----:" + avoidLocation)
+ if (x == avoidLocation[0] && y == avoidLocation[1]) { suitable = false }
+ if (world.data[x][y].type == 5) { suitable = false }
+
+ if (suitable) {
+ world.data[x][y].type = 5
+ minesPlanted++;
+ }
+ }
+
+ world.isGenerated = true;
+ return world;
+}
diff --git a/scripts/world/marker.mjs b/scripts/world/marker.mjs
new file mode 100644
index 0000000..d0805ae
--- /dev/null
+++ b/scripts/world/marker.mjs
@@ -0,0 +1,32 @@
+const searchLoc =
+[
+ [-1,1], [0,1], [1,1],
+ [-1,0], [1,0],
+ [-1,-1],[0,-1],[1,-1]
+]
+// Place Numbers
+export function mark(world) {
+
+for(let x = 0; x < world.dimensions[0]; x++){
+ for(let y = 0; y < world.dimensions[1]; y++){
+ if (world.data[x][y].type === 1) {
+ var counter = 0;
+ searchLoc.forEach(location => {
+ const tempx = x + location[0]
+ const tempy = y + location[1]
+ if (tempx >= 0 && tempy >= 0 && tempx < world.dimensions[0] && tempy < world.dimensions[1]) {
+ if (world.data[tempx][tempy].type === 5) {
+ counter++;
+ }
+ }
+ });
+ if (counter !== 0) {
+ world.data[x][y].type = 15 + counter
+ }
+ }
+ }
+}
+ world.isMarked = true;
+ return world;
+
+}
diff --git a/scripts/world/obfuscator.mjs b/scripts/world/obfuscator.mjs
new file mode 100644
index 0000000..68a8a38
--- /dev/null
+++ b/scripts/world/obfuscator.mjs
@@ -0,0 +1,16 @@
+
+export function obfuscate(world) {
+ let tempWorld = world;
+ for(let x = 0; x < tempWorld.dimensions[0]; x++){
+ for(let y = 0; y < tempWorld.dimensions[1]; y++){
+
+ if (tempWorld.data[x][y].mask === true) {
+
+ tempWorld.data[x][y].type = 0;
+ };
+ tempWorld.isObfuscated = true;
+
+ }
+ }
+ return tempWorld;
+}
diff --git a/scripts/world/placer.mjs b/scripts/world/placer.mjs
new file mode 100644
index 0000000..c098042
--- /dev/null
+++ b/scripts/world/placer.mjs
@@ -0,0 +1,14 @@
+import * as log from "../log.mjs"
+import * as revealer from "./revealer.mjs"
+export function place(data, location, id) {
+ let tile = data[location[0]][location[1]];
+ if (tile.mask === true) {
+ if (tile.mask && tile.flag === 0) {
+ tile.mask = false;
+ }
+
+ data[location[0]][location[1]] = tile;
+ revealer.reveal(data, location)
+ }
+ return data;
+}
diff --git a/scripts/world/revealer.mjs b/scripts/world/revealer.mjs
new file mode 100644
index 0000000..1cfed20
--- /dev/null
+++ b/scripts/world/revealer.mjs
@@ -0,0 +1,43 @@
+
+const searchLoc =
+[
+ [-1,1], [0,1], [1,1],
+ [-1,0], [1,0],
+ [-1,-1],[0,-1],[1,-1]
+]
+
+export function reveal(data, location) {
+ if (data[location[0]][location[1]].type !== 5) {
+
+ var toSearch = [];
+ var searchedLocations = [];
+ toSearch.push(location)
+
+ if (data[location[0]][location[1]].type === 1) {
+ while (toSearch.length > 0) {
+ const x = toSearch[0][0]
+ const y = toSearch[0][1]
+ searchedLocations.push(toSearch[0])
+ toSearch.shift()
+ searchLoc.forEach(loc => {
+ const tempx = x + loc[0]
+ const tempy = y + loc[1]
+ if (tempx >= 0 && tempy >= 0 && tempx < data.length && tempy < data[0].length) {
+
+ if (data[tempx][tempy].type === 1 && data[tempx][tempy].mask === true) {
+
+ if (!toSearch.includes([tempx,tempy]) && !searchedLocations.includes([tempx,tempy])) {
+ toSearch.push([tempx,tempy])
+ }
+ }
+ if (data[tempx][tempy].type !== 5) {
+ data[tempx][tempy].mask = false;
+ }
+ }
+ })
+
+ }
+ }
+ return data
+ }
+}
diff --git a/scripts/world/world.mjs b/scripts/world/world.mjs
new file mode 100644
index 0000000..a9b79dc
--- /dev/null
+++ b/scripts/world/world.mjs
@@ -0,0 +1,55 @@
+import * as obfuscater from "./obfuscator.mjs";
+import * as generator from "./generator.mjs"
+import * as marker from "./marker.mjs"
+import * as log from "../log.mjs"
+import * as flagger from "./flagger.mjs"
+import * as placer from "./placer.mjs"
+
+export class World {
+ constructor(dimensions = [32,32], mines = 30) {
+ this.mines = 200
+ this.dimensions = dimensions;
+ this.isGenerated = false;
+ this.isObfuscated = false;
+ this.isMarked = false;
+ this.data = Array.from(Array(this.dimensions[0]), () => new Array(this.dimensions[1]));
+ for (let x = 0; x < this.dimensions[0]; x++){
+ for (let y = 0; y < this.dimensions[1]; y++){
+ this.data[x][y] = {type: 1, flag: 0, mask: true}
+ }
+ }
+ }
+
+ click (location, mode, player) {
+ if (this.isGenerated) {
+ if (mode === 2) {
+ this.data = flagger.flag(this.data, location, player)
+ }
+
+ if (mode === 0) {
+ this.data = placer.place(this.data, location, player)
+ }
+ } else {
+ this.generate(location).mark();
+ this.data = placer.place(this.data, location, player)
+ }
+
+ }
+
+ generate(location) {
+ if (this.isGenerated) return log.log("Already Generated");
+ return generator.generate(this, location);
+ }
+
+ mark() {
+ if (this.isMarked) return log.log("Already Marked!");
+ return marker.mark(this);
+ }
+
+ obfuscate() {
+ if (this.isObfuscated) return log.log("already done")
+ const tempWorld = JSON.parse(JSON.stringify(this));;
+ return obfuscater.obfuscate(tempWorld);
+ }
+
+}
diff --git a/util.js b/util.js
deleted file mode 100644
index 284a94f..0000000
--- a/util.js
+++ /dev/null
@@ -1,7 +0,0 @@
-function randomNumber(min, max) {
- return Math.floor(Math.random() * (max - min) + min);
-}
-function clamp(number, min, max) {
- return Math.max(min, Math.min(number, max));
-}
-module.exports = {randomNumber, clamp}
diff --git a/worldgen.js b/worldgen.js
deleted file mode 100644
index dc3b9c0..0000000
--- a/worldgen.js
+++ /dev/null
@@ -1,77 +0,0 @@
-const util = require("./util.js")
-const log = require("./log.js")
-const searchLoc =
-[
- [-1,1], [0,1], [1,1],
- [-1,0], [1,0],
- [-1,-1],[0,-1],[1,-1]
-]
-function generateWorld(gridSize, perlinScale){
- let x, y = 0
-
- let tempWorld = Array.from(Array(gridSize[0]), () => new Array(gridSize[1]));
- for (x = 0; x < gridSize[0]; x++){
- for (y = 0; y < gridSize[1]; y++){
- tempWorld[x][y] = {type: 0, structure: 0, flag: 0, mask: true}
- }
- }
-
-// Generate board
- for(let x = 0; x < gridSize[0]; x++){
- for(let y = 0; y < gridSize[1]; y++){
- const value = util.randomNumber(0, 6);
- var n;
- switch (value) {
- case 0:
- n = 0;
- break;
- case 1:
- n = 0
- break;
- case 2:
- n = 0
- break;
- case 3:
- n = 0
- break;
- case 4:
- n = 0
- break;
- case 5:
- n = 5
- break;
- default:
- log.log("OTHER")
- n = 7
-
- }
- tempWorld[x][y].type = n
-
- }
-}
-// Place Numbers
-for(let x = 0; x < gridSize[0]; x++){
- for(let y = 0; y < gridSize[1]; y++){
- if (tempWorld[x][y].type === 0) {
- var counter = 0;
- searchLoc.forEach(location => {
- const tempx = x + location[0]
- const tempy = y + location[1]
- if (tempx >= 0 && tempy >= 0 && tempx < gridSize[0] && tempy < gridSize[1]) {
- if (tempWorld[tempx][tempy].type === 5) {
- counter++;
- }
- }
- });
- if (counter !== 0) {
- tempWorld[x][y].type = 15 + counter
- }
- }
- }
-}
-
-
- return tempWorld;
-}
-
-module.exports = { generateWorld };
diff --git a/www/index.html b/www/index.html
index b2cfa1d..d4ac11f 100644
--- a/www/index.html
+++ b/www/index.html
@@ -3,7 +3,7 @@
-
+
diff --git a/www/mine.png b/www/mine.png
index c538326..43c2de4 100644
Binary files a/www/mine.png and b/www/mine.png differ
diff --git a/www/scripts/display/draw.js b/www/scripts/display/draw.js
index 14802c2..ab7e45a 100644
--- a/www/scripts/display/draw.js
+++ b/www/scripts/display/draw.js
@@ -16,28 +16,18 @@ export function renderTiles() { // DRAW THE IMAGE TO THE CANVAS.
for(y = 0; y < gridSize[1]; y++){
const xu = x*tileSize;
const yu = y*tileSize;
- const tempWorld = game.world;
+ const tempWorld = game.world.data;
// Draw buildings
ctx.drawImage(tileArray[tempWorld[x][y].type], xu,yu)
// Draw Structures
- switch (tempWorld[x][y].structure) {
- case (1):
- ctx.drawImage(tileArray[4], xu,yu)
- break;
- case (2):
- ctx.drawImage(tileArray[32], xu,yu)
- break;
- case (3):
- ctx.drawImage(tileArray[33], xu,yu)
- break;
- case (4):
- ctx.drawImage(tileArray[34], xu,yu)
-
- break;
- }
-
+ const flag = tempWorld[x][y].flag
+ // console.log(flag)
+ if (flag !== 0) {
+ // console.log("FALAG")
+ ctx.drawImage(tileArray[flag + 7], xu,yu)
+ }
}
}
diff --git a/www/scripts/interface/game/mouse.js b/www/scripts/interface/game/mouse.js
index b958152..28fee6c 100644
--- a/www/scripts/interface/game/mouse.js
+++ b/www/scripts/interface/game/mouse.js
@@ -43,9 +43,10 @@ function getMousePosition(canvas, event) {
const y = event.clientY - rect.top;
const xu = cursor.x
const yu = cursor.y
+ const button = event.button
console.log("Click!")
console.log(xu,yu)
- clickCanvas({tilePosition: [xu,yu], structure: getButton()*1})
+ clickCanvas({tilePosition: [xu,yu], mode: button})
}
diff --git a/www/scripts/net/netcode.js b/www/scripts/net/netcode.js
index 74372b1..a0aea16 100644
--- a/www/scripts/net/netcode.js
+++ b/www/scripts/net/netcode.js
@@ -40,7 +40,7 @@ socket.on('illegalAction', function(data){
})
-socket.on('playerList', function(data){
+socket.on('metadata', function(data){
console.log(data)
});
diff --git a/www/socket.io.js b/www/socket.io.js
deleted file mode 100644
index 7738dec..0000000
--- a/www/socket.io.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/*!
- * Socket.IO v3.1.3
- * (c) 2014-2021 Guillermo Rauch
- * Released under the MIT License.
- */
-!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.io=e():t.io=e()}(self,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=17)}([function(t,e,n){function r(t){if(t)return function(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}(t)}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},r.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var o=0;o0;case l.ACK:case l.BINARY_ACK:return Array.isArray(e)}}}]),n}(h);e.Decoder=b;var m=function(){function t(e){u(this,t),this.packet=e,this.buffers=[],this.reconPack=e}return p(t,[{key:"takeBinaryData",value:function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){var e=y.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}},{key:"finishedReconstruction",value:function(){this.reconPack=null,this.buffers=[]}}]),t}()},function(t,e){var n=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(t){var e=t,o=t.indexOf("["),i=t.indexOf("]");-1!=o&&-1!=i&&(t=t.substring(0,o)+t.substring(o,i).replace(/:/g,";")+t.substring(i,t.length));for(var s,c,a=n.exec(t||""),u={},f=14;f--;)u[r[f]]=a[f]||"";return-1!=o&&-1!=i&&(u.source=e,u.host=u.host.substring(1,u.host.length-1).replace(/;/g,":"),u.authority=u.authority.replace("[","").replace("]","").replace(/;/g,":"),u.ipv6uri=!0),u.pathNames=function(t,e){var n=e.replace(/\/{2,9}/g,"/").split("/");"/"!=e.substr(0,1)&&0!==e.length||n.splice(0,1);"/"==e.substr(e.length-1,1)&&n.splice(n.length-1,1);return n}(0,u.path),u.queryKey=(s=u.query,c={},s.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,n){e&&(c[e]=n)})),c),u}},function(t,e,n){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var n=0;n=this._reconnectionAttempts)this.backoff.reset(),i(u(v.prototype),"emit",this).call(this,"reconnect_failed"),this._reconnecting=!1;else{var n=this.backoff.duration();this._reconnecting=!0;var r=setTimeout((function(){e.skipReconnect||(i(u(v.prototype),"emit",t).call(t,"reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((function(n){n?(e._reconnecting=!1,e.reconnect(),i(u(v.prototype),"emit",t).call(t,"reconnect_error",n)):e.onreconnect()})))}),n);this.subs.push((function(){clearTimeout(r)}))}}},{key:"onreconnect",value:function(){var t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),i(u(v.prototype),"emit",this).call(this,"reconnect",t)}}])&&o(e.prototype,n),a&&o(e,a),v}(l);e.Manager=v},function(t,e,n){var r=n(9),o=n(22),i=n(26),s=n(27);e.polling=function(t){var e=!1,n=!1,s=!1!==t.jsonp;if("undefined"!=typeof location){var c="https:"===location.protocol,a=location.port;a||(a=c?443:80),e=t.hostname!==location.hostname||a!==t.port,n=t.secure!==c}if(t.xdomain=e,t.xscheme=n,"open"in new r(t)&&!t.forceJSONP)return new o(t);if(!s)throw new Error("JSONP disabled");return new i(t)},e.websocket=s},function(t,e,n){var r=n(21),o=n(2);t.exports=function(t){var e=t.xdomain,n=t.xscheme,i=t.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!e||r))return new XMLHttpRequest}catch(t){}try{if("undefined"!=typeof XDomainRequest&&!n&&i)return new XDomainRequest}catch(t){}if(!e)try{return new(o[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}},function(t,e,n){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n0);return e}function u(){var t=a(+new Date);return t!==r?(s=0,r=t):t+"."+a(s++)}for(;c<64;c++)i[o[c]]=c;u.encode=a,u.decode=function(t){var e=0;for(c=0;c1?e-1:0),r=1;r=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,c=!0,a=!1;return{s:function(){n=t[Symbol.iterator]()},n:function(){var t=n.next();return c=t.done,t},e:function(t){a=!0,s=t},f:function(){try{c||null==n.return||n.return()}finally{if(a)throw s}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n1?e-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,o=t;n=n||"undefined"!=typeof location&&location,null==t&&(t=n.protocol+"//"+n.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?n.protocol+t:n.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==n?n.protocol+"//"+t:"https://"+t),o=r(t)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";var i=-1!==o.host.indexOf(":"),s=i?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+s+":"+o.port+e,o.href=o.protocol+"://"+s+(n&&n.port===o.port?"":":"+o.port),o}},function(t,e,n){var r=n(20);t.exports=function(t,e){return new r(t,e)},t.exports.Socket=r,t.exports.protocol=r.protocol,t.exports.Transport=n(3),t.exports.transports=n(8),t.exports.parser=n(1)},function(t,e,n){function r(){return(r=Object.assign||function(t){for(var e=1;e1&&void 0!==arguments[1]?arguments[1]:{};return i(this,l),e=f.call(this),t&&"object"===o(t)&&(n=t,t=null),t?(t=y(t),n.hostname=t.host,n.secure="https"===t.protocol||"wss"===t.protocol,n.port=t.port,t.query&&(n.query=t.query)):n.host&&(n.hostname=y(n.host).host),e.secure=null!=n.secure?n.secure:"undefined"!=typeof location&&"https:"===location.protocol,n.hostname&&!n.port&&(n.port=e.secure?"443":"80"),e.hostname=n.hostname||("undefined"!=typeof location?location.hostname:"localhost"),e.port=n.port||("undefined"!=typeof location&&location.port?location.port:e.secure?443:80),e.transports=n.transports||["polling","websocket"],e.readyState="",e.writeBuffer=[],e.prevBufferLen=0,e.opts=r({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,jsonp:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{}},n),e.opts.path=e.opts.path.replace(/\/$/,"")+"/","string"==typeof e.opts.query&&(e.opts.query=d.decode(e.opts.query)),e.id=null,e.upgrades=null,e.pingInterval=null,e.pingTimeout=null,e.pingTimeoutTimer=null,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){e.transport&&(e.transport.removeAllListeners(),e.transport.close())}),!1),e.open(),e}return e=l,(n=[{key:"createTransport",value:function(t){var e=function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}(this.opts.query);e.EIO=h.protocol,e.transport=t,this.id&&(e.sid=this.id);var n=r({},this.opts.transportOptions[t],this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new p[t](n)}},{key:"open",value:function(){var t;if(this.opts.rememberUpgrade&&l.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length){var e=this;return void setTimeout((function(){e.emit("error","No transports available")}),0)}t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}},{key:"setTransport",value:function(t){var e=this;this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",(function(){e.onDrain()})).on("packet",(function(t){e.onPacket(t)})).on("error",(function(t){e.onError(t)})).on("close",(function(){e.onClose("transport close")}))}},{key:"probe",value:function(t){var e=this.createTransport(t,{probe:1}),n=!1,r=this;function o(){if(r.onlyBinaryUpgrades){var t=!this.supportsBinary&&r.transport.supportsBinary;n=n||t}n||(e.send([{type:"ping",data:"probe"}]),e.once("packet",(function(t){if(!n)if("pong"===t.type&&"probe"===t.data){if(r.upgrading=!0,r.emit("upgrading",e),!e)return;l.priorWebsocketSuccess="websocket"===e.name,r.transport.pause((function(){n||"closed"!==r.readyState&&(f(),r.setTransport(e),e.send([{type:"upgrade"}]),r.emit("upgrade",e),e=null,r.upgrading=!1,r.flush())}))}else{var o=new Error("probe error");o.transport=e.name,r.emit("upgradeError",o)}})))}function i(){n||(n=!0,f(),e.close(),e=null)}function s(t){var n=new Error("probe error: "+t);n.transport=e.name,i(),r.emit("upgradeError",n)}function c(){s("transport closed")}function a(){s("socket closed")}function u(t){e&&t.name!==e.name&&i()}function f(){e.removeListener("open",o),e.removeListener("error",s),e.removeListener("close",c),r.removeListener("close",a),r.removeListener("upgrading",u)}l.priorWebsocketSuccess=!1,e.once("open",o),e.once("error",s),e.once("close",c),this.once("close",a),this.once("upgrading",u),e.open()}},{key:"onOpen",value:function(){if(this.readyState="open",l.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade&&this.transport.pause)for(var t=0,e=this.upgrades.length;t0&&void 0!==arguments[0]?arguments[0]:{};return o(t,{xd:this.xd,xs:this.xs},this.opts),new w(this.uri(),t)}},{key:"doWrite",value:function(t,e){var n=this.request({method:"POST",data:t}),r=this;n.on("success",e),n.on("error",(function(t){r.onError("xhr post error",t)}))}},{key:"doPoll",value:function(){var t=this.request(),e=this;t.on("data",(function(t){e.onData(t)})),t.on("error",(function(t){e.onError("xhr poll error",t)})),this.pollXhr=t}}]),n}(y),w=function(t){a(n,t);var e=f(n);function n(t,r){var o;return i(this,n),(o=e.call(this)).opts=r,o.method=r.method||"GET",o.uri=t,o.async=!1!==r.async,o.data=void 0!==r.data?r.data:null,o.create(),o}return c(n,[{key:"create",value:function(){var t=v(this.opts,"agent","enablesXDR","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized");t.xdomain=!!this.opts.xd,t.xscheme=!!this.opts.xs;var e=this.xhr=new h(t),r=this;try{e.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders)for(var o in e.setDisableHeaderCheck&&e.setDisableHeaderCheck(!0),this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(o)&&e.setRequestHeader(o,this.opts.extraHeaders[o])}catch(t){}if("POST"===this.method)try{e.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{e.setRequestHeader("Accept","*/*")}catch(t){}"withCredentials"in e&&(e.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(e.timeout=this.opts.requestTimeout),this.hasXDR()?(e.onload=function(){r.onLoad()},e.onerror=function(){r.onError(e.responseText)}):e.onreadystatechange=function(){4===e.readyState&&(200===e.status||1223===e.status?r.onLoad():setTimeout((function(){r.onError("number"==typeof e.status?e.status:0)}),0))},e.send(this.data)}catch(t){return void setTimeout((function(){r.onError(t)}),0)}"undefined"!=typeof document&&(this.index=n.requestsCount++,n.requests[this.index]=this)}},{key:"onSuccess",value:function(){this.emit("success"),this.cleanup()}},{key:"onData",value:function(t){this.emit("data",t),this.onSuccess()}},{key:"onError",value:function(t){this.emit("error",t),this.cleanup(!0)}},{key:"cleanup",value:function(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=m:this.xhr.onreadystatechange=m,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete n.requests[this.index],this.xhr=null}}},{key:"onLoad",value:function(){var t=this.xhr.responseText;null!==t&&this.onData(t)}},{key:"hasXDR",value:function(){return"undefined"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR}},{key:"abort",value:function(){this.cleanup()}}]),n}(d);if(w.requestsCount=0,w.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",_);else if("function"==typeof addEventListener){addEventListener("onpagehide"in b?"pagehide":"unload",_,!1)}function _(){for(var t in w.requests)w.requests.hasOwnProperty(t)&&w.requests[t].abort()}t.exports=k,t.exports.Request=w},function(t,e,n){var r=n(11).PACKET_TYPES,o="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),i="function"==typeof ArrayBuffer,s=function(t,e){var n=new FileReader;return n.onload=function(){var t=n.result.split(",")[1];e("b"+t)},n.readAsDataURL(t)};t.exports=function(t,e,n){var c,a=t.type,u=t.data;return o&&u instanceof Blob?e?n(u):s(u,n):i&&(u instanceof ArrayBuffer||(c=u,"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(c):c&&c.buffer instanceof ArrayBuffer))?e?n(u instanceof ArrayBuffer?u:u.buffer):s(new Blob([u]),n):n(r[a]+(u||""))}},function(t,e,n){var r,o=n(11),i=o.PACKET_TYPES_REVERSE,s=o.ERROR_PACKET;"function"==typeof ArrayBuffer&&(r=n(25));var c=function(t,e){if(r){var n=r.decode(t);return a(n,e)}return{base64:!0,data:t}},a=function(t,e){switch(e){case"blob":return t instanceof ArrayBuffer?new Blob([t]):t;case"arraybuffer":default:return t}};t.exports=function(t,e){if("string"!=typeof t)return{type:"message",data:a(t,e)};var n=t.charAt(0);return"b"===n?{type:"message",data:c(t.substring(1),e)}:i[n]?t.length>1?{type:i[n],data:t.substring(1)}:{type:i[n]}:s}},function(t,e){!function(t){"use strict";e.encode=function(e){var n,r=new Uint8Array(e),o=r.length,i="";for(n=0;n>2],i+=t[(3&r[n])<<4|r[n+1]>>4],i+=t[(15&r[n+1])<<2|r[n+2]>>6],i+=t[63&r[n+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i},e.decode=function(e){var n,r,o,i,s,c=.75*e.length,a=e.length,u=0;"="===e[e.length-1]&&(c--,"="===e[e.length-2]&&c--);var f=new ArrayBuffer(c),p=new Uint8Array(f);for(n=0;n>4,p[u++]=(15&o)<<4|i>>2,p[u++]=(3&i)<<6|63&s;return f}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},function(t,e,n){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var n=0;n';n=document.createElement(t)}catch(t){(n=document.createElement("iframe")).name=r.iframeId,n.src="javascript:0"}n.id=r.iframeId,r.form.appendChild(n),r.iframe=n}this.form.action=this.uri(),a(),t=t.replace(d,"\\\n"),this.area.value=t.replace(y,"\\n");try{this.form.submit()}catch(t){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===r.iframe.readyState&&c()}:this.iframe.onload=c}},{key:"supportsBinary",get:function(){return!1}}])&&o(e.prototype,n),r&&o(e,r),l}(l);t.exports=v},function(t,e,n){function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){for(var n=0;n0&&t.jitter<=1?t.jitter:0,this.attempts=0}t.exports=n,n.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-n:t+n}return 0|Math.min(t,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(t){this.ms=t},n.prototype.setMax=function(t){this.max=t},n.prototype.setJitter=function(t){this.jitter=t}}])}));
-//# sourceMappingURL=socket.io.min.js.map
\ No newline at end of file
diff --git a/www/socket.io.min.js b/www/socket.io.min.js
new file mode 100644
index 0000000..6a23ad6
--- /dev/null
+++ b/www/socket.io.min.js
@@ -0,0 +1,7 @@
+/*!
+ * Socket.IO v4.5.0
+ * (c) 2014-2022 Guillermo Rauch
+ * Released under the MIT License.
+ */
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).io=e()}(this,(function(){"use strict";function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw o}}}}var g=Object.create(null);g.open="0",g.close="1",g.ping="2",g.pong="3",g.message="4",g.upgrade="5",g.noop="6";var m=Object.create(null);Object.keys(g).forEach((function(t){m[g[t]]=t}));for(var k={type:"error",data:"parser error"},b="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),w="function"==typeof ArrayBuffer,_=function(t,e,n){var r,i=t.type,o=t.data;return b&&o instanceof Blob?e?n(o):A(o,n):w&&(o instanceof ArrayBuffer||(r=o,"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer))?e?n(o):A(new Blob([o]),n):n(g[i]+(o||""))},A=function(t,e){var n=new FileReader;return n.onload=function(){var t=n.result.split(",")[1];e("b"+t)},n.readAsDataURL(t)},E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",O="undefined"==typeof Uint8Array?[]:new Uint8Array(256),R=0;R1?{type:m[n],data:t.substring(1)}:{type:m[n]}:k},B=function(t,e){if(T){var n=function(t){var e,n,r,i,o,s=.75*t.length,a=t.length,c=0;"="===t[t.length-1]&&(s--,"="===t[t.length-2]&&s--);var u=new ArrayBuffer(s),h=new Uint8Array(u);for(e=0;e>4,h[c++]=(15&r)<<4|i>>2,h[c++]=(3&i)<<6|63&o;return u}(t);return S(n,e)}return{base64:!0,data:t}},S=function(t,e){return"blob"===e&&t instanceof ArrayBuffer?new Blob([t]):t},N=String.fromCharCode(30);function x(t){if(t)return function(t){for(var e in x.prototype)t[e]=x.prototype[e];return t}(t)}x.prototype.on=x.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},x.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},x.prototype.off=x.prototype.removeListener=x.prototype.removeAllListeners=x.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;i1?e-1:0),r=1;r0);return e}function z(){var t=Y(+new Date);return t!==D?(H=0,D=t):t+"."+Y(H++)}for(;K<64;K++)V[U[K]]=K;function W(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e}function $(t){for(var e={},n=t.split("&"),r=0,i=n.length;r0&&void 0!==arguments[0]?arguments[0]:{};return i(t,{xd:this.xd,xs:this.xs},this.opts),new et(this.uri(),t)}},{key:"doWrite",value:function(t,e){var n=this,r=this.request({method:"POST",data:t});r.on("success",e),r.on("error",(function(t,e){n.onError("xhr post error",t,e)}))}},{key:"doPoll",value:function(){var t=this,e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(function(e,n){t.onError("xhr poll error",e,n)})),this.pollXhr=e}}]),s}(M),et=function(t){o(i,t);var n=p(i);function i(t,r){var o;return e(this,i),I(f(o=n.call(this)),r),o.opts=r,o.method=r.method||"GET",o.uri=t,o.async=!1!==r.async,o.data=void 0!==r.data?r.data:null,o.create(),o}return r(i,[{key:"create",value:function(){var t=this,e=P(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;var n=this.xhr=new G(e);try{n.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders)for(var r in n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0),this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(r)&&n.setRequestHeader(r,this.opts.extraHeaders[r])}catch(t){}if("POST"===this.method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{n.setRequestHeader("Accept","*/*")}catch(t){}"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=function(){4===n.readyState&&(200===n.status||1223===n.status?t.onLoad():t.setTimeoutFn((function(){t.onError("number"==typeof n.status?n.status:0)}),0))},n.send(this.data)}catch(e){return void this.setTimeoutFn((function(){t.onError(e)}),0)}"undefined"!=typeof document&&(this.index=i.requestsCount++,i.requests[this.index]=this)}},{key:"onError",value:function(t){this.emitReserved("error",t,this.xhr),this.cleanup(!0)}},{key:"cleanup",value:function(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=Q,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete i.requests[this.index],this.xhr=null}}},{key:"onLoad",value:function(){var t=this.xhr.responseText;null!==t&&(this.emitReserved("data",t),this.emitReserved("success"),this.cleanup())}},{key:"abort",value:function(){this.cleanup()}}]),i}(x);if(et.requestsCount=0,et.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",nt);else if("function"==typeof addEventListener){addEventListener("onpagehide"in L?"pagehide":"unload",nt,!1)}function nt(){for(var t in et.requests)et.requests.hasOwnProperty(t)&&et.requests[t].abort()}var rt="function"==typeof Promise&&"function"==typeof Promise.resolve?function(t){return Promise.resolve().then(t)}:function(t,e){return e(t,0)},it=L.WebSocket||L.MozWebSocket,ot="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),st=function(t){o(i,t);var n=p(i);function i(t){var r;return e(this,i),(r=n.call(this,t)).supportsBinary=!t.forceBase64,r}return r(i,[{key:"name",get:function(){return"websocket"}},{key:"doOpen",value:function(){if(this.check()){var t=this.uri(),e=this.opts.protocols,n=ot?{}:P(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=ot?new it(t,e,n):e?new it(t,e):new it(t)}catch(t){return this.emitReserved("error",t)}this.ws.binaryType=this.socket.binaryType||"arraybuffer",this.addEventListeners()}}},{key:"addEventListeners",value:function(){var t=this;this.ws.onopen=function(){t.opts.autoUnref&&t.ws._socket.unref(),t.onOpen()},this.ws.onclose=function(e){return t.onClose({description:"websocket connection closed",context:e})},this.ws.onmessage=function(e){return t.onData(e.data)},this.ws.onerror=function(e){return t.onError("websocket error",e)}}},{key:"write",value:function(t){var e=this;this.writable=!1;for(var n=function(n){var r=t[n],i=n===t.length-1;_(r,e.supportsBinary,(function(t){try{e.ws.send(t)}catch(t){}i&&rt((function(){e.writable=!0,e.emitReserved("drain")}),e.setTimeoutFn)}))},r=0;r1&&void 0!==arguments[1]?arguments[1]:{};return e(this,a),r=s.call(this),n&&"object"===t(n)&&(o=n,n=null),n?(n=ht(n),o.hostname=n.host,o.secure="https"===n.protocol||"wss"===n.protocol,o.port=n.port,n.query&&(o.query=n.query)):o.host&&(o.hostname=ht(o.host).host),I(f(r),o),r.secure=null!=o.secure?o.secure:"undefined"!=typeof location&&"https:"===location.protocol,o.hostname&&!o.port&&(o.port=r.secure?"443":"80"),r.hostname=o.hostname||("undefined"!=typeof location?location.hostname:"localhost"),r.port=o.port||("undefined"!=typeof location&&location.port?location.port:r.secure?"443":"80"),r.transports=o.transports||["polling","websocket"],r.readyState="",r.writeBuffer=[],r.prevBufferLen=0,r.opts=i({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},o),r.opts.path=r.opts.path.replace(/\/$/,"")+"/","string"==typeof r.opts.query&&(r.opts.query=$(r.opts.query)),r.id=null,r.upgrades=null,r.pingInterval=null,r.pingTimeout=null,r.pingTimeoutTimer=null,"function"==typeof addEventListener&&(r.opts.closeOnBeforeunload&&addEventListener("beforeunload",(function(){r.transport&&(r.transport.removeAllListeners(),r.transport.close())}),!1),"localhost"!==r.hostname&&(r.offlineEventListener=function(){r.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",r.offlineEventListener,!1))),r.open(),r}return r(a,[{key:"createTransport",value:function(t){var e=i({},this.opts.query);e.EIO=4,e.transport=t,this.id&&(e.sid=this.id);var n=i({},this.opts.transportOptions[t],this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return new at[t](n)}},{key:"open",value:function(){var t,e=this;if(this.opts.rememberUpgrade&&a.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((function(){e.emitReserved("error","No transports available")}),0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}},{key:"setTransport",value:function(t){var e=this;this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(function(t){return e.onClose("transport close",t)}))}},{key:"probe",value:function(t){var e=this,n=this.createTransport(t),r=!1;a.priorWebsocketSuccess=!1;var i=function(){r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",(function(t){if(!r)if("pong"===t.type&&"probe"===t.data){if(e.upgrading=!0,e.emitReserved("upgrading",n),!n)return;a.priorWebsocketSuccess="websocket"===n.name,e.transport.pause((function(){r||"closed"!==e.readyState&&(f(),e.setTransport(n),n.send([{type:"upgrade"}]),e.emitReserved("upgrade",n),n=null,e.upgrading=!1,e.flush())}))}else{var i=new Error("probe error");i.transport=n.name,e.emitReserved("upgradeError",i)}})))};function o(){r||(r=!0,f(),n.close(),n=null)}var s=function(t){var r=new Error("probe error: "+t);r.transport=n.name,o(),e.emitReserved("upgradeError",r)};function c(){s("transport closed")}function u(){s("socket closed")}function h(t){n&&t.name!==n.name&&o()}var f=function(){n.removeListener("open",i),n.removeListener("error",s),n.removeListener("close",c),e.off("close",u),e.off("upgrading",h)};n.once("open",i),n.once("error",s),n.once("close",c),this.once("close",u),this.once("upgrading",h),n.open()}},{key:"onOpen",value:function(){if(this.readyState="open",a.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade&&this.transport.pause)for(var t=0,e=this.upgrades.length;t1))return this.writeBuffer;for(var t,e=1,n=0;n=57344?n+=3:(r++,n+=4);return n}(t):Math.ceil(1.33*(t.byteLength||t.size))),n>0&&e>this.maxPayload)return this.writeBuffer.slice(0,n);e+=2}return this.writeBuffer}},{key:"write",value:function(t,e,n){return this.sendPacket("message",t,e,n),this}},{key:"send",value:function(t,e,n){return this.sendPacket("message",t,e,n),this}},{key:"sendPacket",value:function(t,e,n,r){if("function"==typeof e&&(r=e,e=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var i={type:t,data:e,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}}},{key:"close",value:function(){var t=this,e=function(){t.onClose("forced close"),t.transport.close()},n=function n(){t.off("upgrade",n),t.off("upgradeError",n),e()},r=function(){t.once("upgrade",n),t.once("upgradeError",n)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(function(){t.upgrading?r():e()})):this.upgrading?r():e()),this}},{key:"onError",value:function(t){a.priorWebsocketSuccess=!1,this.emitReserved("error",t),this.onClose("transport error",t)}},{key:"onClose",value:function(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&removeEventListener("offline",this.offlineEventListener,!1),this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}},{key:"filterUpgrades",value:function(t){for(var e=[],n=0,r=t.length;n0;case _t.ACK:case _t.BINARY_ACK:return Array.isArray(n)}}}]),a}(x),Ot=function(){function t(n){e(this,t),this.packet=n,this.buffers=[],this.reconPack=n}return r(t,[{key:"takeBinaryData",value:function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){var e=bt(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}},{key:"finishedReconstruction",value:function(){this.reconPack=null,this.buffers=[]}}]),t}(),Rt=Object.freeze({__proto__:null,protocol:5,get PacketType(){return _t},Encoder:At,Decoder:Et});function Tt(t,e,n){return t.on(e,n),function(){t.off(e,n)}}var Ct=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Bt=function(t){o(i,t);var n=p(i);function i(t,r,o){var s;return e(this,i),(s=n.call(this)).connected=!1,s.receiveBuffer=[],s.sendBuffer=[],s.ids=0,s.acks={},s.flags={},s.io=t,s.nsp=r,o&&o.auth&&(s.auth=o.auth),s.io._autoConnect&&s.open(),s}return r(i,[{key:"disconnected",get:function(){return!this.connected}},{key:"subEvents",value:function(){if(!this.subs){var t=this.io;this.subs=[Tt(t,"open",this.onopen.bind(this)),Tt(t,"packet",this.onpacket.bind(this)),Tt(t,"error",this.onerror.bind(this)),Tt(t,"close",this.onclose.bind(this))]}}},{key:"active",get:function(){return!!this.subs}},{key:"connect",value:function(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}},{key:"open",value:function(){return this.connect()}},{key:"send",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n1?e-1:0),r=1;r0&&t.jitter<=1?t.jitter:0,this.attempts=0}St.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-n:t+n}return 0|Math.min(t,this.max)},St.prototype.reset=function(){this.attempts=0},St.prototype.setMin=function(t){this.ms=t},St.prototype.setMax=function(t){this.max=t},St.prototype.setJitter=function(t){this.jitter=t};var Nt=function(n){o(s,n);var i=p(s);function s(n,r){var o,a;e(this,s),(o=i.call(this)).nsps={},o.subs=[],n&&"object"===t(n)&&(r=n,n=void 0),(r=r||{}).path=r.path||"/socket.io",o.opts=r,I(f(o),r),o.reconnection(!1!==r.reconnection),o.reconnectionAttempts(r.reconnectionAttempts||1/0),o.reconnectionDelay(r.reconnectionDelay||1e3),o.reconnectionDelayMax(r.reconnectionDelayMax||5e3),o.randomizationFactor(null!==(a=r.randomizationFactor)&&void 0!==a?a:.5),o.backoff=new St({min:o.reconnectionDelay(),max:o.reconnectionDelayMax(),jitter:o.randomizationFactor()}),o.timeout(null==r.timeout?2e4:r.timeout),o._readyState="closed",o.uri=n;var c=r.parser||Rt;return o.encoder=new c.Encoder,o.decoder=new c.Decoder,o._autoConnect=!1!==r.autoConnect,o._autoConnect&&o.open(),o}return r(s,[{key:"reconnection",value:function(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}},{key:"reconnectionAttempts",value:function(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}},{key:"reconnectionDelay",value:function(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}},{key:"randomizationFactor",value:function(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}},{key:"reconnectionDelayMax",value:function(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}},{key:"timeout",value:function(t){return arguments.length?(this._timeout=t,this):this._timeout}},{key:"maybeReconnectOnOpen",value:function(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}},{key:"open",value:function(t){var e=this;if(~this._readyState.indexOf("open"))return this;this.engine=new ft(this.uri,this.opts);var n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;var i=Tt(n,"open",(function(){r.onopen(),t&&t()})),o=Tt(n,"error",(function(n){r.cleanup(),r._readyState="closed",e.emitReserved("error",n),t?t(n):r.maybeReconnectOnOpen()}));if(!1!==this._timeout){var s=this._timeout;0===s&&i();var a=this.setTimeoutFn((function(){i(),n.close(),n.emit("error",new Error("timeout"))}),s);this.opts.autoUnref&&a.unref(),this.subs.push((function(){clearTimeout(a)}))}return this.subs.push(i),this.subs.push(o),this}},{key:"connect",value:function(t){return this.open(t)}},{key:"onopen",value:function(){this.cleanup(),this._readyState="open",this.emitReserved("open");var t=this.engine;this.subs.push(Tt(t,"ping",this.onping.bind(this)),Tt(t,"data",this.ondata.bind(this)),Tt(t,"error",this.onerror.bind(this)),Tt(t,"close",this.onclose.bind(this)),Tt(this.decoder,"decoded",this.ondecoded.bind(this)))}},{key:"onping",value:function(){this.emitReserved("ping")}},{key:"ondata",value:function(t){this.decoder.add(t)}},{key:"ondecoded",value:function(t){this.emitReserved("packet",t)}},{key:"onerror",value:function(t){this.emitReserved("error",t)}},{key:"socket",value:function(t,e){var n=this.nsps[t];return n||(n=new Bt(this,t,e),this.nsps[t]=n),n}},{key:"_destroy",value:function(t){for(var e=0,n=Object.keys(this.nsps);e=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{var n=this.backoff.duration();this._reconnecting=!0;var r=this.setTimeoutFn((function(){e.skipReconnect||(t.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((function(n){n?(e._reconnecting=!1,e.reconnect(),t.emitReserved("reconnect_error",n)):e.onreconnect()})))}),n);this.opts.autoUnref&&r.unref(),this.subs.push((function(){clearTimeout(r)}))}}},{key:"onreconnect",value:function(){var t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}]),s}(x),xt={};function Lt(e,n){"object"===t(e)&&(n=e,e=void 0);var r,i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0,r=t;n=n||"undefined"!=typeof location&&location,null==t&&(t=n.protocol+"//"+n.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?n.protocol+t:n.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==n?n.protocol+"//"+t:"https://"+t),r=ht(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var i=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+e,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}(e,(n=n||{}).path||"/socket.io"),o=i.source,s=i.id,a=i.path,c=xt[s]&&a in xt[s].nsps;return n.forceNew||n["force new connection"]||!1===n.multiplex||c?r=new Nt(o,n):(xt[s]||(xt[s]=new Nt(o,n)),r=xt[s]),i.query&&!n.query&&(n.query=i.queryKey),r.socket(i.path,n)}return i(Lt,{Manager:Nt,Socket:Bt,io:Lt,connect:Lt}),Lt}));
+//# sourceMappingURL=socket.io.min.js.map
diff --git a/www/style.css b/www/style.css
index 0f6fdb3..6d27393 100644
--- a/www/style.css
+++ b/www/style.css
@@ -13,6 +13,12 @@ canvas {
border-width: 3px;
}
+@font-face {
+ font-family: "serif";
+ src: url("pixserif.woff2") format('woff2');
+}
+
+
.left{
display: block;
transform: translate(0, 50px);