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
2 changed files with 18 additions and 1 deletions
Showing only changes of commit 2a1b51b014 - Show all commits

View File

@ -2,6 +2,7 @@ CREATE TABLE `challenges` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`token` int(10) unsigned NOT NULL, `token` int(10) unsigned NOT NULL,
`time_limit` int(10) unsigned, `time_limit` int(10) unsigned,
`time_limit_type` enum('game', 'round') NOT NULL DEFAULT 'game',
`no_move` tinyint(1) NOT NULL DEFAULT 0, `no_move` tinyint(1) NOT NULL DEFAULT 0,
`no_pan` tinyint(1) NOT NULL DEFAULT 0, `no_pan` tinyint(1) NOT NULL DEFAULT 0,
`no_zoom` tinyint(1) NOT NULL DEFAULT 0, `no_zoom` tinyint(1) NOT NULL DEFAULT 0,

View File

@ -6,7 +6,7 @@ class Challenge extends Model
{ {
protected static string $table = 'challenges'; protected static string $table = 'challenges';
protected static array $fields = ['token', 'time_limit', 'no_move', 'no_pan', 'no_zoom', 'created']; protected static array $fields = ['token', 'time_limit', 'time_limit_type', 'no_move', 'no_pan', 'no_zoom', 'created'];
protected static array $relations = []; protected static array $relations = [];
@ -14,6 +14,10 @@ class Challenge extends Model
private ?int $timeLimit = null; private ?int $timeLimit = null;
private static array $timeLimitTypes = ['game', 'round'];
private string $timeLimitType = 'game';
private bool $noMove = false; private bool $noMove = false;
private bool $noPan = false; private bool $noPan = false;
@ -34,6 +38,13 @@ class Challenge extends Model
} }
} }
public function setTimeLimitType(string $timeLimitType): void
{
if (in_array($timeLimitType, self::$timeLimitTypes)) {
$this->timeLimitType = $timeLimitType;
}
}
public function setNoMove(bool $noMove): void public function setNoMove(bool $noMove): void
{ {
$this->$noMove = $noMove; $this->$noMove = $noMove;
@ -69,6 +80,11 @@ class Challenge extends Model
return $this->timeLimit; return $this->timeLimit;
} }
public function getTimeLimitType(): string
{
return $this->timeLimitType;
}
public function getNoMove(): bool public function getNoMove(): bool
{ {
return $this->noMove; return $this->noMove;