Move Server and client into seperate folders

This commit is contained in:
Alexander Bass 2022-06-24 12:29:05 -04:00
parent 62c6a63428
commit cc0312b357
97 changed files with 38 additions and 705 deletions

View file

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 64 KiB

View file

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

1
dist/env.js vendored
View file

@ -1 +1,2 @@
export const port = 8082; export const port = 8082;
//# sourceMappingURL=env.js.map

1
dist/env.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"env.js","sourceRoot":"","sources":["../server/src/env.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC"}

1
dist/game.js vendored
View file

@ -34,3 +34,4 @@ export class Game {
return names; return names;
} }
} }
//# sourceMappingURL=game.js.map

1
dist/game.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"game.js","sourceRoot":"","sources":["../server/src/game.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAA;AAClC,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAC,MAAM,kBAAkB,CAAA;AAEvC,MAAM,OAAO,IAAI;IAIf,YAAY,EAAS,EAAE,OAAW;QAChC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAA;IACjC,CAAC;IAED,SAAS,CAAC,EAAS,EAAE,IAAW,EAAE,KAAY;QAC5C,sDAAsD;QACtD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,OAAO,MAAM,CAAA;IACf,CAAC;IAED,gBAAgB,CAAC,EAAS;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACrC;IACH,CAAC;IAED,SAAS;QACP,IAAI,GAAG,GAAG,EAAE,CAAA;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC5C,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;SAC7B;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,WAAW;QACT,IAAI,KAAK,GAAG,EAAE,CAAA;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC5C,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;SACjC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF"}

115
dist/log.js vendored
View file

@ -1,115 +0,0 @@
import * as os from "os";
var mode = 0;
var logs = [];
var rightView = [0, 1, 2, 3, 4, 5, 6];
var info = [[], []];
export function setMode(type) {
mode = type;
}
export function updateLog() {
if (mode)
return;
let templogs = logs;
console.clear();
const columns = process.stdout.columns;
const rows = process.stdout.rows;
const vertSplit = Math.round(rows / 4);
for (var i = 0; i < vertSplit; i++) {
process.stdout.cursorTo(Math.round(columns / 2), i);
process.stdout.clearLine();
process.stdout.write(`|`);
}
for (var i = 0; i < columns; i++) {
process.stdout.cursorTo(i + 1, vertSplit);
process.stdout.write(`=`);
}
process.stdout.cursorTo(0, 0);
process.stdout.write("Players:");
const games = info[0];
var pointer = 0;
for (i = 0; i < games.length; i++) {
process.stdout.cursorTo(0, pointer + 1);
process.stdout.write(`\x1b[46mGameName: \x1b[1m${games[i].name}\x1b[0m`);
const players = games[i].players;
for (var j = 0; j < players.length; j++) {
process.stdout.cursorTo(0, pointer + 2);
process.stdout.write(`--Name: \x1b[1m${players[j].name}\x1b[0m -\x1b[1m ID:${players[j].id}\x1b[0m`);
pointer++;
}
pointer++;
}
if (templogs.length > Math.round(3 * rows / 4) - 3) {
templogs.splice(0, logs.length - Math.round(3 * rows / 4) + 2);
}
for (var i = 0; i < templogs.length; i++) {
process.stdout.cursorTo(0, vertSplit + 1 + i);
process.stdout.write(`${templogs[i]}${os.EOL}`);
}
}
export function log(string, color) {
if (mode)
return console.log(string);
if (string == undefined)
return;
var prefix = '';
switch (color) {
case "reset":
prefix = "\x1b[0m";
break;
case "bright":
prefix = "\x1b[1m";
break;
case "dim":
prefix = "\x1b[2m";
break;
case "underscore":
prefix = "\x1b[4m";
break;
case "reverse":
prefix = "\x1b[7m";
break;
case "FgBlack":
prefix = "\x1b[30m";
break;
case "FgRed":
prefix = "\x1b[31m";
break;
case "FgGreen":
prefix = "\x1b[32m";
break;
case "FgYellow":
prefix = "\x1b[33m";
break;
case "FgBlue":
prefix = "\x1b[34m";
break;
case "FgMagenta":
prefix = "\x1b[35m";
break;
case "FgCyan":
prefix = "\x1b[36m";
break;
case "FgWhite":
prefix = "\x1b[37m";
break;
}
// BgBlack = "\x1b[40m"
// BgRed = "\x1b[41m"
// BgGreen = "\x1b[42m"
// BgYellow = "\x1b[43m"
// BgBlue = "\x1b[44m"
// BgMagenta = "\x1b[45m"
// BgCyan = "\x1b[46m"
// BgWhite = "\x1b[47m"
const newString = prefix + string + "\x1b[0m";
logs.push(newString);
updateLog();
}
export function setInfo(players) {
if (mode)
return false;
if (players != undefined) {
info[0] = players;
updateLog();
}
}

