RiotSharp 2.4 released

January 14, 2016 - RiotSharp, release

In this is post, I’ll give a quick overview of the new features in the new release of RiotSharp, the C# wrapper for the Riot Games API.

New Tournament API

In this release, we’ve added support to the new Tournament API which was announced by Riot here a month ago. Thanks to this addition, given that you’ve applied for a special tournament API key, you’ll be able to build a tournament system with the given features:

I’ll give a quick rundown on how to do that.

First, you’ll need a tournament API instance, which you can retrieve with the tournament API key you got:

var tournamentApi = TournamentRiotApi.GetInstance("TOURNAMENT_API_KEY");

Then, you will have to create a provider given the region where the tournament will take place and the url to an HTTP server listening on port 80 to which Riot Games’ servers will send callbacks containing information about completed games created with a tournament code you generated, more on that later:

var provider = tournamentApi.CreateProvider(Region.euw, "http://website.com");

Thanks to this provider, which you should save if you want to create other tournaments later on, you can create tournaments:

var tournament = tournamentApi.CreateTournament(provider.Id, "TOURNAMENT_NAME");

You can now generate tournament codes which can be used to join a game with the specified settings:

var tournamentCodes = tournamentApi.CreateTournamentCodes(
    tournament.Id, teamSize, allowedSummonerIds,
    TournamentSpectatorType.All,
    TournamentPickType.TournamentDraft,
    TournamentMapType.SummonersRift,
    string.empty,
    count = 10);

Where you can specify:

If you need to change some of these info, you can do so with UpdateTournamentCode(). You can also retrieve these info and some more through GetTournamentCodeDetails().

Next up, you can retrieve lobby events as they are taking place!

var lobbyEvents = tournamentApi.GetTournamentLobbyEvents(tournamentCode);
var summonerIdsWhoJoined = lobbyEvents
    .Where(le => le.EventType == "PlayerJoinedGameEvent")
    .Select(le => le.SummonerId);
foreach (var summonerId in summonerIdsWhoJoined)
{
    Console.WriteLine(summonerId);
}

Here, I just retrieve the summoner id of every player who joined the lobby.

Finally, unranked matches! You’re now gonna be able to retrieve information regarding a match for which the specified tournament code was used:

var match = tournamentApi.GetTournamentMatch(Region.euw, tournamentCode);
foreach (var participantIdentity in match.ParticipantIdentities)
{
    Console.WriteLine(participantIdentity.Player.SummonerName);
}

As shown, you can retrieve the same data as you would do with the standard API. However, the tournament API does not anonymize summoner data, conversely to the standard endpoint.

You can find a list of all supported operation in ITournamentRiotApi which contains all supported operations as well as their async versions.

You can find the full documentation for this API on developer.riotgames.com.

Credit to @StevenReitsma and @jvanvugt for developing this new API!

Misc

RiotSharp is now a PCL which means you will be able to use it in your Windows Store and Windows Phone endeavors.

We’ve upgraded to the latest release of Json.NET: 8.0.1.

We are now better integrated with AppVeyor our continous integration service: the unit tests are being run on every push to the develop branch. Unfortunately, the tests cannot be run on PRs because the API keys, which are needed to run the tests, are stored as encrypted environment variables which are not enabled by AppVeyor when building PRs.

Contribute!

RiotSharp is now on up-for-grabs and there are quite a few easy-to-solve issues for you to contribute. So feel free to jump right in!