From c2f5806394b9eb0b7b5387d30cacbfb8a9bc8b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 4 Apr 2021 23:01:01 +0200 Subject: [PATCH] MAPG-222 fixes: skip invalid guessPosition, hide showSummaryButton, handle countdown time if timeout is 0 --- public/static/js/game.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/public/static/js/game.js b/public/static/js/game.js index 4519d62..cd9685e 100644 --- a/public/static/js/game.js +++ b/public/static/js/game.js @@ -120,7 +120,9 @@ for (var j = 0; j < round.allResults.length; ++j) { var result = round.allResults[j]; - Game.addGuessPositionToResultMap(result.guessPosition, result, true); + if (result.guessPosition) { + Game.addGuessPositionToResultMap(result.guessPosition, result, true); + } } } @@ -330,6 +332,7 @@ scoreInfo.children[0].style.display = null; scoreInfo.children[1].style.display = null; document.getElementById('continueButton').style.display = null; + document.getElementById('showSummaryButton').style.display = null; document.getElementById('startNewGameButton').style.display = null; document.getElementById('showGuessButton').style.visibility = null; @@ -434,8 +437,10 @@ if (allResults) { for (var i = 0; i < allResults.length; ++i) { var currentResult = allResults[i]; - Game.addGuessPositionToResultMap(currentResult.guessPosition, currentResult); - resultBounds.extend(currentResult.guessPosition); + if (currentResult.guessPosition) { + Game.addGuessPositionToResultMap(currentResult.guessPosition, currentResult); + resultBounds.extend(currentResult.guessPosition); + } } } @@ -735,15 +740,16 @@ clearInterval(Game.countdownHandler); } + Game.countdownElement = document.getElementById('countdown'); + Game.countdownTimeElement = document.getElementById('countdownTime'); + + Game.setCountdownTime(Math.round(timeout / 1000)); + if (timeout <= 0) { return; } Game.timeoutEnd = new Date(new Date().getTime() + timeout); - Game.countdownElement = document.getElementById('countdown'); - Game.countdownTimeElement = document.getElementById('countdownTime'); - - Game.setCountdownTime(Math.round(timeout / 1000)); Game.countdownHandler = setInterval(function () { var timeLeft = Math.round((Game.timeoutEnd - new Date()) / 1000); -- 2.45.2