Combu  3.2.2
Unity API Documentation
Managing Tournaments

In this section you will learn how to retrieve the tournaments list of the local user and how to add/remove tournaments.

Loading Tournaments

To retrieve the list of tournaments accessible by the local user you need to call Tournament.Load:

// Load the active tournaments, no filter by customData
Tournament.Load(false, null, (Tournament[] tournaments) => {
Debug.Log("Tournaments loaded: " + tournaments.Length);
});

Loading by Tournament ID

You can also load a single Tournament by its ID:

// Load a Tournament by ID
Tournament.Load(123, (Tournament tournament) => {
if (tournament != null)
Debug.Log("Success: " + tournament.title);
else
Debug.Log("Failed");
});

Matches of the Tournament

Once that the Tournament has been loaded, the property matches gives you access to its matches and their extra data.

Quick Tournament

To create a quick tournament with other users user you need to call Tournament.QuickTournament:

// Load 2 random users
User.Random( null, 2, (User[] users) => {
Tournament t = Tournament.QuickTournament(users);
if (t.matches.Count == 0)
{
Debug.Log("Something going wrong, no matches created");
}
else
{
t.title = "My Tournament 1";
t.customData["Key1"] = "Value";
t.Save((bool success, string error) => {
Debug.Log("Success: " + success + " - Matches: " + t.matches.Count);
});
}
});

Create your own Tournament

You can take a look at the code in Tournament.QuickTournament to see how to create a Tournament and use the code as base to create your own type of tournaments.

Removing Tournaments

To delete a tournament you need to call Tournament.Delete, or call the method Delete on a Tournament instance:

// Remove by Tournament ID
Tournament.Delete(123, (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});
// Remove by Tournament object
myTournament.Delete( (bool success, string error) => {
if (success)
Debug.Log("Success");
else
Debug.Log("Failed: " + error);
});