]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/Round.php
simple result hiding on initial tournament request
[alttp.git] / app / Models / Round.php
index 3c191bc17efb200d65b1263371dec4599d93b508..18be60fe015d346a085a416e4990aee3458c7447 100644 (file)
@@ -10,6 +10,16 @@ class Round extends Model
        use HasFactory;
 
 
+       public function isComplete() {
+               if (count($this->tournament->participants) == 0) return false;
+               if (count($this->results) == 0) return false;
+               foreach ($this->tournament->getRunners() as $participant) {
+                       $result = $participant->findResult($this);
+                       if (!$result || !$result->has_finished) return false;
+               }
+               return true;
+       }
+
        public function updatePlacement() {
                $runners = [];
                foreach ($this->tournament->participants as $p) {
@@ -53,6 +63,13 @@ class Round extends Model
        }
 
 
+       public function hideResults() {
+               foreach ($this->results as $result) {
+                       $result->makeHidden(['forfeit', 'placement', 'score', 'time']);
+               }
+       }
+
+
        public function results() {
                return $this->hasMany(Result::class);
        }