/**
  * Build list of matches (elimination rounds) for tournament
  * @param Tournament $tournament
  * @return array
  */
 public function populate(Tournament $tournament)
 {
     $matchPlanList = array();
     /* @var $category Category */
     foreach ($tournament->getCategories() as $category) {
         $matches = array();
         switch ($category->getStrategy()) {
             case 0:
                 $matches = $this->populateAB($category);
                 break;
             case 1:
                 $matches = $this->populateType1($category);
                 break;
             case 2:
                 $matches = $this->populateType2($category);
                 break;
             case 3:
                 $matches = $this->populateType3($category);
                 break;
         }
         /* @var $match QMatchPlan */
         foreach ($matches as $match) {
             $match->setCategory($category);
             $matchPlanList[] = $match;
         }
     }
     return $matchPlanList;
 }
Example #2
0
 /**
  * Build list of matches (preliminary rounds) for tournament
  * @param Tournament $tournament
  * @param PlanningOptions $options
  * @return array
  */
 public function populate(Tournament $tournament, PlanningOptions $options)
 {
     $matchPlanList = array();
     /* @var Category $category */
     foreach ($tournament->getCategories() as $category) {
         /* @var $group Group */
         foreach ($category->getGroupsClassified(Group::$PRE) as $group) {
             $matches = $this->populateGroup($group, $options);
             /* @var $match MatchPlan */
             foreach ($matches as $match) {
                 $match->setCategory($category);
                 $match->setGroup($group);
                 $matchPlanList[] = $match;
             }
         }
     }
     return $matchPlanList;
 }
 private function makeResultForm(Tournament $tournament)
 {
     $categories = array();
     foreach ($tournament->getCategories() as $category) {
         $categories[$category->getId()] = $this->get('translator')->trans('CATEGORY', array(), 'tournament') . " " . $category->getName() . " - " . $this->get('translator')->transChoice('GENDER.' . $category->getGender() . $category->getClassification(), $category->getAge(), array('%age%' => $category->getAge()), 'tournament');
     }
     $playgroundList = $this->get('logic')->listPlaygroundsByTournament($tournament->getId());
     $playgrounds = array();
     foreach ($playgroundList as $playground) {
         $playgrounds[$playground->getId()] = $playground->getName();
     }
     $formDef = $this->createFormBuilder();
     $formDef->add('matchno', 'text', array('label' => 'FORM.MATCHPLANNING.MATCHNO', 'required' => false, 'help' => 'FORM.MATCHPLANNING.HELP.MATCHNO', 'icon' => 'fa fa-lg fa-tag', 'translation_domain' => 'admin'));
     $formDef->add('date', 'text', array('label' => 'FORM.MATCHPLANNING.DATE', 'required' => false, 'help' => 'FORM.MATCHPLANNING.HELP.DATE', 'icon' => 'fa fa-lg fa-calendar', 'translation_domain' => 'admin'));
     $formDef->add('category', 'choice', array('label' => 'FORM.MATCHPLANNING.CATEGORY', 'choices' => $categories, 'empty_value' => 'FORM.MATCHPLANNING.DEFAULT', 'required' => false, 'help' => 'FORM.MATCHPLANNING.HELP.CATEGORY', 'icon' => 'fa fa-lg fa-sitemap', 'translation_domain' => 'admin'));
     $formDef->add('group', 'choice', array('label' => 'FORM.MATCHPLANNING.GROUP', 'choices' => array(), 'empty_value' => 'FORM.MATCHPLANNING.DEFAULT', 'required' => false, 'help' => 'FORM.MATCHPLANNING.HELP.GROUP', 'icon' => 'fa fa-lg fa-bookmark', 'translation_domain' => 'admin'));
     $formDef->add('playground', 'choice', array('label' => 'FORM.MATCHPLANNING.PLAYGROUND', 'choices' => $playgrounds, 'empty_value' => 'FORM.MATCHPLANNING.DEFAULT', 'required' => false, 'help' => 'FORM.MATCHPLANNING.HELP.PLAYGROUND', 'icon' => 'fa fa-lg fa-futbol-o', 'translation_domain' => 'admin'));
     return $formDef->getForm();
 }
 public function listChampionsByTournament(Tournament $tournament)
 {
     $sortedGroups = array();
     $teams = array();
     /* @var $category Category */
     foreach ($tournament->getCategories() as $category) {
         /* @var $champion Champion */
         foreach ($category->getChampions() as $champion) {
             $groupid = $champion->getGroup()->getId();
             if (!isset($sortedGroups[$groupid])) {
                 $sortedGroups[$groupid] = $this->container->get('orderTeams')->sortCompletedGroup($groupid);
             }
             $rankedTeams = $sortedGroups[$groupid];
             if ($rankedTeams && isset($rankedTeams[$champion->getRank() - 1])) {
                 $team = $this->entity->getTeamById($rankedTeams[$champion->getRank() - 1]->getId());
                 $teams[$category->getId()][$champion->getChampion()] = $team;
             }
         }
     }
     return $teams;
 }
