Esempio n. 1
0
 /**
  * @param $tournoi Tournoi
  */
 public static function generateCalendar($tournoi)
 {
     $calendrier = new Calendrier($tournoi);
     $arbres = array();
     foreach ($tournoi->getCompetitions() as $competition) {
         array_push($arbres, $competition->getTree());
     }
     $Tree = $TreeForMatchs = self::getTreeForMatchs($arbres);
     $creneaux = $tournoi->getHoraires();
     foreach ($TreeForMatchs as $step) {
         while (count($step) != 0) {
             foreach ($creneaux as $horaire) {
                 foreach ($tournoi->getTerrains() as $terrain) {
                     $matchCanBeDone = false;
                     $try = 0;
                     while (!($matchCanBeDone = self::MatchCanBeDone($calendrier->getMatchs(), $match = new Match($terrain, new creneau($horaire[0], $horaire[1]), $step[0])) || $try > 25)) {
                         array_push($step, $step[0]);
                         unset($step[0]);
                         $try++;
                     }
                     $calendrier->addMatch($match);
                 }
                 unset($step[0]);
             }
         }
     }
 }