1
dist/main.js vendored
View file

@ -4,3 +4,4 @@ setInterval(function () { updateInfo(); }, 5000);
function updateInfo() { function updateInfo() {
console.log("running..."); console.log("running...");
} }
//# sourceMappingURL=main.js.map

1
dist/main.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../server/src/main.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AACzB,OAAO,qBAAqB,CAAA;AAG5B,WAAW,CAAC,cAAY,UAAU,EAAE,CAAA,CAAA,CAAC,EAAC,IAAI,CAAC,CAAA;AAC3C,SAAS,UAAU;IACjB,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AAC3B,CAAC"}

1
dist/player.js vendored
View file

@ -5,3 +5,4 @@ export class Player {
this.color = color; this.color = color;
} }
} }
//# sourceMappingURL=player.js.map

1
dist/player.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"player.js","sourceRoot":"","sources":["../server/src/player.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,MAAM;IAIjB,YAAY,EAAS,EAAE,IAAW,EAAE,KAAY;QAC9C,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}

1
dist/roomManager.js vendored
View file

@ -58,3 +58,4 @@ class RoomManager {
} }
} }
export var roomManager = new RoomManager(); export var roomManager = new RoomManager();
//# sourceMappingURL=roomManager.js.map

1
dist/roomManager.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"roomManager.js","sourceRoot":"","sources":["../server/src/roomManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,MAAM,WAAW;IAEf;QACE,IAAI,CAAC,KAAK,GAAG,EAAE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id).emit('illegalAction', this.action); io.to(this.id).emit('illegalAction', this.action);
} }
} }
//# sourceMappingURL=illegalAction.js.map

1
dist/server/illegalAction.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"illegalAction.js","sourceRoot":"","sources":["../../server/src/server/illegalAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,EAAE,EAAC,MAAM,SAAS,CAAA;AAC1B,MAAM,OAAO,aAAa;IAGxB,YAAY,EAAS,EAAE,MAAa;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IACD,iBAAiB;QACf,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACnD,CAAC;CACF"}

1
dist/server/io.js vendored
View file

@ -1,3 +1,4 @@
import { webServer } from "./server.js"; import { webServer } from "./server.js";
import { Server } from "socket.io"; import { Server } from "socket.io";
export const io = new Server(webServer, {}); export const io = new Server(webServer, {});
//# sourceMappingURL=io.js.map

1
dist/server/io.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"io.js","sourceRoot":"","sources":["../../server/src/server/io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC"}

View file

@ -53,3 +53,4 @@ function connected(client) {
client.sync(); client.sync();
}); });
} }
//# sourceMappingURL=netcode.js.map

1
dist/server/netcode.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"netcode.js","sourceRoot":"","sources":["../../server/src/server/netcode.ts"],"names":[],"mappings":"AAAA,OA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AAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;QAC3B,MAAM,CAAC,IAAI,EAAE,CAAA;QACb,MAAM,CAAC,QAAQ,EAAE,CAAA;IACrB,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,UAAS,IAAQ;QACtC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,UAAS,IAAQ;QACxC,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAAE,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;QAC9F,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QAC5F,MAAM,CAAC,IAAI,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;AACN,CAAC"}

View file

@ -6,3 +6,4 @@ const __dirname = path.resolve(path.dirname(''));
app.use(express.static(__dirname + '/www/')); app.use(express.static(__dirname + '/www/'));
export var webServer = app.listen(port, function () { export var webServer = app.listen(port, function () {
}); });
//# sourceMappingURL=server.js.map

1
dist/server/server.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../server/src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,IAAI,GAAG,GAAG,OAAO,EAAE,CAAA;AAEnB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;AACjD,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC;AAC7C,MAAM,CAAC,IAAI,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE;AACxC,CAAC,CAAC,CAAC"}

1
dist/util.js vendored
View file

@ -9,3 +9,4 @@ export function createCode() {
const randomString = crypto.randomBytes(3).toString("hex").toUpperCase(); const randomString = crypto.randomBytes(3).toString("hex").toUpperCase();
return randomString; return randomString;
} }
//# sourceMappingURL=util.js.map

