コード例 #1
0
ファイル: user.php プロジェクト: kleitz/brackets
 public function get_account()
 {
     $formErrors = Session::get('errors');
     $bracket = Bracket::find(Session::get('bracketId'));
     $user = Auth::user();
     return View::make('user/account', array('bracket' => $bracket, 'user' => $user, 'formErrors' => $formErrors));
 }
コード例 #2
0
ファイル: Tournament.php プロジェクト: kleitz/tournament-1
 /**
  * Organize a list of matches into the correct match order for brackets.
  *
  * @param array $matches
  * @return array
  */
 public function organizeBrackets($matches)
 {
     $participants = $this->getParticipants(array(), true);
     $rounds = array();
     foreach ($matches as $match) {
         $round = (int) $match['Match']['round'];
         if (empty($rounds[$round])) {
             $rounds[$round] = array();
         }
         $rounds[$round][] = $match['Match']['id'];
     }
     // Loop through and sort matches
     foreach ($rounds as &$r) {
         sort($r, SORT_NUMERIC);
     }
     ksort($rounds);
     $bracket = new Bracket($this->_event);
     $bracket->setMatches($matches);
     $bracket->setParticipants($participants);
     $bracket->setRounds($rounds);
     return $bracket;
 }
コード例 #3
0
ファイル: onp.php プロジェクト: rn0/php-calc
 public function __construct($value)
 {
     parent::__construct('l_bracket', $value);
 }
コード例 #4
0
 /**
  * Renvoi tout les matches en JSON
  *
  * @return Response
  */
 public function index()
 {
     $bracket = new Bracket();
     return Response::json(array('success' => true, 'payload' => $bracket->getArray()));
 }
コード例 #5
0
ファイル: bracket.php プロジェクト: kleitz/brackets
 public function post_set_match_winner($matchId)
 {
     $bracket = Bracket::find(Session::get('bracketId'));
     $match = Match::find($matchId);
     // If the bracket doesn't exist
     // redirect back on home
     if (!$bracket) {
         return Redirect::home();
     }
     if (!$match) {
         return Redirect::to('bracket/tournament');
     }
     $homeScore = Input::get('teamScoreHome');
     $awayScore = Input::get('teamScoreAway');
     if ($homeScore < 5 && $awayScore < 5) {
         return Redirect::to('bracket/tournament')->with('error', 'Neither team has a high enough score to conclude the match.');
     }
     // Create the tournament object
     $tournament = new Tournament($bracket);
     $team = $homeScore > $awayScore ? $match->teams[0] : $match->teams[1];
     // advance this team to the next round or declare them the champ.
     $tournament->advanceTeam($match, $team);
     return Redirect::to('bracket/tournament');
 }
コード例 #6
0
ファイル: RoundRobin.php プロジェクト: kleitz/tournament-1
 /**
  * Organize a list of matches into the correct match order for brackets.
  *
  * 	- Save a mapping of matches and participants for easy lookup
  * 	- Group all matches into an index of participants per pool
  *
  * @param array $matches
  * @return Bracket
  */
 public function organizeBrackets($matches)
 {
     $participants = $this->getParticipants(array(), true);
     $pools = array();
     $rounds = array();
     foreach ($matches as $match) {
         $home_id = $match['Match']['home_id'];
         $away_id = $match['Match']['away_id'];
         $round = (int) $match['Match']['round'];
         $pool = (int) $match['Match']['pool'];
         // Store match IDs into a pool and round indexed by the participant
         if (empty($pools[$pool][$round][$home_id])) {
             $pools[$pool][$round][$home_id] = array();
         }
         if (empty($pools[$pool][$round][$away_id])) {
             $pools[$pool][$round][$away_id] = array();
         }
         $pools[$pool][$round][$home_id][$match['Match']['order']] = $match['Match']['id'];
         $pools[$pool][$round][$away_id][$match['Match']['order']] = $match['Match']['id'];
         // Store the rounds as a reference
         if (empty($rounds[$round])) {
             $rounds[$round] = array();
         }
         $rounds[$round][] = $match['Match']['id'];
     }
     // Loop through and sort matches
     foreach ($pools as &$p) {
         ksort($p);
         foreach ($p as &$r) {
             foreach ($r as &$m) {
                 ksort($m);
             }
         }
     }
     $bracket = new Bracket($this->_event);
     $bracket->setMatches($matches);
     $bracket->setParticipants($participants);
     $bracket->setPools($pools);
     $bracket->setRounds($rounds, false);
     return $bracket;
 }