diff options
author | Kyle Gunger <corechg@gmail.com> | 2020-02-27 17:48:00 -0500 |
---|---|---|
committer | Kyle Gunger <corechg@gmail.com> | 2020-02-27 17:48:00 -0500 |
commit | ea8f308bc00330b5378eb2b8f16d9cc348719c9a (patch) | |
tree | 34a9074b4687beefd3bf046d68374ef307f178da /webcards/scripts/client/lobby.js | |
parent | 62cfd4f23993e04602aa15adf4fc71e6eb48c376 (diff) |
Init WebCards
Diffstat (limited to 'webcards/scripts/client/lobby.js')
-rw-r--r-- | webcards/scripts/client/lobby.js | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/webcards/scripts/client/lobby.js b/webcards/scripts/client/lobby.js new file mode 100644 index 0000000..8d46352 --- /dev/null +++ b/webcards/scripts/client/lobby.js @@ -0,0 +1,102 @@ +// Lobby manages the players and games provided by the server and allows users to join or create their own games. +function Lobby(el){ + this.root = el; + + this.elements = { + status: this.root.getElementsByClassName("status")[0], + addr: this.root.getElementsByClassName("addr")[0], + + stats: { + game: document.getElementById("game"), + packs: document.getElementById("packs"), + online: document.getElementById("online"), + ingame: document.getElementById("ingame"), + pubgame: document.getElementById("pubgame") + }, + + settings: { + name: document.getElementById("name"), + color: document.getElementById("usercolor") + } + }; + + this.top = new TopBar(document.getElementsByClassName("topbar")[0]); + + this.init = false; + this.online = []; + this.games = []; + this.packs = []; + this.players = []; +} + +Lobby.prototype = { + packList: function(data){ + + this.elements.stats.packs.innerText = this.packs.length(); + }, + + gameList: function(data, game){ + + this.elements.stats.pubgame.innerText = this.games.length(); + }, + + players: function(data) { + + this.elements.stats.online.innerText = this.players.length(); + this.init = true; + }, + + addGame: function(data){ + + }, + + removeGame: function(data){ + + }, + + addPlayer: function(data){ + + }, + + movePlayer: function(data){ + + }, + + removePlayer: function(data){ + + }, + + newGameScreen: function(){ + if(this.init) return; + }, + + setState: function(text, color, server){ + this.elements.status.style.backgroundColor = color; + this.elements.status.innerText = text; + this.elements.addr.innerText = server; + this.top.setColor(color); + }, + + reset: function(){ + this.setState("Connecting", "#DA0", this.elements.addr.innerText); + this.init = false; + } +}; + +// ############### +// # TopBar Code # +// ############### + +function TopBar(el) { + this.root = el; + + this.newGame = el.getElementsByClassName("new-game")[0]; + this.mobileSettings = el.getElementsByClassName("mobile-settings")[0]; + this.status = el.getElementsByClassName("status")[0]; +} + +TopBar.prototype = { + setColor: function(color) { + this.status.style.backgroundColor = color; + } +}; |