Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | /** This class represents frontend data associated with the game lobby and session */ class GameRoom{ /** * Creates an instance of a GameRoom to be used by players * * @param {Player} host the player that is designated as the host * @param {Player[]} playerList list of players that have joined the lobby * @param {number} lobbyID the id that identifies the lobby * @param {number} maxPlayers the maxiumum number of players that can join * @param {number} numPlayers the number of players that have joined the lobby */ constructor(host, maxPlayers) { /** * @type {Player} * @private */ this._host = host; /** * @type {Player[]} * @private */ this._playerList = []; /** * @type {number} * @private */ this._lobbyID = Math.floor(Math.random() * 10000); // Generate a random lobby ID /** * @type {number} * @private */ this._maxPlayers = maxPlayers; /** * @type {number} * @private */ this._numPlayers = 1; // Starts with the host } /** @returns {Player} The host of the game room. */ get host() { return this._host; } /** @param {Player} newHost - The new host of the game room. */ set host(newHost) { this._host = newHost; } /** @returns {Player[]} The list of players in the game room. */ get playerList() { return this._playerList; } /** * @param {Player[]} newPlayerList - The updated list of players. */ set playerList(newPlayerList) { this._playerList = newPlayerList; this._numPlayers = newPlayerList.length + 1; // Update numPlayers (including host) } /** @returns {number} The unique lobby ID. */ get lobbyID() { return this._lobbyID; } /** @param {number} newLobbyID - The new lobby ID. */ set lobbyID(newLobbyID) { this._lobbyID = newLobbyID; } /** @returns {number} The maximum number of players allowed. */ get maxPlayers() { return this._maxPlayers; } /** @param {number} newMaxPlayers - The new maximum player limit. */ set maxPlayers(newMaxPlayers) { this._maxPlayers = newMaxPlayers; } /** @returns {number} The current number of players in the room. */ get numPlayers() { return this._numPlayers; } /** @param {number} newNumPlayers - The updated player count. */ set numPlayers(newNumPlayers) { this._numPlayers = newNumPlayers; } } |