Merge pull request 'MAPG-222 fixes: skip invalid guessPosition, hide showSummaryButton, handle countdown time if timeout is 0' (#18) from bugfix/MAPG-222-show-summary-can-be-clicked-when-game-is-restarted into develop
All checks were successful
default-pipeline default-pipeline #98

Reviewed-on: https://gitea.e5tv.hu/esoko/mapguesser/pulls/18
This commit is contained in:
Bence Pőcze 2021-04-04 23:05:47 +02:00 committed by Gitea
commit 257f59c96e
No known key found for this signature in database
GPG Key ID: 2E27A8C281A1CC2C

View File

@ -120,9 +120,11 @@
for (var j = 0; j < round.allResults.length; ++j) { for (var j = 0; j < round.allResults.length; ++j) {
var result = round.allResults[j]; var result = round.allResults[j];
if (result.guessPosition) {
Game.addGuessPositionToResultMap(result.guessPosition, result, true); Game.addGuessPositionToResultMap(result.guessPosition, result, true);
} }
} }
}
document.getElementById('currentRound').innerHTML = String(Game.rounds.length) + '/' + String(Game.NUMBER_OF_ROUNDS); document.getElementById('currentRound').innerHTML = String(Game.rounds.length) + '/' + String(Game.NUMBER_OF_ROUNDS);
document.getElementById('currentScoreSum').innerHTML = String(Game.scoreSum) + '/' + String(Game.rounds.length * Game.MAX_SCORE); document.getElementById('currentScoreSum').innerHTML = String(Game.scoreSum) + '/' + String(Game.rounds.length * Game.MAX_SCORE);
@ -330,6 +332,7 @@
scoreInfo.children[0].style.display = null; scoreInfo.children[0].style.display = null;
scoreInfo.children[1].style.display = null; scoreInfo.children[1].style.display = null;
document.getElementById('continueButton').style.display = null; document.getElementById('continueButton').style.display = null;
document.getElementById('showSummaryButton').style.display = null;
document.getElementById('startNewGameButton').style.display = null; document.getElementById('startNewGameButton').style.display = null;
document.getElementById('showGuessButton').style.visibility = null; document.getElementById('showGuessButton').style.visibility = null;
@ -434,10 +437,12 @@
if (allResults) { if (allResults) {
for (var i = 0; i < allResults.length; ++i) { for (var i = 0; i < allResults.length; ++i) {
var currentResult = allResults[i]; var currentResult = allResults[i];
if (currentResult.guessPosition) {
Game.addGuessPositionToResultMap(currentResult.guessPosition, currentResult); Game.addGuessPositionToResultMap(currentResult.guessPosition, currentResult);
resultBounds.extend(currentResult.guessPosition); resultBounds.extend(currentResult.guessPosition);
} }
} }
}
Game.showResultMap(result, resultBounds); Game.showResultMap(result, resultBounds);
}, },
@ -735,15 +740,16 @@
clearInterval(Game.countdownHandler); clearInterval(Game.countdownHandler);
} }
Game.countdownElement = document.getElementById('countdown');
Game.countdownTimeElement = document.getElementById('countdownTime');
Game.setCountdownTime(Math.round(timeout / 1000));
if (timeout <= 0) { if (timeout <= 0) {
return; return;
} }
Game.timeoutEnd = new Date(new Date().getTime() + timeout); 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 () { Game.countdownHandler = setInterval(function () {
var timeLeft = Math.round((Game.timeoutEnd - new Date()) / 1000); var timeLeft = Math.round((Game.timeoutEnd - new Date()) / 1000);