Compare commits

...
8 changed files with 30 additions and 46 deletions

No files matched your search

+7 -3
View File
@@ -31,11 +31,11 @@ main {
color: #ffffff; color: #ffffff;
} }
p, h1, h2, input, textarea, select, button, a, table { p, h1, h2, h3, input, textarea, select, button, a, table, label {
font-family: 'Roboto', sans-serif; font-family: 'Roboto', sans-serif;
} }
h1, h2 { h1, h2, h3 {
font-weight: 500; font-weight: 500;
} }
@@ -55,7 +55,11 @@ h2, header.small h1 {
font-size: 24px; font-size: 24px;
} }
p, h2 { h3 {
font-size: 18px;
}
p, h2, h3 {
line-height: 150%; line-height: 150%;
} }
-10
View File
@@ -75,16 +75,6 @@ div.mapItem>div.buttonContainer {
grid-auto-flow: column; grid-auto-flow: column;
} }
#restrictions {
margin-top: 1em;
margin-bottom: 1em;
font-family: 'Roboto', sans-serif;
}
#restrictions h3 {
font-weight: 500;
}
#restrictions input { #restrictions input {
height: auto; height: auto;
margin: 0.5em; margin: 0.5em;
+14 -13
View File
@@ -21,7 +21,6 @@ const GameType = Object.freeze({ 'SINGLE': 0, 'MULTI': 1, 'CHALLENGE': 2 });
googleLink: null, googleLink: null,
history: [], history: [],
restrictions: null, restrictions: null,
finishers: null,
readyToContinue: true, readyToContinue: true,
timeoutEnd: null, timeoutEnd: null,
@@ -348,8 +347,6 @@ const GameType = Object.freeze({ 'SINGLE': 0, 'MULTI': 1, 'CHALLENGE': 2 });
return; return;
} }
var restrictionsForDisplay = []; var restrictionsForDisplay = [];
if (Game.restrictions.timeLimit) { if (Game.restrictions.timeLimit) {
restrictionsForDisplay.push('time limit per ' + Game.restrictions.timeLimitType); restrictionsForDisplay.push('time limit per ' + Game.restrictions.timeLimitType);
@@ -366,6 +363,10 @@ const GameType = Object.freeze({ 'SINGLE': 0, 'MULTI': 1, 'CHALLENGE': 2 });
} }
} }
if (restrictionsForDisplay.length == 0) {
return;
}
// create restrictions span for header // create restrictions span for header
var restrictions = document.createElement('span'); var restrictions = document.createElement('span');
restrictions.setAttribute('id', 'restrictions'); restrictions.setAttribute('id', 'restrictions');
@@ -486,10 +487,6 @@ const GameType = Object.freeze({ 'SINGLE': 0, 'MULTI': 1, 'CHALLENGE': 2 });
} }
} }
} }
if (response.finishers) {
Game.finishers = new Set(response.finishers);
}
}, },
reset: function () { reset: function () {
@@ -542,7 +539,6 @@ const GameType = Object.freeze({ 'SINGLE': 0, 'MULTI': 1, 'CHALLENGE': 2 });
document.getElementById('panningBlockerCover').style.display = null; document.getElementById('panningBlockerCover').style.display = null;
Game.history = []; Game.history = [];
Game.finishers = null;
Game.initialize(); Game.initialize();
}, },
@@ -871,16 +867,21 @@ const GameType = Object.freeze({ 'SINGLE': 0, 'MULTI': 1, 'CHALLENGE': 2 });
var highscores = new Map(); var highscores = new Map();
highscores.set('me', Game.scoreSum); highscores.set('me', Game.scoreSum);
for (var i = 0; i < Game.history.length; ++i) { // collect the results of users who are through the last round
const round = Game.history[Game.history.length - 1];
if (round.allResults) {
for (const result of round.allResults) {
highscores.set(result.userName, result.score);
}
}
// add up scores only for the finishers
for (var i = Game.history.length - 2; i >= 0; --i) {
const round = Game.history[i]; const round = Game.history[i];
if (round.allResults) { if (round.allResults) {
for (const result of round.allResults) { for (const result of round.allResults) {
if (Game.finishers.has(result.userName)) {
if (highscores.has(result.userName)) { if (highscores.has(result.userName)) {
highscores.set(result.userName, highscores.get(result.userName) + result.score); highscores.set(result.userName, highscores.get(result.userName) + result.score);
} else {
highscores.set(result.userName, result.score);
}
} }
} }
} }
+4 -5
View File
@@ -112,11 +112,10 @@ class GameController implements ISecured
public function createNewChallenge(): IContent public function createNewChallenge(): IContent
{ {
// create Challenge // create Challenge
$challengeToken = rand(); do {
while ($this->challengeRepository->getByToken($challengeToken)) { // initiliaze or if a challenge with the same token already exists
// if a challenge with the same token already exists $challengeToken = mt_rand();
$challengeToken = rand(); } while ($this->challengeRepository->getByToken($challengeToken));
}
$challenge = new Challenge(); $challenge = new Challenge();
$challenge->setToken($challengeToken); $challenge->setToken($challengeToken);
-8
View File
@@ -199,14 +199,6 @@ class GameFlowController implements ISecured
if (!isset($currentPlace)) { // game finished if (!isset($currentPlace)) { // game finished
$response['finished'] = true; $response['finished'] = true;
// list all players who finished the challenge
$response['finishers'] = [];
foreach ($this->userInChallengeRepository->getAllByChallengeWithUsers($challenge) as $userInChallenge) {
if ($userInChallenge->getCurrentRound() == $currentRound && $userInChallenge->getUser()->getId() != $userId) {
$response['finishers'][] = $userInChallenge->getUser()->getDisplayName();
}
}
} else { // continue game } else { // continue game
$response['place'] = [ $response['place'] = [
'panoId' => $currentPlace->getPanoIdCached(), 'panoId' => $currentPlace->getPanoIdCached(),
+1 -3
View File
@@ -57,11 +57,9 @@ class UserInChallengeRepository
} }
// validate token string // validate token string
foreach (str_split($token_str) as $char) { if (!ctype_xdigit($token_str)) {
if (!(('0' <= $char && $char <= '9') || ('a' <= $char && $char <= 'f'))) {
return null; return null;
} }
}
// convert token to int // convert token to int
$token = hexdec($token_str); $token = hexdec($token_str);
+1 -1
View File
@@ -30,7 +30,7 @@
@section(subheader) @section(subheader)
<span id="mapName" class="bold">Loading map...</span><!-- <span id="mapName" class="bold">Loading map...</span><!--
--><span>Round <span id="currentRound" class="bold"></span></span><!-- --><span id="roundContainer">Round <span id="currentRound" class="bold"></span></span><!--
--><span>Score <span id="currentScoreSum" class="bold"></span></span> --><span>Score <span id="currentScoreSum" class="bold"></span></span>
@endsection @endsection
+3 -3
View File
@@ -43,7 +43,7 @@ TODO: condition!
<p class="bold center marginTop marginBottom">OR</p> <p class="bold center marginTop marginBottom">OR</p>
--> -->
<div id="restrictions"> <div id="restrictions" class="marginTop marginBottom">
<h3>Optional restrictions</h3> <h3>Optional restrictions</h3>
<div> <div>
<div> <div>
@@ -54,7 +54,7 @@ TODO: condition!
<input type="range" id="timeLimit" name="timeLimit" min="10" max="1800" step="10" value="300" /> <input type="range" id="timeLimit" name="timeLimit" min="10" max="1800" step="10" value="300" />
</div> </div>
<div id="timeLimitType"> <div id="timeLimitType">
Time limit <label>Time limit</label>
<input type="radio" id="timeLimitTypeGame" name="timeLimitType" value="game" checked /> <input type="radio" id="timeLimitTypeGame" name="timeLimitType" value="game" checked />
<label for="timeLimitTypeGame">for the whole game</label> <label for="timeLimitTypeGame">for the whole game</label>
<input type="radio" id="timeLimitTypeRound" name="timeLimitType" value="round" /> <input type="radio" id="timeLimitTypeRound" name="timeLimitType" value="round" />
@@ -67,7 +67,7 @@ TODO: condition!
</div> </div>
<div> <div>
<input type="checkbox" id="noZoom" name="noZoom" value="noZoom" /> <input type="checkbox" id="noZoom" name="noZoom" value="noZoom" />
<label for="noMove">No zoom allowed</label> <label for="noZoom">No zoom allowed</label>
</div> </div>
<div> <div>
<input type="checkbox" id="noPan" name="noPan" value="noPan" /> <input type="checkbox" id="noPan" name="noPan" value="noPan" />