function createGFCTournament($mynodeidparent) { // /******************************************************************************** // //CREATE A TOURNAMENT and Update Drupal Tournaments Node with Challonge tourney ID // // Include the Challonge API Class include '/opt/bitnami/apps/drupal/htdocs/includes/challonge.class.php'; $c = new ChallongeAPI('XqrMnBPs15MvmX0izddB4zyIHKswRCoaIAyq4cTt'); // get the GFC data needed to create tourney in Challonge //$mynodeidparent = 18; //test id for debugging $node = node_load($mynodeidparent); $wrapper = entity_metadata_wrapper('node', $node); // retreive param values needed from GFC data // get tourney name $tourney_name = $wrapper->field_tournament_name->value(); // get type of play $term = taxonomy_term_load($wrapper->field_tournament_type->raw()); $wrapper2 = entity_metadata_wrapper('taxonomy_term', $term); $tourney_type = $term->name; // get description $tourney_descriptions = $wrapper->field_tournament_description->value(); //get url value $tourney_url = (string) uniqid(); //str_replace ( ' ', '', $tourney_name ); // TODO: invent good url scheme // set paramater values for challonge from GFC values $params = array("tournament[name]" => $tourney_name, "tournament[tournament_type]" => $tourney_type, "tournament[url]" => $tourney_url, "tournament[description]" => $tourney_descriptions); // call to challonge to create tournament $tournament = $c->makeCall("tournaments", $params, "post"); $tournament = $c->createTournament($params); //Save new URL value to GFC $wrapper->field_tournament_challonge_url->set($tourney_url); // save value $wrapper->save(); // ************************* // update GFC with returned tournament ID // ************************* //****************NOTE: Need to reload by URL value from CHALLONGE due to bug $tournament_id = $tourney_url; $params = array("include_matches " => 0); $tournament = $c->makeCall("tournaments/{$tournament_id}", $params, "get"); $tournament = $c->getTournament($tournament_id, $params); // retreive new tournament id and set to variable $challonge_id = (int) $tournament->id; // id set value $wrapper->field_tournament_challonge_id->set($challonge_id); //set url value // save value $wrapper->save(); return $c->result; }
public function updateMatchesFromChallonge() { $c = new ChallongeAPI(Yii::app()->params['challonge_api']); $params = array(); $matches = $c->getMatches($this->challonge_id, $params); foreach ($matches as $k => $match) { $_match = Match::model()->findByAttributes(array('tournament_id' => $this->id, 'challonge_match_id' => $match->match->id)); if ($_match) { $_match->team_1 = strlen($match->match->player1_id) ? $match->match->player1_id : ''; $_match->team_2 = strlen($match->match->player2_id) ? $match->match->player2_id : ''; $_match->identifier = $match->match->identifier; $_match->round = $match->match->round; $_match->state = $match->match->state; $_match->winner = $match->match->winner_id; $_match->loser = $match->match->loser_id; $_match->save(); } } }
<?php //header('Content-type: application/xml'); // Include the class on your page somewhere require $_SERVER['DOCUMENT_ROOT'] . '/includes/modules/tournamentManagement/challonge.class.php'; // Create a new instance of the API wrapper. Pass your API key into the constructor // You can view/generate your API key on the 'Password / API Key' tab of your account settings page. $c = new ChallongeAPI('vbAqvSEkokYx74ZIIMP7wUgVZLOzq7VzgF2CBetW'); /* For whatever reason (example: developing locally) if you get a SSL validation error from CURL, you can set the verify_ssl attribute of the class to false (defualts to true). It is highly recommended that you **NOT** do this on a production server. */ $c->verify_ssl = true; $tournament_id = 'testtournamentlanops'; $params = array("include_matches " => 0); $tournament = $c->makeCall("tournaments/{$tournament_id}", $params, "get"); $tournament = $c->getTournament($tournament_id, $params); echo '<pre>'; print_r($c->result); echo '</pre>'; // MATCHES EXAMPLES // ************************ // Get all matches for a tournament // http://challonge.com/api/tournaments/:tournament/matches $matches = $c->makeCall("tournaments/{$tournament_id}/matches", $params); $matches = $c->getMatches($tournament_id, $params); echo '<pre>'; print_r($c->result); echo '</pre>'; $participants = $c->makeCall("tournaments/{$tournament_id}/participants");
public function actionFinalizeTournament($id) { $model = $this->loadModel($id); $c = new ChallongeAPI(Yii::app()->params['challonge_api']); $params = array('include_matches' => 1, 'include_participants' => 1); $tournament_id = $model->challonge_id; $tournament = $c->publishTournament($tournament_id, $params)->tournament; $model->finished = date('Y-m-d H:i:s'); $model->save(); }
*/ $c->verify_ssl = false; // TOURNAMENT EXAMPLES // ************************ // Get all tournaments you created // http://challonge.com/api/tournaments $tournaments = $c->makeCall('tournaments'); $tournaments = $c->getTournaments(); print_r($c->result); // /******************************************************************************** // //CREATE A TOURNAMENT and Update Drupal Tournaments Node with Challonge tourney ID // // // Include the class on your page somewhere include '/opt/bitnami/apps/drupal/htdocs/includes/challonge.class.php'; $c = new ChallongeAPI('XqrMnBPs15MvmX0izddB4zyIHKswRCoaIAyq4cTt'); // get the GFC data needed to create tourney in Challonge $mynodeidparent = 17; $node = node_load($mynodeidparent); $wrapper = entity_metadata_wrapper('node', $node); // retreive param values needed from GFC data // get tourney name $tourney_name = $wrapper->field_tournament_name->value(); // get type of play $term = taxonomy_term_load($wrapper->field_tournament_type->raw()); $wrapper2 = entity_metadata_wrapper('taxonomy_term', $term); $tourney_type = $term->name; // get description $tourney_descriptions = $wrapper->field_tournament_description->value(); //get url value $tourney_url = str_replace(' ', '', $tourney_name);
<?php /*LanOps Manager - Tournament Management*/ require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/libs/std.php"; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/modules/tournamentManagement/challonge.class.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/modules/tournamentManagement/raffle.php'; //Tournament API $challonge = new ChallongeAPI('vbAqvSEkokYx74ZIIMP7wUgVZLOzq7VzgF2CBetW'); /*---PAGE FUNCTIONALITY---*/ function singleElimination($participants) { } function getMatch($tournament_id, $params) { return $challonge->getMatches($tournament_id, $params); } function getGame($gameID, $section = 'all') { $thisGame = Game::find_by_gameid($gameID); switch ($section) { case 'all': return $thisGame; break; case 'name': return $thisGame->name; break; } } //Add new tournament if ($_POST['action'] == 'add') { //Setup URL