/**
  * @param Tournament $tournament
  * @return TournamentDrawInterface
  * @throws TournamentIncorrectTypeException
  */
 public function create(Tournament $tournament) : TournamentDrawInterface
 {
     switch ($tournament->getTournamentParams()->getType()) {
         case TournamentType::ROUND_ROBIN():
             return $this->container->get("core.service.round_robin");
         case TournamentType::SWITZ():
             return $this->container->get("core.service.swiss");
         default:
             throw new TournamentIncorrectTypeException();
     }
 }
예제 #2
0
 /**
  * @param Tournament $tournament
  */
 private function changeTournamentTypeOnSwiss(Tournament $tournament)
 {
     $tournamentParams = TournamentParamsFactory::create(TournamentType::SWITZ())->setTimeBegin($tournament->getTournamentParams()->getTimeBegin());
     $tournament->setTournamentParams($tournamentParams)->setRounds($this->container->getParameter("rounds_for_swiss"));
     $this->getManager()->persist($tournament);
     $this->getManager()->flush();
 }
예제 #3
0
 /**
  * @param Tournament $tournament
  */
 public function calculateRounds(Tournament $tournament)
 {
     if ($tournament->getRounds() != 0) {
         return;
     }
     $countPlayers = count($tournament->getPlayers());
     $tournament->setRounds($tournament->getTournamentParams()->getGamesVsOpponent() * ($countPlayers % 2 === 0 ? $countPlayers - 1 : $countPlayers));
 }