diff --git a/database/migrations/structure/20210510_2000_challenge.sql b/database/migrations/structure/20210510_2000_challenge.sql index 810d849..a5c4941 100644 --- a/database/migrations/structure/20210510_2000_challenge.sql +++ b/database/migrations/structure/20210510_2000_challenge.sql @@ -2,6 +2,7 @@ CREATE TABLE `challenges` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `token` int(10) unsigned NOT NULL, `time_limit` int(10) unsigned, + `time_limit_type` enum('game', 'round') NOT NULL DEFAULT 'game', `no_move` tinyint(1) NOT NULL DEFAULT 0, `no_pan` tinyint(1) NOT NULL DEFAULT 0, `no_zoom` tinyint(1) NOT NULL DEFAULT 0, diff --git a/src/PersistentData/Model/Challenge.php b/src/PersistentData/Model/Challenge.php index d947ae8..a484fe3 100644 --- a/src/PersistentData/Model/Challenge.php +++ b/src/PersistentData/Model/Challenge.php @@ -6,7 +6,7 @@ class Challenge extends Model { 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 = []; @@ -14,6 +14,10 @@ class Challenge extends Model private ?int $timeLimit = null; + private static array $timeLimitTypes = ['game', 'round']; + + private string $timeLimitType = 'game'; + private bool $noMove = 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 { $this->$noMove = $noMove; @@ -69,6 +80,11 @@ class Challenge extends Model return $this->timeLimit; } + public function getTimeLimitType(): string + { + return $this->timeLimitType; + } + public function getNoMove(): bool { return $this->noMove;