From 5f5f759f69b51fb27c5271f5c1c0a80ceab8a2dc Mon Sep 17 00:00:00 2001 From: Alexander Bass Date: Tue, 21 Jun 2022 21:51:09 -0400 Subject: [PATCH] DAJKDJAKDBHAKJdbk_Server --- Pixerif.ttf | Bin 0 -> 39092 bytes index.js | 175 ---------------------------- index.mjs | 10 ++ package-lock.json | 120 +++++++++---------- package.json | 2 +- pixerif.woff2 | Bin 0 -> 6312 bytes scripts/env.mjs | 1 + scripts/game.mjs | 54 +++++++++ log.js => scripts/log.mjs | 17 +-- scripts/player.mjs | 7 ++ scripts/roomManager.mjs | 64 ++++++++++ scripts/server/illegalAction.mjs | 11 ++ scripts/server/io.mjs | 4 + scripts/server/netcode.mjs | 55 +++++++++ scripts/server/server.mjs | 10 ++ scripts/util.mjs | 6 + scripts/world/flagger.mjs | 22 ++++ scripts/world/generator.mjs | 42 +++++++ scripts/world/marker.mjs | 32 +++++ scripts/world/obfuscator.mjs | 16 +++ scripts/world/placer.mjs | 14 +++ scripts/world/revealer.mjs | 43 +++++++ scripts/world/world.mjs | 55 +++++++++ util.js | 7 -- worldgen.js | 77 ------------ www/index.html | 2 +- www/mine.png | Bin 65859 -> 65896 bytes www/scripts/display/draw.js | 24 ++-- www/scripts/interface/game/mouse.js | 3 +- www/scripts/net/netcode.js | 2 +- www/socket.io.js | 7 -- www/socket.io.min.js | 7 ++ www/style.css | 6 + 33 files changed, 537 insertions(+), 358 deletions(-) create mode 100644 Pixerif.ttf delete mode 100644 index.js create mode 100644 index.mjs create mode 100644 pixerif.woff2 create mode 100644 scripts/env.mjs create mode 100644 scripts/game.mjs rename log.js => scripts/log.mjs (86%) create mode 100644 scripts/player.mjs create mode 100644 scripts/roomManager.mjs create mode 100644 scripts/server/illegalAction.mjs create mode 100644 scripts/server/io.mjs create mode 100644 scripts/server/netcode.mjs create mode 100644 scripts/server/server.mjs create mode 100644 scripts/util.mjs create mode 100644 scripts/world/flagger.mjs create mode 100644 scripts/world/generator.mjs create mode 100644 scripts/world/marker.mjs create mode 100644 scripts/world/obfuscator.mjs create mode 100644 scripts/world/placer.mjs create mode 100644 scripts/world/revealer.mjs create mode 100644 scripts/world/world.mjs delete mode 100644 util.js delete mode 100644 worldgen.js delete mode 100644 www/socket.io.js create mode 100644 www/socket.io.min.js diff --git a/Pixerif.ttf b/Pixerif.ttf new file mode 100644 index 0000000000000000000000000000000000000000..5ced489ba6ffab06119c4c41fdc0ea187642f855 GIT binary patch literal 39092 zcmd^odzf8Ub>BMY-kGs9dW}cd@S+b?Ek8H~i@C&~&#&|4`B^hZX zWXTvq$uYk9$WF5m_cq8gkE-SKe~ntKay>J48P8A+)Z( z>WbZ0%5pgq*AL_R%o}drwB_wLyzWtvWFM|?+jDT{@Kry({ZB;tzbca6zvrQ&Yh-Qu zn8>1yxZm76^Wfp*#{pSBbQsqs?LF{@``>Up*(5UfMUl6 zBHwI&e0w|}_s6r;gJjSvDNiVPry<8PxvMG1JurKPq_^yl>|zU!_sbG(;hTv*mC5S<;lypyqAKhExnJMQy$@EoOFzR&loKE%Oyfg_6_#fA43 zFV6a2JUhGAdxCn_K_A6uVhn7GIHz_p$ghQqVCCLBF`r9?zX=Vv}2?swv7gURPQJ_<8K zd*?^cR{l7{(e)hPLWKF?<&ocMgjS?Ta4nerWe zr1vM%Z_lc46}-FfZuv}@8Og?dten9RF9x{rBJhXIX%N+gke5#XJKT;gw4fqe*P9VsAD;OP}=10BBhxi)9d0 zEk)nETvo`CoGin#Qd)9~tddjZG&x<)0QDp2ea`}&qlofjvQEb3Y*{bo$hopXCS;?W zhu&qAOv+~2B2#jKY?TXTn{1bhURE?3BIxl*o@tK}MbnY>)C zmFwhsxj}A}SIA9rv)m%L%58GH+##=&JLOf7;;ZFud5zp7Ghpwn@;3SV@(y{Qd{90L z$$df|mruzj8ci$Yc~X8)z97FZPstbMY58aJW%=jwhw?{&a9H-p zeZt(~A^Et>$pfezmHjxrU6^sa4j(}udQ8uDc&$8w%BST^@@sOh9L(<=kT+`G$*;?A zCnq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A1vxiZYcp+aX zw!8R|yxQD-?8qTH@f5l!>w1#o$I;g$p&wd?{=_mT_EKz(cl7+HFMj^N@X4<~Jh6-C KZ#F-^?f(FD)_O|- literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..800b6781c3f85d2d75c5417d7a3bf6612b3f3c99 GIT binary patch literal 6312 zcmV;Z7+2?aPew8T0RR9102rtM4gdfE0GPA@02oRD0RR9100000000000000000000 z0000#Mn+Uk92y=5Rse)%2m}!b3WA9Mf$|OkHUcCAiUbRV1ONme1%ogLjR_mZi6!Hh zrNG7k7~DT_6eX0k-zWq&4ge(mXA@QRm>}a2^TCCx+60M-W(uikqoO#3s1tz@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|E>yK2`5+FCRJL5g!U=>Uj)SigECjz>F8U!qV{l7_QZcr?p-*qf3Uz*Odmu*1?2i;BR&?o84bUX4F;0scEzKO; zIQB0Y;^iLvUoDVAG8A`R^%1ZqOE;%KDtfB^b(`xQw!BOw4X|`rYn&CgT9&ysz-F4; zdfH>@-r}4EyP)Nmd!0D*YV4M49ky#9mTMk$(Y=dGT|Cgn;tn$IXjFIp)p2m#{`@QN e4qZ 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 c53832621c3115bb6321c6448b04876ac6300933..43c2de4969ced50393e5c9a290f80790358238a5 100644 GIT binary patch delta 705 zcmb`EPe>F|9LHzearcD-j?B)wD?2(HOIZ0AT-lSnWZi91mtM%%j=`aQ!I>oqm zq4A68$@M09C~PcL2%dEEB6be3Lx>$aByig;r!UXs+(`cuA(?f zxo~F|TVtj0oxj(kJ^dU{gfB%G4}GCKD{Ja%{P1RKVdq=_p#0|YM5XY0+^zoxGFSSp delta 180 zcmaFS#B#WaWrB(jXMsm#F#`kNVGw3Kp1&exV{}TwW`)pRMj8{78+eXPo_`=@^X-Nm q@+>*`PpfTS|A0?n^U?$B9YidnUI#zlar-I*5O})!xvX0;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);