Tidy unused code.
This commit is contained in:
parent
986dcc4dcd
commit
426cecd355
12
client/scripts/interface/mainmenu/join.js
Normal file
12
client/scripts/interface/mainmenu/join.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import * as net from "../../net/netcode.js"
|
||||
import {Picker} from "./picker.js"
|
||||
import {tileArray, menuArray} from "../../display/tileRenderer.js"
|
||||
import * as util from "../../util.js"
|
||||
import {ID} from "../../util.js"
|
||||
import * as status from "../../net/status.js"
|
||||
|
||||
var colorPicker;
|
||||
|
||||
export function init(){
|
||||
colorPicker = new Picker("joinGameSelectColorBar", tileArray, [8, 16], null, 0, null)
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import * as status from "../../net/status.js"
|
||||
// import {joinGame, createGame} from "../../net/netcode.js"
|
||||
import { changeScene } from "../scene.js"
|
||||
import * as createMenu from "./create.js"
|
||||
|
||||
import {ID} from "../../util.js"
|
||||
|
||||
const joinType = ID("joinType")
|
||||
|
@ -15,14 +15,12 @@ codeInput.addEventListener("input", e => {
|
|||
|
||||
|
||||
ID("gotoCreate").addEventListener("click", e => {
|
||||
joinType.style.display = "none"
|
||||
createGameMenu.style.display = ""
|
||||
createMenu.init()
|
||||
changeScene("newgame")
|
||||
})
|
||||
|
||||
ID("gotoJoin").addEventListener("click", e => {
|
||||
joinType.style.display = "none"
|
||||
joinGameMenu.style.display = "";
|
||||
if (codeInput.value.length !== 6) return console.log("error")
|
||||
net.initJoin(codeInput.value)
|
||||
})
|
||||
|
||||
ID("joinGameButton").addEventListener("click", e => {
|
||||
|
|
|
@ -1,13 +1,33 @@
|
|||
import {ID} from "../util.js"
|
||||
import * as createMenu from "./mainmenu/create.js"
|
||||
import * as joinMenu from "./mainmenu/join.js"
|
||||
const menu = ID('menu')
|
||||
const game = ID('game')
|
||||
const joinType = ID("joinType")
|
||||
const joinGameMenu = ID("joinGame")
|
||||
const createGameMenu = ID("createGame")
|
||||
|
||||
|
||||
export function changeScene(scene) {
|
||||
if (scene == "game") {
|
||||
document.getElementById('menu').style = "display: none;"
|
||||
document.getElementById('game').style = ""
|
||||
// picker.create();
|
||||
}
|
||||
if (scene == "mainmenu") {
|
||||
document.getElementById('menu').style = ""
|
||||
document.getElementById('game').style = "display: none;"
|
||||
// picker.destroy();
|
||||
console.log(`Changing scene to ${scene}`)
|
||||
switch (scene) {
|
||||
case "game":
|
||||
menu.style = "display: none;"
|
||||
game.style = ""
|
||||
break;
|
||||
case "mainmenu":
|
||||
menu.style = ""
|
||||
game.style = "display: none;"
|
||||
break;
|
||||
case "newgame":
|
||||
joinType.style.display = "none";
|
||||
createGameMenu.style.display = "";
|
||||
createMenu.init();
|
||||
break;
|
||||
case "joingame":
|
||||
joinType.style.display = "none";
|
||||
joinGameMenu.style.display = "";
|
||||
joinMenu.init();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -11,6 +11,10 @@ export function joinGame(data){
|
|||
socket.emit('joinGame', data);
|
||||
}
|
||||
|
||||
export function initJoin(code){
|
||||
socket.emit('initJoin', code)
|
||||
}
|
||||
|
||||
export function createGame(data){
|
||||
socket.emit('createGame', data);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script src="http://localhost:35729/livereload.js" charset="utf-8"></script>
|
||||
<script type="text/javascript" src="socket.io.min.js"></script>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script src='index.js' type="module"></script>
|
||||
|
@ -45,6 +44,8 @@
|
|||
</div>
|
||||
<div id="joinGame" style="display: none;">
|
||||
<input type="text" id="joinGameCode" value="">
|
||||
<u>Color</u>
|
||||
<div id="joinGameSelectColorBar"></div>
|
||||
<input type="text" id="joinGameUsername" value="">
|
||||
<button type="button" id="joinGameButton">Join</button>
|
||||
</div>
|
||||
|
|
14
package-lock.json
generated
14
package-lock.json
generated
|
@ -11,7 +11,7 @@
|
|||
"dependencies": {
|
||||
"express": "^4.18.1",
|
||||
"sass": "^1.52.3",
|
||||
"socket.io": "^4.5.0",
|
||||
"socket.io": "^4.5.1",
|
||||
"ts-node": "^10.8.1",
|
||||
"typescript": "^4.7.4"
|
||||
},
|
||||
|
@ -1039,9 +1039,9 @@
|
|||
"integrity": "sha512-W4N+o69rkMEGVuk2D/cvca3uYsvGlMwsySWV447y99gUPghxq42BxqLNMndb+a1mm/5/7NeXVQS7RLa2XyXvYg=="
|
||||
},
|
||||
"node_modules/socket.io-parser": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.4.tgz",
|
||||
"integrity": "sha512-t+b0SS+IxG7Rxzda2EVvyBZbvFPBCjJoyHuE0P//7OAsN23GItzDRdWa6ALxZI/8R5ygK7jAR6t028/z+7295g==",
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.5.tgz",
|
||||
"integrity": "sha512-sNjbT9dX63nqUFIOv95tTVm6elyIU4RvB1m8dOeZt+IgWwcWklFDOdmGcfo3zSiRsnR/3pJkjY5lfoGqEe4Eig==",
|
||||
"dependencies": {
|
||||
"@types/component-emitter": "^1.2.10",
|
||||
"component-emitter": "~1.3.0",
|
||||
|
@ -2037,9 +2037,9 @@
|
|||
"integrity": "sha512-W4N+o69rkMEGVuk2D/cvca3uYsvGlMwsySWV447y99gUPghxq42BxqLNMndb+a1mm/5/7NeXVQS7RLa2XyXvYg=="
|
||||
},
|
||||
"socket.io-parser": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.4.tgz",
|
||||
"integrity": "sha512-t+b0SS+IxG7Rxzda2EVvyBZbvFPBCjJoyHuE0P//7OAsN23GItzDRdWa6ALxZI/8R5ygK7jAR6t028/z+7295g==",
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.0.5.tgz",
|
||||
"integrity": "sha512-sNjbT9dX63nqUFIOv95tTVm6elyIU4RvB1m8dOeZt+IgWwcWklFDOdmGcfo3zSiRsnR/3pJkjY5lfoGqEe4Eig==",
|
||||
"requires": {
|
||||
"@types/component-emitter": "^1.2.10",
|
||||
"component-emitter": "~1.3.0",
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
"dependencies": {
|
||||
"express": "^4.18.1",
|
||||
"sass": "^1.52.3",
|
||||
"socket.io": "^4.5.0",
|
||||
"socket.io": "^4.5.1",
|
||||
"ts-node": "^10.8.1",
|
||||
"typescript": "^4.7.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/node16": "^1.0.3",
|
||||
"rollup": "^2.75.7",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/node": "^18.0.0"
|
||||
"@types/node": "^18.0.0",
|
||||
"rollup": "^2.75.7"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ class RoomManager {
|
|||
constructor(){
|
||||
this.games = [];
|
||||
}
|
||||
|
||||
getGameByID(id:string) {
|
||||
const game = this.games.filter(obj => obj.id == id)[0]
|
||||
return game
|
||||
|
@ -16,9 +17,9 @@ class RoomManager {
|
|||
this.games.push(game);
|
||||
return game
|
||||
}
|
||||
|
||||
removeGameByID(id:string) {
|
||||
this.games = this.games.filter(obj => obj.id != id);
|
||||
|
||||
}
|
||||
|
||||
getAllPlayerIDs() {
|
||||
|
|
|
@ -34,6 +34,10 @@ function connected(client:any) {
|
|||
client.player = null
|
||||
})
|
||||
|
||||
client.on('initJoin', function(code:string){
|
||||
if (roomManager.getGameByID(code).players.length >= 8) return new IllegalAction(client.id, 28)
|
||||
})
|
||||
|
||||
client.on('joinGame', function(data:any){
|
||||
const info = roomManager.playerJoinGame(data.room, data.name, data.color, client.id)
|
||||
client.join(info[0].id)
|
||||
|
|
Loading…
Reference in a new issue