Ejemplo n.º 1
0
 /**
  * @param Tournament $tournament
  * @param $matchList
  * @param PlanningOptions $options
  * @return PlanningResults
  */
 public function setupCriteria(Tournament $tournament, $matchList, PlanningOptions $options)
 {
     $result = new PlanningResults();
     /* @var $timeslot Timeslot */
     foreach ($tournament->getTimeslots()->toArray() as $timeslot) {
         /* @var $pattr PlaygroundAttribute */
         foreach ($timeslot->getPlaygroundattributes()->toArray() as $pattr) {
             if ($pattr->getFinals() == $options->isFinals()) {
                 $pa = new PA();
                 $pa->setPA($pattr);
                 $pa->setId($pattr->getId());
                 $pa->setPlayground($pattr->getPlayground());
                 $pa->setTimeslot($pattr->getTimeslot());
                 $pa->setSchedule($pattr->getStartSchedule());
                 $categories = array();
                 foreach ($pattr->getCategories() as $category) {
                     $categories[$category->getId()] = $category;
                 }
                 $pa->setCategories($categories);
                 $pa->setMatchlist(array());
                 $result->addTimeslot($pa);
             }
         }
     }
     if ($options->isFinals()) {
         // Order the match plan by classification ascending
         usort($matchList, function (QMatchPlan $m1, QMatchPlan $m2) {
             return min(1, max(-1, $m1->getClassification() - $m2->getClassification()));
         });
     } else {
         // Order the match plan by group ascending
         usort($matchList, function (MatchPlan $m1, MatchPlan $m2) {
             return min(1, max(-1, $m1->getGroup()->getId() - $m2->getGroup()->getId()));
         });
     }
     foreach ($matchList as $match) {
         $result->appendUnresolved($match);
     }
     return $result;
 }
Ejemplo n.º 2
0
 private function makeTimeslotTable(Tournament $tournament)
 {
     $ts = array();
     $pattrs = array();
     $tournament->getTimeslots()->forAll(function ($idx, Timeslot $timeslot) use(&$pattrs) {
         $pattrs = array_merge($pattrs, $timeslot->getPlaygroundattributes()->toArray());
         return true;
     });
     /* @var $pattr PlaygroundAttribute */
     foreach ($pattrs as $pattr) {
         $pa = new PA();
         $pa->setPA($pattr);
         $pa->setId($pattr->getId());
         $pa->setPlayground($pattr->getPlayground());
         $pa->setTimeslot($pattr->getTimeslot());
         $pa->setSchedule($pattr->getStartSchedule());
         $categories = array();
         foreach ($pattr->getCategories() as $category) {
             $categories[$category->getId()] = $category;
         }
         $pa->setCategories($categories);
         $pa->setMatchlist(array());
         $ts[$pattr->getId()] = $pa;
     }
     return $ts;
 }