diff --git a/client/board.js b/client/board.js index 2abd102..8ff7b44 100644 --- a/client/board.js +++ b/client/board.js @@ -123,6 +123,16 @@ Board.prototype.drawSquares = function() { Board.prototype.drawWalls = function(edges) { this.walls = {}; + while (this.parent.getElementsByClassName('content-wall-x').length) { + const child = this.parent.getElementsByClassName('content-wall-x')[0]; + child.parentNode.removeChild(child); + } + + while (this.parent.getElementsByClassName('content-wall-y').length) { + const child = this.parent.getElementsByClassName('content-wall-y')[0]; + child.parentNode.removeChild(child); + } + edges.forEach(edge => { this.walls[edge] = true; diff --git a/client/controls.js b/client/controls.js index 41903a6..eddaf1f 100644 --- a/client/controls.js +++ b/client/controls.js @@ -1,9 +1,13 @@ -const Controls = function(connection) { - this.connection = connection; +const Controls = function() { this.moves = 0; document.addEventListener('move-increment', this.onMoveIncrement.bind(this)); + document.getElementById('controls-moves-reset').addEventListener('click', this.onMoveReset.bind(this)); + document.getElementById('controls-next-round').addEventListener('click', this.onStartNextGame.bind(this)); + document.getElementById('controls-regenerate-walls').addEventListener('click', this.onRegenWalls.bind(this)); + document.getElementById('controls-reposition-robots').addEventListener('click', this.onRepositionRobots.bind(this)); + // document.getElementById('controls-timer-skip').addEventListener('click', this.onSkipTimer.bind(this)); } // guessBuild: = function() { @@ -25,12 +29,17 @@ const Controls = function(connection) { // }, Controls.prototype.playerAdd = function() { - const rawInput = prompt("What is your name?"); - this.connection.send(JSON.stringify({ head: { type: 'playerAdd' }, body: rawInput })) + const names = ["Biff", "Morty", "Herb", "Chester", "Lyle", "Cap", "Dale", "Ned", "Mindy"] + const r = Math.floor(Math.random() * names.length); + + const rawInput = names[r] //prompt("What is your name?"); + + const evt = new CustomEvent('playerAdd', { detail: rawInput }); + document.dispatchEvent(evt); }; Controls.prototype.playerRemove = function(rawInput) { - this.connection.send(JSON.stringify({ head: { type: 'playerRemove' }, body: rawInput })) + alert('nope') }; Controls.prototype.playersUpdate = function(names) { @@ -72,6 +81,21 @@ Controls.prototype.onMoveReset = function() { this.moves = 0; document.getElementById('controls-moves').innerHTML = this.moves; - var event = new Event('board-reset'); + const event = new Event('board-reset'); document.dispatchEvent(event); -}; \ No newline at end of file +}; + +Controls.prototype.onStartNextGame = function() { + const evt = new Event('board-reset'); + document.dispatchEvent(evt); +} + +Controls.prototype.onRegenWalls = function() { + const evt = new Event('regenerateWalls'); + document.dispatchEvent(evt); +} + +Controls.prototype.onRepositionRobots = function() { + const evt = new Event('repositionRobots'); + document.dispatchEvent(evt); +} \ No newline at end of file diff --git a/index.css b/index.css index fff9602..21c9a50 100644 --- a/index.css +++ b/index.css @@ -16,8 +16,8 @@ body { #controls-container { background: #e7e7e7; - border: solid #c7c7c7; - border-width: 0 1px; + border: solid #e7e7e7; + border-width: 0 10px; bottom: 0; left: 20px; position: absolute; @@ -38,6 +38,7 @@ body { .controls-subtitle { background-color: #4D3243; + background-image: linear-gradient(90deg, #4D3243, #3C2132); color: #fff; padding: 12px; margin: 24px 0 12px 0; @@ -59,19 +60,22 @@ body { .controls-button { background: none; border: 1px solid #888; - color: #666; + color: #444; cursor: pointer; font-size: 12px; padding: 4px 8px; } .controls-button:hover { - background: #ddd; - border-color: #444; - color: #222; + background: #639699; + border-color: #639699; + color: #fff; } -#controls-room { +#controls-start { + display: block; + margin: 0 auto; + padding: 4px 8px; } .controls-room-error { diff --git a/index.html b/index.html index 58f552b..7c87e5f 100644 --- a/index.html +++ b/index.html @@ -13,10 +13,8 @@