/**
  * Add a Pool to the Phase
  *
  * @Route("/{id}/new")
  * @param Phase $phase
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function newAction(Phase $phase)
 {
     $pool = new Pool();
     $pool->setName("Groupe " . (count($phase->getPools()) + 1));
     $phase->addPool($pool);
     $em = $this->getDoctrine()->getManager();
     $em->flush();
     return $this->redirect($this->generateUrl('abienvenu_kyjoukan_phase_index', ['slug_event' => $phase->getEvent()->getSlug(), 'slug' => $phase->getSlug()]) . "#pools");
 }
Exemple #2
0
 public function checkPhaseTeams(Phase $phase)
 {
     $errors = [];
     if (count($phase->getTeams())) {
         foreach ($phase->getEvent()->getTeams() as $team) {
             if (!$phase->hasTeam($team)) {
                 $errors[] = "L'équipe {$team->getName()} est exclue de cette phase";
             }
         }
     } else {
         $errors[] = "Aucune équipe n'est chargée dans cette phase. Utilisez le bouton \"Chargez les équipes de l'évènement\" pour recopier toutes les équipes de l'évènement dans cette phase";
     }
     return $errors;
 }
 /**
  * Shuffle games into the phase
  *
  * @Route("/shuffle")
  * @param Phase $phase
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function shuffleAction(Phase $phase)
 {
     if (!count($phase->getEvent()->getGrounds())) {
         $this->addFlash('danger', "Impossible de programmer, veuillez d'abord ajouter des terrains!");
     } else {
         if (!count($phase->getPools())) {
             $this->addFlash('danger', "Impossible de programmer, veuillez d'abord ajouter des groupes!");
         } else {
             $this->get('kyjoukan.dispatcher')->shuffleGames($phase);
             $this->addFlash('success', "Les matchs sont programmés.");
         }
     }
     return $this->redirect($this->generateUrl("abienvenu_kyjoukan_phase_index", ['slug_event' => $phase->getEvent()->getSlug(), 'slug' => $phase->getSlug()]) . "#games");
 }
 /**
  * Dispatch games according to the brackets rule
  * @param Phase $phase
  */
 protected function dispatchBracketGames(Phase $phase)
 {
     $eventGrounds = $phase->getEvent()->getGrounds();
     do {
         $areWeDone = true;
         foreach ($phase->getPools() as $pool) {
             $game = $this->getNextBracketGame($pool->getGames()->toArray(), $pool->getTeams()->toArray());
             if ($game) {
                 $newGame = $this->nextGameSlot($phase, $eventGrounds);
                 $newGame->setTeam1($game->getTeam1());
                 $newGame->setTeam2($game->getTeam2());
                 $pool->addGame($newGame);
                 $areWeDone = false;
             }
         }
     } while (!$areWeDone);
 }