From b14cdadd417dd8b3082c91fd69329508be44f5e2 Mon Sep 17 00:00:00 2001 From: Ben Burlingham Date: Sun, 19 Jul 2020 10:08:57 -0700 Subject: [PATCH] Newround event elevated to global. --- README.md | 2 -- client/connection.js | 1 + client/controls.js | 3 +-- client/grid.js | 2 +- server/ricochet.js | 3 ++- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1265cdd..9ba4ae8 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,4 @@ A victory state can be stored by taking a snapshot of the current stack. Icons from [https://game-icons.net](https://game-icons.net) ## TODO -- reset robots? on server reset...avoid multiple shadows -- "start next round" button not showing on new join in win state - Fix 6 things diff --git a/client/connection.js b/client/connection.js index 172ab67..fe1d88a 100644 --- a/client/connection.js +++ b/client/connection.js @@ -91,6 +91,7 @@ Connection.prototype.onReceiveMessage = function({ data }) { case 'connected': eventName = 'G-connected'; break; case 'countdown': eventName = 'G-countdown'; break; case 'full': eventName = 'G-full'; break; + case 'newround': eventName = 'G-newround'; break; case 'objective': eventName = 'G-objective'; break; case 'players': eventName = 'G-players'; break; case 'robots': eventName = 'G-robots'; break; diff --git a/client/controls.js b/client/controls.js index e4de5e0..ae2458a 100644 --- a/client/controls.js +++ b/client/controls.js @@ -11,7 +11,6 @@ const Controls = function() { document.addEventListener('L-conn-error', this.msgConnectionError.bind(this)); document.addEventListener('L-complete', this.msgComplete.bind(this)); document.addEventListener('L-join', this.msgJoin.bind(this)); - document.addEventListener('L-newround', this.msgNewRound.bind(this)); document.addEventListener('L-replay-complete', this.msgReplayComplete.bind(this)); document.addEventListener('L-skip', this.msgSkip.bind(this)); document.addEventListener('L-stack', this.msgStack.bind(this)); @@ -19,6 +18,7 @@ const Controls = function() { document.addEventListener('G-connected', this.msgConnected.bind(this)); document.addEventListener('G-countdown', this.msgCountdown.bind(this)); document.addEventListener('G-full', this.msgFull.bind(this)); + document.addEventListener('G-newround', this.msgNewRound.bind(this)); document.addEventListener('G-players', this.msgPlayers.bind(this)); document.addEventListener('G-state', this.msgState.bind(this)); document.addEventListener('G-win', this.msgWin.bind(this)); @@ -199,7 +199,6 @@ Controls.prototype.msgWin = function(evt) { Controls.prototype.msgNewRound = function() { this.winningMoveCount = Infinity; document.getElementById('controls-win-next').style.display = 'none'; - // SHOW ARROWS IN GRID }; Controls.prototype.msgReplayComplete = function() { diff --git a/client/grid.js b/client/grid.js index c4158f9..990beed 100644 --- a/client/grid.js +++ b/client/grid.js @@ -13,10 +13,10 @@ const Grid = function() { this.squaresPerSide = 20; this.squareSideLength = 0; - document.addEventListener('L-newround', this.msgNewRound.bind(this)); document.addEventListener('L-stack', this.msgStack.bind(this)); document.addEventListener('L-shadows', this.msgShadows.bind(this)); + document.addEventListener('G-newround', this.msgNewRound.bind(this)); document.addEventListener('G-robots', this.msgRobots.bind(this)); document.addEventListener('G-walls', this.msgWalls.bind(this)); document.addEventListener('G-objective', this.msgObjective.bind(this)); diff --git a/server/ricochet.js b/server/ricochet.js index 7c625eb..0e06ef5 100644 --- a/server/ricochet.js +++ b/server/ricochet.js @@ -271,6 +271,7 @@ Ricochet.prototype.msgNewRound = function() { this.winningPlayerId = null; this.winningStack = null; + this.messenger.messageAll({ type: 'newround' }); this.messenger.messageAll({ type: 'objective', body: this.objective}); this.messenger.messageAll({ type: 'state', body: this.state}); this.messenger.messageAll({ type: 'robots', body: this.robots}); @@ -298,7 +299,7 @@ Ricochet.prototype.msgSkip = function() { Ricochet.prototype.msgSolve = function(message) { clearTimeout(this.countdownTimer); - + this.countdownTimer = setTimeout(this.onCountdownComplete.bind(this), this.countdownDuration * 1000); this.countdownTimestamp = new Date().getTime();