feature/MAPG-235-basic-challenge-mode #48

Merged
balazs merged 43 commits from feature/MAPG-235-basic-challenge-mode into develop 2021-05-28 20:41:09 +02:00
5 changed files with 26 additions and 4 deletions
Showing only changes of commit aadeda05af - Show all commits

View File

@ -93,6 +93,7 @@ div.mapItem>div.buttonContainer {
#restrictions input[type=range] {
height: 1.5em;
margin-left: 2em;
width: 70%;
}
#timeLimitType {

View File

@ -65,6 +65,22 @@
}
};
var Util = {
printTimeForHuman: function (time) {
if (time < 60) {
return '' + time + ' seconds';
} else if (time == 60) {
return '1 minute';
} else if (time % 60 == 0) {
return '' + Math.floor(time / 60) + ' minutes';
} else if (time % 60 == 1) {
return '' + Math.floor(time / 60) + ' minutes and 1 second';
} else {
return '' + Math.floor(time / 60) + ' minutes and ' + time % 60 + ' seconds';
}
}
};
Maps.addStaticMaps();
Maps.initializeDescriptionDivs();
@ -119,7 +135,7 @@
document.getElementById('playMode').style.visibility = 'hidden';
var timeLimit = document.getElementById('timeLimit').value;
document.getElementById('timeLimitLabel').innerText = 'Time limit of ' + timeLimit + ' seconds per round';
document.getElementById('timeLimitLabel').innerText = 'Time limit of ' + Util.printTimeForHuman(timeLimit);
};
}
@ -149,7 +165,7 @@
document.getElementById('timeLimit').oninput = function () {
var timeLimit = document.getElementById('timeLimit').value;
document.getElementById('timeLimitLabel').innerText = 'Time limit of ' + timeLimit + ' seconds per round';
document.getElementById('timeLimitLabel').innerText = 'Time limit of ' + Util.printTimeForHuman(timeLimit);
document.getElementById('timerEnabled').checked = true;
}
})();

View File

@ -239,6 +239,11 @@ class GameFlowController
$response = $this->prepareChallengeResponse($userId, $challenge, $currentRound, true);
if ($challenge->getTimeLimitType() === 'game' && $userInChallenge->getCurrentRound() > 0) {
$timeLimit = max(10, $userInChallenge->getTimeLeft());
$response['restrictions']['timeLimit'] = $timeLimit * 1000;
}
return new JsonContent($response);
}

View File

@ -50,7 +50,7 @@ class UserInChallenge extends Model
public function setTimeLeft(?int $timeLeft): void
{
if(isset($timeLeft)) {
$this->timeLeft = $timeLeft;
$this->timeLeft = max(0, $timeLeft);
}
}

View File

@ -51,7 +51,7 @@ TODO: condition!
<label id="timeLimitLabel" for="timerEnabled">Time limit measured in seconds</label>
</div>
<div>
<input type="range" id="timeLimit" name="timeLimit" min="10" max="600" value="120" />
<input type="range" id="timeLimit" name="timeLimit" min="10" max="1800" step="10" value="300" />
</div>
<div id="timeLimitType">
Time limit