Пример #1
0
 /**
  * Returns the BBRound containing the round format for this match
  * 
  * returns null if unable to determine the round format
  *
  * @return BBRound|null - null if unavailable
  */
 public function &round_format()
 {
     //Already set
     if (!is_null($this->round_format)) {
         return $this->round_format;
     }
     //If we have a value for round and bracket, grab the round from the tournament now
     if (isset($this->current_data['round']) && isset($this->current_data['bracket'])) {
         //The tournament's rounds array is keyed by "friendly" bracket, determine ours now
         $bracket = BBHelper::get_bracket_label($this->current_data['bracket'], true);
         $round = $this->current_data['round'];
         //Found it!
         $this->round_format =& $this->tournament->rounds->{$bracket}[$round];
     } else {
         $this->set_error('Unable to figure out which round / bracket this match is in');
         return $this->bb->ref(null);
     }
     //Success!
     return $this->round_format;
 }
Пример #2
0
 /**
  * Fetch the data object that determines the elimination bracket participants and results
  * 
  * @todo implement the $bracket filter
  * 
  * @param int|null $bracket
  * <br /><b>Optional</b><br />
  * Specify a single bracket to return<br />
  * 
  * @return BBBracketsObject|boolean
  * <br />Return values:<br />
  * <ul>
  *  <li>{@link BBBracketsObject} - default return value</li>
  *  <li>{@link BBMatchObject}[][] - if a <var>$bracket</var> integer was provided, only the array of rounds for that bracket is returned</li>
  *  <li><b>False</b> returned if tournament has no brackets / error communicating with the API</li>
  */
 public function &brackets($bracket = null)
 {
     //Already set
     if (!is_null($this->brackets)) {
         return $this->brackets;
     }
     //Failure
     if (!BBHelper::tournament_has_brackets($this)) {
         return $this->bb->ref($this->set_error('This tournament does not have any brackets to load!'));
     }
     //GOGOGO!
     $result = $this->call(self::SERVICE_LOAD_BRACKETS, array('tourney_id' => $this->id), self::CACHE_TTL_DRAW, self::CACHE_OBJECT_TYPE, $this->id);
     //Failure!
     if ($result->result != BinaryBeast::RESULT_SUCCESS) {
         $this->set_error('Error returned from the API when calling the bracket drawing service, please refer to $bb->result_history for details');
         return $this->bb->ref(false);
     }
     /*
      * Success!
      * 
      * Now pass each returned match through process_draw_match,
      * which will attempt to convert the values into Model objects
      */
     $this->brackets = new stdClass();
     foreach ($result->brackets as $bracket => $rounds) {
         //the API's response is keyed by bracket integer, let's translate for convenience of developers
         $bracket = BBHelper::get_bracket_label($bracket, true);
         $this->brackets->{$bracket} = array();
         foreach ($rounds as $round => $matches) {
             $this->brackets->{$bracket}[$round] = array();
             foreach ($matches as $match) {
                 $this->brackets->{$bracket}[$round][] = $this->process_drawn_match($match);
             }
         }
     }
     //Success! now return the result
     return $this->brackets;
 }