/**
  * Update tournament schedule with qualified teams
  * @param $tournamentid
  * @return array
  */
 public function updateTournamentSchedule($tournamentid)
 {
     $groups = $this->map($this->logic->listGroupsByTournament($tournamentid));
     $playgrounds = $this->map($this->logic->listPlaygroundsByTournament($tournamentid));
     $settledGroups = array();
     /* @var $group Group */
     foreach ($groups as $group) {
         $settledGroups[$group->getId()] = $this->order->sortCompletedGroup($group->getId());
     }
     $matches = array();
     $matchList = $this->match->listOpenQMatchesByTournament($tournamentid);
     /* @var $qmatch QMatch */
     foreach ($matchList as $qmatch) {
         $sortedGrpA = $settledGroups[$qmatch->getGroupA()];
         $sortedGrpB = $settledGroups[$qmatch->getGroupB()];
         if ($sortedGrpA && $sortedGrpB) {
             $match = new MatchPlan();
             $match->setMatchno($qmatch->getMatchno());
             $match->setDate($qmatch->getDate());
             $match->setTime($qmatch->getTime());
             $match->setGroup($groups[$qmatch->getPid()]);
             $match->setCategory($match->getGroup()->getCategory());
             $match->setPlayground($playgrounds[$qmatch->getPlayground()]);
             $match->setTeamA($this->getTeam($sortedGrpA[$qmatch->getRankA()]));
             $match->setTeamB($this->getTeam($sortedGrpB[$qmatch->getRankB()]));
             $matches[] = array('Q' => $qmatch, 'M' => $match);
         } else {
             $matches[] = array('Q' => $qmatch, 'M' => null);
         }
     }
     return $matches;
 }
예제 #2
0
 /**
  * @param Group $group
  * @param PlanningOptions $options
  * @return array
  */
 private function populateGroup(Group $group, PlanningOptions $options)
 {
     $matches = array();
     $teams = $group->getTeams();
     $check = array();
     /* @var $teamA Team */
     foreach ($teams as $teamA) {
         $idx = 0;
         /* @var $teamB Team */
         foreach ($teams as $teamB) {
             if ($teamA->getId() != $teamB->getId() && !isset($check[$teamB->getId()])) {
                 $switch = $idx % 2 == 0 || $options->isDoublematch();
                 $match = new MatchPlan();
                 $match->setTeamA($switch ? $teamA : $teamB);
                 $match->setTeamB($switch ? $teamB : $teamA);
                 $match->setFixed(false);
                 $matches[] = $match;
                 $idx++;
             }
         }
         if (!$options->isDoublematch()) {
             $check[$teamA->getId()] = $teamA;
         }
     }
     return $matches;
 }
예제 #3
0
 private function buildMatchPlan(MatchSchedule $ms, MatchPlan $match)
 {
     $match->setGroup($ms->getGroup());
     $match->setCategory($ms->getGroup()->getCategory());
     /* @var $rel MatchScheduleRelation */
     foreach ($ms->getMatchRelations()->getValues() as $rel) {
         if ($rel->getAwayteam()) {
             $match->setTeamB($rel->getTeam());
         } else {
             $match->setTeamA($rel->getTeam());
         }
     }
 }