1
dist/util.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"util.js","sourceRoot":"","sources":["../server/src/util.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,MAAM,UAAU,YAAY,CAAC,GAAU,EAAE,GAAU;IAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;AACzD,CAAC;AACD,MAAM,UAAU,KAAK,CAAC,MAAa,EAAE,GAAU,EAAE,GAAU;IACzD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;IACxE,OAAO,YAAY,CAAA;AACrB,CAAC"}

View file

@ -18,3 +18,4 @@ export function flag(x, y, data, player) {
data[x][y] = tile; data[x][y] = tile;
return data; return data;
} }
//# sourceMappingURL=flagger.js.map

1
dist/world/flagger.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"flagger.js","sourceRoot":"","sources":["../../server/src/world/flagger.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,IAAI,CAAC,CAAQ,EAAE,CAAQ,EAAE,IAAc,EAAE,MAAa;IACpE,IAAI,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAErB,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAC9C,MAAM,KAAK,GAAU,CAAC,MAAM,CAAC,KAAK,CAAA;IAClC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAEnB,QAAQ,IAAI,CAAC,IAAI,EAAE;QACjB,KAAK,CAAC,CAAC,CAAC;YACJ,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;YACpB,MAAM;QACR,KAAK,CAAC,KAAK,CAAC;YACR,IAAI,CAAC,IAAI,GAAG,KAAK,GAAG,EAAE,CAAC;YACzB,MAAM;QACR;YACI,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;KACnB;IACC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACxB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IACjB,OAAO,IAAI,CAAC;AACd,CAAC"}

View file

@ -31,3 +31,4 @@ export function generate(avoidX, avoidY, world) {
world.isGenerated = true; world.isGenerated = true;
return world; return world;
} }
//# sourceMappingURL=generator.js.map

1
dist/world/generator.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../server/src/world/generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,YAAY,CAAA;AAGlC,MAAM,SAAS,GACf;IACE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,E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D,IAAI,QAAQ,EAAE;YACZ,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAA;YACzB,YAAY,EAAE,CAAC;SAChB;KACF;IAED,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;IACzB,OAAO,KAAK,CAAC;AACf,CAAC"}

View file

@ -27,3 +27,4 @@ export function mark(world) {
world.isMarked = true; world.isMarked = true;
return world; return world;
} }
//# sourceMappingURL=marker.js.map

1
dist/world/marker.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"marker.js","sourceRoot":"","sources":["../../server/src/world/marker.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GACf;IACE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,EAAS,CAAC,CAAC,EAAC,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;CACtB,CAAA;AACD,gBAAgB;AAChB,MAAM,UAAU,IAAI,CAAC,KAAW;IAEhC,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,EAAC;QAClC,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC;YACnC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,EAAE;gBACjC,IAAI,OAAO,GAAG,CAAC,CAAC;gBAChB,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;oBAC3B,MAAM,KAAK,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;oBAC7B,MAAM,KAAK,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;oBAC7B,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE;wBAC3E,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,EAAE;4BACvC,OAAO,EAAE,CAAC;yBACX;qBACF;gBACH,CAAC,CAAC,CAAC;gBACH,IAAI,OAAO,KAAK,CAAC,EAAE;oBACnB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,GAAG,OAAO,CAAA;iBACnC;aACA;SACF;KACF;IACC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;IACtB,OAAO,KAAK,CAAC;AAEf,CAAC"}

View file

@ -11,3 +11,4 @@ export function obfuscate(world) {
} }
return tempWorld; return tempWorld;
} }
//# sourceMappingURL=obfuscator.js.map

1
dist/world/obfuscator.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"obfuscator.js","sourceRoot":"","sources":["../../server/src/world/obfuscator.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,SAAS,CAAC,KAAW;IACnC,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,EAAC;QACtC,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAC;YAEvC,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE;gBAEtC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;aAC/B;YAAA,CAAC;YACF,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC;SAE/B;KACF;IACG,OAAO,SAAS,CAAC;AACvB,CAAC"}

View file

@ -10,3 +10,4 @@ export function place(x, y, data) {
} }
return data; return data;
} }
//# sourceMappingURL=placer.js.map

