Esempio n. 1
0
 /**
  * Plan tournament schedule
  * Schedule is saved in match planning tables
  * @param Tournament $tournament
  * @param $level
  * @return array
  */
 public function planTournamentByStep(Tournament $tournament, $level)
 {
     $planningCard = array();
     switch ($level) {
         case 0:
             $this->logic->removeMatchSchedules($tournament);
             $this->logic->removeQMatchSchedules($tournament);
             $planningCard['level'] = 10;
             break;
         case 10:
             $options = new PlanningOptions();
             $options->setDoublematch($tournament->getOption()->isDrr());
             $options->setPreferpg($tournament->getOption()->isSvd());
             $options->setFinals(false);
             $matchList = (new MatchBuilder())->populate($tournament, $options);
             $result = (new MatchUtil($this->em))->setupCriteria($tournament, $matchList, $options);
             (new MatchPlanner($this->logger))->plan($result);
             (new MatchUtil($this->em))->savePlan($tournament, $result);
             $planningCard['preliminary'] = $result;
             if ($tournament->getOption()->isEr()) {
                 $planningCard['level'] = 70;
             } else {
                 $planningCard['level'] = 100;
             }
             break;
         case 70:
             $options = new PlanningOptions();
             $options->setDoublematch($tournament->getOption()->isDrr());
             $options->setPreferpg($tournament->getOption()->isSvd());
             $options->setFinals(true);
             $matchListF = (new QMatchBuilder())->populate($tournament);
             $resultF = (new MatchUtil($this->em))->setupCriteria($tournament, $matchListF, $options);
             (new QMatchPlanner($this->logger))->plan($resultF);
             (new MatchUtil($this->em))->savePlan($tournament, $resultF);
             $planningCard['elimination'] = $resultF;
             $planningCard['level'] = 100;
             break;
     }
     return $planningCard;
 }
 /**
  * Plan matches according to assigned groups and match configuration
  * @Route("/edit/m/plan/plan/{tournamentid}", name="_edit_match_planning_plan")
  * @Template("ICupPublicSiteBundle:Edit:planmatch.html.twig")
  */
 public function planMatchesAction($tournamentid)
 {
     $tournament = $this->checkArgs($tournamentid);
     $options = new PlanningOptions();
     $options->setDoublematch($tournament->getOption()->isDrr());
     $options->setPreferpg(false);
     $this->get('planning')->planTournament($tournament, $options);
     return $this->redirect($this->generateUrl("_edit_match_planning_result", array('tournamentid' => $tournament->getId())));
 }
 public function tstMatchPlanningOutput()
 {
     $options = new PlanningOptions();
     $options->setDoublematch(false);
     $options->setPreferpg(false);
     $this->container->get("planning")->planTournamentPre($this->tournament, $options);
     $match_schedule = $this->container->get("planning")->getSchedule($this->tournament);
     /* @var $match MatchPlan */
     foreach ($match_schedule["matches"] as $match) {
         echo $match->getDate();
         echo "  ";
         echo $match->getTime();
         echo "  ";
         echo $match->getCategory()->getName() . "|" . $match->getGroup()->getName() . ":" . $match->getPlayground()->getName();
         echo "  ";
         echo $match->getTeamA();
         echo " - ";
         echo $match->getTeamB();
         echo "\n";
     }
     $teams = array();
     /* @var $match MatchPlan */
     foreach ($match_schedule["matches"] as $match) {
         $teams[$match->getTeamA()->getId()][] = $match;
         $teams[$match->getTeamB()->getId()][] = $match;
     }
     /*
             foreach ($match_schedule["unassigned"] as $match) {
                 $teams[$match->getTeamA()->getId()][] = $match;
                 $teams[$match->getTeamB()->getId()][] = $match;
             }
     */
     foreach ($teams as $team_matches) {
         foreach ($team_matches as $match) {
             echo $match->getDate();
             echo "  ";
             echo $match->getTime();
             echo "  ";
             echo $match->getCategory()->getName() . "|" . $match->getGroup()->getName() . ":" . $match->getPlayground()->getName();
             echo "  ";
             echo $match->getTeamA();
             echo " - ";
             echo $match->getTeamB();
             echo "\n";
         }
         echo "\n";
     }
 }