From 5ffbbc8524fb5c42b00c741e9868e99e3f7c3fe4 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Tue, 29 Sep 2020 14:41:43 -0400 Subject: Start join game implementation --- scripts/gui/lobby.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'scripts/gui') diff --git a/scripts/gui/lobby.js b/scripts/gui/lobby.js index 7d2b6cd..5939697 100644 --- a/scripts/gui/lobby.js +++ b/scripts/gui/lobby.js @@ -41,10 +41,22 @@ class TopBar{ // ############# // Game represents a single game in the lobby view. It has methods for setting up the elements and such. -class Game{ - constructor (name, packs, maxp, id) - { - } +function createGameEl (options = {id: 0, name: ""}, el) +{ + let e = document.createElement("div"); + e.className = "game"; + + let title = document.createElement("h2"); + title.textContent = options.name; + e.appendChild(title); + + let join = document.createElement("button"); + join.className = "join"; + join.textContent = "Join"; + join.addEventListener("click", game.joinGame.bind(game, options.id)); + e.appendChild(join); + + el.appendChild(e); } // ############## @@ -130,7 +142,7 @@ class Lobby { // { data.packs } list of the pack names used by this game // { data.id } room identifier (uuid) addGame (data) { - + createGameEl(data, this.e.games); } // Called when a new public game is removed on the server -- cgit v1.2.3