1
dist/world/placer.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"placer.js","sourceRoot":"","sources":["../../server/src/world/placer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAGzC,MAAM,UAAU,KAAK,CAAC,CAAQ,EAAE,CAAQ,EAAE,IAAc;IACtD,IAAI,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtB,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE;QACxB,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,EAAE;YAChC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;SACnB;QAED,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QAClB,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;KAC1B;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}

View file

@ -33,3 +33,4 @@ export function reveal(x, y, data) {
} }
return data; return data;
} }
//# sourceMappingURL=revealer.js.map

1
dist/world/revealer.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"revealer.js","sourceRoot":"","sources":["../../server/src/world/revealer.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GACf;IACE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC;IAC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,CAAC,CAAC,MAAM,EAAE;oBAE7E,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE;wBAErE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAC,KAAK,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAC,KAAK,CAAC,CAAC,EAAE;4BACnF,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,EAAC,KAAK,CAAC,CAAC,CAAA;yBAC7B;qBACF;oBACH,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,EAAE;wBACjC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC;qBACjC;iBACF;YACD,CAAC,CAAC,CAAA;SACL;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}

1
dist/world/world.js vendored
View file

@ -50,3 +50,4 @@ export class World {
return obfuscater.obfuscate(tempWorld); return obfuscater.obfuscate(tempWorld);
} }
} }
//# sourceMappingURL=world.js.map

1
dist/world/world.js.map vendored Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"world.js","sourceRoot":"","sources":["../../server/src/world/world.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAMrC,MAAM,OAAO,KAAK;IAQhB,YAAY,OAAW;QACrB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1B,I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AQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAC3B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;SAC1C;IAED,CAAC;IAED,QAAQ,CAAC,CAAQ,EAAE,CAAQ;QACzB,IAAI,IAAI,CAAC,WAAW;YAAE,OAAO,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAC9D,OAAO,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,IAAI;QACF,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACzD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,SAAS;QACP,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;QACzD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAAA,CAAC;QACpD,OAAO,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IACzC,CAAC;CAEF"}

View file

@ -1 +0,0 @@
export const port = 8082;

View file

@ -1,43 +0,0 @@
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(id, options) {
this.id = id;
this.players = [];
this.oldWorld = []
this.world = new World(options)
}
addPlayer(id, name, color) {
if (this.getAllNames().includes(name)) return false
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.removeGameByID(this.id);
}
}
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
}
}

View file

@ -1,125 +0,0 @@
import * as os from "os"
var mode = 0
var logs = []
var rightView = [0,1,2,3,4,5,6]
var info = [[],[]]
export function setMode(type) {
mode = type
}
export function updateLog() {
if (mode) return
let templogs = logs;
console.clear()
const columns = process.stdout.columns;
const rows = process.stdout.rows;
const vertSplit = Math.round(rows/4)
for (var i = 0; i < vertSplit; i++) {
process.stdout.cursorTo(Math.round(columns/2),i);
process.stdout.clearLine();
process.stdout.write(`|`)
}
for (var i = 0; i < columns; i++) {
process.stdout.cursorTo(i+1, vertSplit)
process.stdout.write(`=`)
}
process.stdout.cursorTo(0,0)
process.stdout.write("Players:")
const games = info[0]
var pointer = 0
for (i = 0; i < games.length; i++) {
process.stdout.cursorTo(0,pointer+1)
process.stdout.write(`\x1b[46mGameName: \x1b[1m${games[i].name}\x1b[0m`)
const players = games[i].players;
for (var j = 0; j < players.length; j++) {
process.stdout.cursorTo(0,pointer+2)
process.stdout.write(`--Name: \x1b[1m${players[j].name}\x1b[0m -\x1b[1m ID:${players[j].id}\x1b[0m`)
pointer++;
}
pointer++;
}
if (templogs.length > Math.round(3*rows/4)-3) {
templogs.splice(0, logs.length-Math.round(3*rows/4)+2);
}
for (var i = 0; i < templogs.length; i++ ) {
process.stdout.cursorTo(0,vertSplit+1+i)
process.stdout.write(`${templogs[i]}${os.EOL}` )
}
}
export function log(string, color) {
if (mode) return console.log(string)
if (string == undefined) return;
var prefix = '';
switch (color) {
case "reset":
prefix = "\x1b[0m"
break;
case "bright":
prefix = "\x1b[1m"
break;
case "dim":
prefix = "\x1b[2m"
break;
case "underscore":
prefix = "\x1b[4m"
break;
case "reverse":
prefix = "\x1b[7m"
break;
case "FgBlack":
prefix = "\x1b[30m"
break;
case "FgRed":
prefix = "\x1b[31m"
break;
case "FgGreen":
prefix = "\x1b[32m"
break;
case "FgYellow":
prefix = "\x1b[33m"
break;
case "FgBlue":
prefix = "\x1b[34m"
break;
case "FgMagenta":
prefix = "\x1b[35m"
break;
case "FgCyan":
prefix = "\x1b[36m"
break;
case "FgWhite":
prefix = "\x1b[37m"
break;
}
// BgBlack = "\x1b[40m"
// BgRed = "\x1b[41m"
// BgGreen = "\x1b[42m"
// BgYellow = "\x1b[43m"
// BgBlue = "\x1b[44m"
// BgMagenta = "\x1b[45m"
// BgCyan = "\x1b[46m"
// BgWhite = "\x1b[47m"
const newString = prefix + string + "\x1b[0m"
logs.push(newString)
updateLog();
}
export function setInfo (players){
if (mode) return false
if (players != undefined) {
info[0] = players;
updateLog()
}
}

