diff --git a/buildstyle.sh b/buildstyle.sh deleted file mode 100644 index 1eb5d45..0000000 --- a/buildstyle.sh +++ /dev/null @@ -1,2 +0,0 @@ -scss client/scss/main.scss dist/www/style.css -rm -rf .sass-cache diff --git a/package.json b/package.json index 5c7b0cb..1f80195 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,7 @@ "main": "", "type": "module", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build": "" + "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", diff --git a/server/src/roomManager.ts b/server/src/roomManager.ts index 5ca2ccd..63e51ea 100644 --- a/server/src/roomManager.ts +++ b/server/src/roomManager.ts @@ -58,7 +58,6 @@ class RoomManager { if (this.getAllPlayerIDs().includes(playerID)) { // return new IllegalAction(playerID, 22) } - console.log(options) const id = util.createCode() const game = this.addGame(id, options) const player = game.addPlayer(playerID, playerName, playerColor); diff --git a/server/src/server/netcode.ts b/server/src/server/netcode.ts index eecee00..088d44f 100644 --- a/server/src/server/netcode.ts +++ b/server/src/server/netcode.ts @@ -1,6 +1,8 @@ import {IllegalAction} from "./illegalAction.js" import {roomManager} from "../roomManager.js" import {io} from "./io.js" +import {Player} from "../player.js" +import {Game} from "../game.js" io.on('connection', function(client:any){ connected(client) @@ -21,14 +23,15 @@ function connected(client:any) { const id = client.game.id client.emit('message', id) } - - client.game = ""; - client.player = ""; + client.game = null; + client.player = null; client.on('disconnect', function(){ if (!roomManager.getAllPlayerIDs().includes(client.id)) return new IllegalAction(client.id, 22) client.game.removePlayerByID(client.id) client.sendMeta(); + client.game = null + client.player = null }) client.on('joinGame', function(data:any){ @@ -40,9 +43,31 @@ function connected(client:any) { client.emit('inGame', true) client.sendMeta() }) + type CreateGameOptions = {width: number, height: number, mines: number} + type CreateGameData = {options: CreateGameOptions, name: string, color: number} client.on('createGame', function(data:any){ - const info = roomManager.playerCreateGame(data.options, data.name, data.color, client.id) + if ( + typeof data.name === "string" && + typeof data.color === "number" && + typeof data.options.width === "number" && + typeof data.options.height === "number" && + typeof data.options.mines === "number" + ) { + console.log("good 2") + } else {return false} + if ( + data.name.length < 9 && + data.color > 0 && data.color < 9 && + data.options.width > 8 && data.options.width < 500 && + data.options.height > 8 && data.options.height < 500 && + data.options.mines > 6 && data.options.mines < (data.options.height * data.options.width) + ) { + console.log("good 3") + } else {return false} + const createGameData: CreateGameData = data as CreateGameData; + console.log(createGameData) + const info = roomManager.playerCreateGame(createGameData.options, createGameData.name, createGameData.color, client.id) client.join(info[0].id) client.game = info[0]; client.player = info[1] diff --git a/server/src/world/world.ts b/server/src/world/world.ts index 12f82f7..b907de3 100644 --- a/server/src/world/world.ts +++ b/server/src/world/world.ts @@ -18,8 +18,8 @@ export class World { data: WorldData; constructor(options:any) { this.mines = options.mines - this.width = options.width*1 - this.height = options.height*1 + this.width = options.width + this.height = options.height this.isGenerated = false; this.isObfuscated = false; this.isMarked = false;