From ad911d6edd0fa76431284ef6283bb07da45d808d Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Thu, 11 Aug 2022 00:03:45 -0400 Subject: A few small fixes --- scripts/cards/card.js | 10 ++++++++++ scripts/client.js | 25 +++++++++++++++++-------- scripts/gui/lobby.js | 3 +++ styles/client/card.css | 2 +- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/scripts/cards/card.js b/scripts/cards/card.js index 7246db3..17d8994 100644 --- a/scripts/cards/card.js +++ b/scripts/cards/card.js @@ -81,6 +81,16 @@ class Card { static generateObjectCard (data, el) { // Generate card areas. + if (typeof data.style == "object") { + for (let i in data.style) { + el.style.setProperty(i, data.style[i]); + } + } + + if(data.assetURL == null) { + data.assetURL = "./"; + } + for (let i of CardPos) { if (typeof data[i] == "object") diff --git a/scripts/client.js b/scripts/client.js index ffba4b5..815d4f2 100644 --- a/scripts/client.js +++ b/scripts/client.js @@ -171,23 +171,32 @@ class Client{ { let m = e.detail; - if(m.type === "nojoin") { + switch (m.type) { + case "nojoin": alert(`Failed to join game. ${m.data}`); - } else if (m.type === "join") { - this.table.openTable(); - this.lobby.setState("In Game", "ok", this.socket.server) - this.inGame = true; - } else if (m.type === "leave") { + break; + case "leave": this.table.reset(); if (this.game.id !== m.data) { this.lobby.setState("Joining...", "loading", this.socket.server); this.socket.send("join", this.game); + } else { + this.lobby.setState("Connected", "ok", this.socket.server); } this.inGame = false; - } else if (TABLE_RPC.includes(m.type)) - this.table[m.type](m.data); + break; + case "join": + this.table.openTable(); + this.lobby.setState("In Game", "ok", this.socket.server); + this.inGame = true; + break; + default: + if (TABLE_RPC.includes(m.type) && this.inGame) + this.table[m.type](m.data); + break; + } } // Callback when a chat event is recieved from the server diff --git a/scripts/gui/lobby.js b/scripts/gui/lobby.js index a2771b7..c760f50 100644 --- a/scripts/gui/lobby.js +++ b/scripts/gui/lobby.js @@ -159,6 +159,9 @@ class Lobby { } for (let i of data.games) { + if(typeof i != "object") + continue; + if (this.games[i.id] == null) { let g = new Game(i, this.e.games); this.games[i.id] = g; diff --git a/styles/client/card.css b/styles/client/card.css index 8b82fec..6f03347 100644 --- a/styles/client/card.css +++ b/styles/client/card.css @@ -136,7 +136,7 @@ deck { top: calc(var(--y) * (100vh - 250px)); left: calc(var(--x) * (100vw - 166px)); - transform: scale(var(--size)) rotate(var(--rot)); + transform: scale(var(--scale)) rotate(var(--rot)); overflow: visible; -- cgit v1.2.3