feature/MAPG-235-basic-challenge-mode #48
@ -84,7 +84,7 @@ div.mapItem>div.buttonContainer {
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
#restrictions input[type=checkbox] {
|
#restrictions input {
|
||||||
height: auto;
|
height: auto;
|
||||||
margin: 0.5em;
|
margin: 0.5em;
|
||||||
}
|
}
|
||||||
@ -94,6 +94,10 @@ div.mapItem>div.buttonContainer {
|
|||||||
margin-left: 2em;
|
margin-left: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#timeLimitType {
|
||||||
|
margin-left: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 1504px) {
|
@media screen and (min-width: 1504px) {
|
||||||
#mapContainer {
|
#mapContainer {
|
||||||
grid-template-columns: auto auto auto auto;
|
grid-template-columns: auto auto auto auto;
|
||||||
|
@ -115,6 +115,9 @@ class GameController
|
|||||||
if ($this->request->post('timerEnabled') !== null && $this->request->post('timeLimit') !== null) {
|
if ($this->request->post('timerEnabled') !== null && $this->request->post('timeLimit') !== null) {
|
||||||
balazs marked this conversation as resolved
Outdated
|
|||||||
$challenge->setTimeLimit($this->request->post('timeLimit'));
|
$challenge->setTimeLimit($this->request->post('timeLimit'));
|
||||||
}
|
}
|
||||||
|
if ($this->request->post('timeLimitType') !== null) {
|
||||||
bence
commented
I think rand() should be called with explicit arguments, otherwise a number is returned between 0 and getrandmax() and getrandmax() is platform-dependent. On the other hand maybe the token could be generated as the room ID for multiplayer. Then a fixed length string would be generated - I used bin2hex(random_bytes(3)) for room ID. I guess it was intentional to use integer indexes in the DB, it could be be more efficient but I already used string indexes for other purpose. I think rand() should be called with explicit arguments, otherwise a number is returned between 0 and getrandmax() and getrandmax() is platform-dependent.
On the other hand maybe the token could be generated as the room ID for multiplayer. Then a fixed length string would be generated - I used bin2hex(random_bytes(3)) for room ID. I guess it was intentional to use integer indexes in the DB, it could be be more efficient but I already used string indexes for other purpose.
balazs
commented
Good point. However I don't think it would cause any problems. I thought it would be better to use 4 byte length integers instead of 3 bytes for more possible ids, because challenges are normally not getting deleted. Good point. However I don't think it would cause any problems. I thought it would be better to use 4 byte length integers instead of 3 bytes for more possible ids, because challenges are normally not getting deleted.
balazs
commented
I've read your comment again, and I see that bin2hex returns a string. Yes I thought it would perform better just to use an integer instead. I've read your comment again, and I see that bin2hex returns a string. Yes I thought it would perform better just to use an integer instead.
I can also see now, that on Windows the getrandmax() is only 32767, which is far too small. I am going to replace it with mt_rand() if that's fine for you.
|
|||||||
|
$challenge->setTimeLimitType($this->request->post('timeLimitType'));
|
||||||
|
}
|
||||||
if ($this->request->post('noMove') !== null) {
|
if ($this->request->post('noMove') !== null) {
|
||||||
$challenge->setNoMove(true);
|
$challenge->setNoMove(true);
|
||||||
}
|
}
|
||||||
|
@ -47,17 +47,17 @@ class Challenge extends Model
|
|||||||
|
|
||||||
public function setNoMove(bool $noMove): void
|
public function setNoMove(bool $noMove): void
|
||||||
{
|
{
|
||||||
$this->$noMove = $noMove;
|
$this->noMove = $noMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setNoPan(bool $noPan): void
|
public function setNoPan(bool $noPan): void
|
||||||
{
|
{
|
||||||
$this->$noPan = $noPan;
|
$this->noPan = $noPan;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setNoZoom(bool $noZoom): void
|
public function setNoZoom(bool $noZoom): void
|
||||||
{
|
{
|
||||||
$this->$noZoom = $noZoom;
|
$this->noZoom = $noZoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCreatedDate(DateTime $created): void
|
public function setCreatedDate(DateTime $created): void
|
||||||
|
@ -53,6 +53,13 @@ TODO: condition!
|
|||||||
<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="600" value="120" />
|
||||||
</div>
|
</div>
|
||||||
|
<div id="timeLimitType">
|
||||||
|
Time limit
|
||||||
|
<input type="radio" id="timeLimitTypeGame" name="timeLimitType" value="game" checked />
|
||||||
|
<label for="timeLimitTypeGame">for the whole game</label>
|
||||||
|
<input type="radio" id="timeLimitTypeRound" name="timeLimitType" value="round" />
|
||||||
|
<label for="timeLimitTypeRound">per round</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<input type="checkbox" id="noMove" name="noMove" value="noMove" />
|
<input type="checkbox" id="noMove" name="noMove" value="noMove" />
|
||||||
|
Maybe a do..while would be better here because the token calculation should not be repeated.
My eye is twitching when variables are used outside of the scope of {}, but it's different in PHP, so it can be refactored.