test
This commit is contained in:
parent
43a3535442
commit
406c848eca
|
@ -1,2 +0,0 @@
|
||||||
scss client/scss/main.scss dist/www/style.css
|
|
||||||
rm -rf .sass-cache
|
|
|
@ -5,8 +5,7 @@
|
||||||
"main": "",
|
"main": "",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
"build": ""
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -58,7 +58,6 @@ class RoomManager {
|
||||||
if (this.getAllPlayerIDs().includes(playerID)) {
|
if (this.getAllPlayerIDs().includes(playerID)) {
|
||||||
// return new IllegalAction(playerID, 22)
|
// return new IllegalAction(playerID, 22)
|
||||||
}
|
}
|
||||||
console.log(options)
|
|
||||||
const id = util.createCode()
|
const id = util.createCode()
|
||||||
const game = this.addGame(id, options)
|
const game = this.addGame(id, options)
|
||||||
const player = game.addPlayer(playerID, playerName, playerColor);
|
const player = game.addPlayer(playerID, playerName, playerColor);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import {IllegalAction} from "./illegalAction.js"
|
import {IllegalAction} from "./illegalAction.js"
|
||||||
import {roomManager} from "../roomManager.js"
|
import {roomManager} from "../roomManager.js"
|
||||||
import {io} from "./io.js"
|
import {io} from "./io.js"
|
||||||
|
import {Player} from "../player.js"
|
||||||
|
import {Game} from "../game.js"
|
||||||
|
|
||||||
io.on('connection', function(client:any){
|
io.on('connection', function(client:any){
|
||||||
connected(client)
|
connected(client)
|
||||||
|
@ -21,14 +23,15 @@ function connected(client:any) {
|
||||||
const id = client.game.id
|
const id = client.game.id
|
||||||
client.emit('message', id)
|
client.emit('message', id)
|
||||||
}
|
}
|
||||||
|
client.game = null;
|
||||||
client.game = "";
|
client.player = null;
|
||||||
client.player = "";
|
|
||||||
|
|
||||||
client.on('disconnect', function(){
|
client.on('disconnect', function(){
|
||||||
if (!roomManager.getAllPlayerIDs().includes(client.id)) return new IllegalAction(client.id, 22)
|
if (!roomManager.getAllPlayerIDs().includes(client.id)) return new IllegalAction(client.id, 22)
|
||||||
client.game.removePlayerByID(client.id)
|
client.game.removePlayerByID(client.id)
|
||||||
client.sendMeta();
|
client.sendMeta();
|
||||||
|
client.game = null
|
||||||
|
client.player = null
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on('joinGame', function(data:any){
|
client.on('joinGame', function(data:any){
|
||||||
|
@ -40,9 +43,31 @@ function connected(client:any) {
|
||||||
client.emit('inGame', true)
|
client.emit('inGame', true)
|
||||||
client.sendMeta()
|
client.sendMeta()
|
||||||
})
|
})
|
||||||
|
type CreateGameOptions = {width: number, height: number, mines: number}
|
||||||
|
type CreateGameData = {options: CreateGameOptions, name: string, color: number}
|
||||||
|
|
||||||
client.on('createGame', function(data:any){
|
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.join(info[0].id)
|
||||||
client.game = info[0];
|
client.game = info[0];
|
||||||
client.player = info[1]
|
client.player = info[1]
|
||||||
|
|
|
@ -18,8 +18,8 @@ export class World {
|
||||||
data: WorldData;
|
data: WorldData;
|
||||||
constructor(options:any) {
|
constructor(options:any) {
|
||||||
this.mines = options.mines
|
this.mines = options.mines
|
||||||
this.width = options.width*1
|
this.width = options.width
|
||||||
this.height = options.height*1
|
this.height = options.height
|
||||||
this.isGenerated = false;
|
this.isGenerated = false;
|
||||||
this.isObfuscated = false;
|
this.isObfuscated = false;
|
||||||
this.isMarked = false;
|
this.isMarked = false;
|
||||||
|
|
Loading…
Reference in a new issue