View file

@ -1,7 +0,0 @@
export class Player {
constructor(id, name, color) {
this.id = id;
this.name = name;
this.color = color;
}
}

View file

@ -1,80 +0,0 @@
import {Game} from "./game.mjs"
import * as log from "./log.mjs"
import * as util from "./util.mjs"
import {IllegalAction} from "./server/illegalAction.mjs"
class RoomManager {
constructor(){
this.games = [];
}
getGameByID(id) {
const game = this.games.filter(obj => obj.id == id)[0]
if (game === undefined) {
return false
}
return game
}
addGame(id, options) {
const game = new Game(id, options);
this.games.push(game);
return game
}
removeGameByID(id) {
this.games = this.games.filter(obj => obj.id != id);
log.log("removed game - " + id)
}
getAllPlayerIDs() {
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
}
getAllGameIDs() {
let ids = []
for (let i = 0; i < this.games.length; i++) {
ids.push(this.games[i].id)
}
return ids
}
playerJoinGame(roomCode, playerName, playerID) {
// See if the client is already in a game
console.log(roomCode, playerName)
if (this.getAllPlayerIDs().includes(playerID)) {
return new IllegalAction(id, 22)
}
if (!this.getAllGameIDs().includes(roomCode)) {
return new IllegalAction(id, 30)
}
const game = this.getGameByID(roomCode);
const player = game.addPlayer(playerID, playerName);
// See if player name is taken already
if (player === false) {
this.removeGame(game)
return new IllegalAction(id, 20)
}
return [game, player]
}
playerCreateGame(options, playerName, playerColor, playerID) {
if (this.getAllPlayerIDs().includes(playerID)) {
return new IllegalAction(id, 22)
}
console.log(options)
const id = util.createCode()
const game = this.addGame(id, options)
const player = game.addPlayer(playerID, playerName, playerColor);
return [game, player]
}
}
export var roomManager = new RoomManager();

View file

@ -1,11 +0,0 @@
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)
}
}

View file

@ -1,4 +0,0 @@
import {webServer} from "./server.mjs"
import { Server } from "socket.io";
export const io = new Server(webServer, {});

View file

@ -1,68 +0,0 @@
import {IllegalAction} from "./illegalAction.mjs"
import * as log from "../log.mjs"
import {roomManager} from "../roomManager.mjs"
import {io} from "./io.mjs"
io.on('connection', function(client){
connected(client)
});
function connected(client) {
client.sync = function() {
const tempWorld = client.game.world.obfuscate();
io.to(client.game.id).emit('sync',{world: tempWorld})
}
client.sendMeta = function() {
const roomID = client.game.id
const roomPlayers = client.game.players; // Dont send client id's to everyone, TODO
const metadata = {players: roomPlayers, roomID: roomID}
io.to(client.game.id).emit('metadata', metadata)
const id = client.game.id
client.emit('message', id)
}
client.game = "";
client.player = "";
client.on('disconnect', function(){
if (!roomManager.getAllPlayerIDs().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){
const info = roomManager.playerJoinGame(data.room, data.name, client.id)
client.join(info[0].id)
client.game = info[0];
client.player = info[1]
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('createGame', function(data){
const info = roomManager.playerCreateGame(data.options, data.name, data.color, client.id)
client.join(info[0].id)
client.game = info[0];
client.player = info[1]
log.log(`${client.id} joined the game as ${data.name} `, 'FgMagenta');
client.emit('inGame', true)
client.sync()
client.sendMeta()
})
client.on('leaveGame', function(data){
log.log(client.id + ' disconnected.')
client.game.removePlayerByID(client.id)
})
client.on('clickCanvas', function(data){
if (!roomManager.getAllPlayerIDs().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()
})
}

View file

@ -1,10 +0,0 @@
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;
});

View file

@ -1,12 +0,0 @@
import crypto from "crypto";
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));
}
export function createCode() {
const randomString = crypto.randomBytes(3).toString("hex").toUpperCase()
return randomString
}