Example #5
0
 public function makeTeams(Tournament $tournament)
 {
     $testclubs = array(array("YOSLIK TASHKENT", "UZB"), array("B. URDULIZ", "ESP"), array("ATHENS 2015", "GRC"), array("N.H.C. TERAMO", "ITA"), array("GLADSAXE HG", "DNK"), array("UKS SPARTACUS", "POL"), array("TSINGHUA UNIV.", "CHN"), array("E.C. PINHEIROS", "BRA"), array("ZAGLEBIE LUBIN", "POL"), array("ASD FLAVIONI", "ITA"), array("SALASPILS SS", "LVA"), array("JSG ECHAZ ERMS", "DEU"), array("BRASIL REAL", "BRA"), array("HC MELITA", "MLT"), array("POGON ZABRIZE", "POL"), array("HC DUNAV BELENE", "BGR"), array("DTJ POLANKA", "CZE"), array("XINZHUANG JHS", "CHN"), array("ESBF", "FRA"), array("FALK", "NOR"), array("C.C. ANSIAO", "PRT"), array("ETIEC MENDOZA", "ARG"), array("VIKINGUR", "ISL"));
     $clubs = array();
     foreach ($testclubs as $clubinfo) {
         $club = new Club();
         $club->setName($clubinfo[0]);
         $club->setCountry($clubinfo[1]);
         $this->em->persist($club);
         $clubs[] = $club;
     }
     /* @var $user User */
     $user = $tournament->getHost()->getEditors()->first();
     /* @var $category Category */
     foreach ($tournament->getCategories() as $category) {
         $clubDiv = array_shift($clubs);
         /* @var $group Group */
         foreach ($category->getGroupsClassified(Group::$PRE) as $group) {
             for ($n = 1; $n <= 5; $n++) {
                 /* @var $club Club */
                 $club = array_shift($clubs);
                 $this->addTeam($category, $group, $club, "", $user);
                 array_push($clubs, $club);
             }
             $this->addTeam($category, $group, $clubDiv, $group->getName(), $user);
         }
         array_push($clubs, $clubDiv);
     }
     $this->em->flush();
 }
 private function importCategories(Tournament $source_tournament, Tournament $tournament)
 {
     $em = $this->getDoctrine()->getManager();
     $cconversion = array();
     /* @var $category Category */
     foreach ($source_tournament->getCategories() as $category) {
         $new_category = new Category();
         $new_category->setTournament($tournament);
         $new_category->setName($category->getName());
         $new_category->setGender($category->getGender());
         $new_category->setClassification($category->getClassification());
         $new_category->setAge($category->getAge());
         $new_category->setMatchtime($category->getMatchtime());
         $em->persist($new_category);
         $cconversion[$category->getId()] = $new_category;
         foreach ($category->getGroups() as $group) {
             $new_group = new Group();
             $new_group->setCategory($new_category);
             $new_group->setName($group->getName());
             $new_group->setClassification($group->getClassification());
             $em->persist($new_group);
         }
     }
     $em->flush();
     return $cconversion;
 }
 private function listEnrolled(Tournament $tmnt, Club $club)
 {
     $host = $tmnt->getHost();
     $enrolled = $this->get('logic')->listEnrolledByClub($tmnt->getId(), $club->getId());
     $enrolledList = array();
     /* @var $enroll Enrollment */
     foreach ($enrolled as $enroll) {
         $enrolledList[$enroll->getCategory()->getId()][] = $enroll;
     }
     $classMap = array();
     $categoryMap = array();
     /* @var $category Category */
     foreach ($tmnt->getCategories() as $category) {
         $classification = $category->getClassification() . $category->getAge();
         $classMap[$classification] = $classification;
         $cls = $category->getGender() . $classification;
         $categoryMap[$cls][] = $category;
     }
     return array('host' => $host, 'tournament' => $tmnt, 'club' => $club, 'classifications' => $classMap, 'enrolled' => $enrolledList, 'categories' => $categoryMap);
 }