View file

@ -1,22 +0,0 @@
export function flag(x, y, data, player) {
let tile = data[x][y]
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[x][y] = tile
return data;
}

View file

@ -1,42 +0,0 @@
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(avoidX, avoidY, world){
var minesPlanted = 0;
while (minesPlanted < world.mines || !(minesPlanted <= world.width*world.height-15)) {
const x = util.randomNumber(0,world.width)
const y = util.randomNumber(0,world.height)
var suitable = true;
searchLoc.forEach(loc => {
const tempx = x + loc[0]
const tempy = y + loc[1]
if (tempx === avoidX && tempy === avoidX) {
suitable = false;
}
})
if (x == avoidX && y == avoidY) { 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;
}

View file

@ -1,32 +0,0 @@
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.width; x++){
for(let y = 0; y < world.height; 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.width && tempy < world.height) {
if (world.data[tempx][tempy].type === 5) {
counter++;
}
}
});
if (counter !== 0) {
world.data[x][y].type = 15 + counter
}
}
}
}
world.isMarked = true;
return world;
}

View file

@ -1,16 +0,0 @@
export function obfuscate(world) {
let tempWorld = world;
for(let x = 0; x < tempWorld.width; x++){
for(let y = 0; y < tempWorld.height; y++){
if (tempWorld.data[x][y].mask === true) {
tempWorld.data[x][y].type = 0;
};
tempWorld.isObfuscated = true;
}
}
return tempWorld;
}

View file

@ -1,14 +0,0 @@
import * as log from "../log.mjs"
import * as revealer from "./revealer.mjs"
export function place(x, y, data) {
let tile = data[x][y];
if (tile.mask === true) {
if (tile.mask && tile.flag === 0) {
tile.mask = false;
}
data[x][y] = tile;
revealer.reveal(x, y, data)
}
return data;
}

View file

@ -1,43 +0,0 @@
const searchLoc =
[
[-1,1], [0,1], [1,1],
[-1,0], [1,0],
[-1,-1],[0,-1],[1,-1]
]
export function reveal(x, y, data) {
if (data[x][y].type !== 5) {
var toSearch = [];
var searchedLocations = [];
toSearch.push([x, y])
if (data[x][y].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
}
}

View file

@ -1,56 +0,0 @@
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(options) {
this.mines = options.mines
this.width = options.width*1
this.height = options.height*1
this.isGenerated = false;
this.isObfuscated = false;
this.isMarked = false;
this.data = Array.from(Array(this.width), () => new Array(this.height));
for (let x = 0; x < this.width; x++){
for (let y = 0; y < this.height; y++){
this.data[x][y] = {type: 1, flag: 0, mask: true}
}
}
}
click (x, y, mode, player) {
if (this.isGenerated) {
if (mode === 2) {
this.data = flagger.flag(x, y, this.data, player)
}
if (mode === 0) {
this.data = placer.place(x, y, this.data, player)
}
} else {
this.generate(x, y).mark();
this.data = placer.place(x, y, this.data, player)
}
}
generate(x, y) {
if (this.isGenerated) return log.log("Already Generated");
return generator.generate(x, y, this);
}
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);
}
}

View file

@ -4,6 +4,6 @@ import { port } from "../env.js"
var app = express() var app = express()
const __dirname = path.resolve(path.dirname('')); const __dirname = path.resolve(path.dirname(''));
app.use(express.static(__dirname + '/www/')); app.use(express.static(__dirname + '../server/www/'));
export var webServer = app.listen(port, function () { export var webServer = app.listen(port, function () {
}); });

View file

@ -3,11 +3,11 @@
"compilerOptions": { "compilerOptions": {
"module": "es2015", "module": "es2015",
"target": "es6", "target": "es6",
"rootDir": "src", "rootDir": "server/src",
"outDir": "dist", "outDir": "dist",
"sourceMap": false, "sourceMap": true,
"strict": true "strict": true
}, },
"include": ["src"], "include": ["server/src"],
"exclude": ["node_modules"] "exclude": ["node_modules"]
} }