-
Notifications
You must be signed in to change notification settings - Fork 14
Tournaments
Tournaments implements official Tournament API. Those methods require a Production or Personal Key, which can be obtain by submitting your application to Riot Game Registering an App. But before doing so, you'll have to provide an fake implementation using Tournament Stub.
- newTournament(hostRegion: TournamentRegion, named: String, hostUrl: String, amount: Int? = nil, info: TournamentInfo)
- createTournamentProvider(hostRegion: TournamentRegion, hostUrl: String)
- createTournament(providerId: ProviderId, named: String)
- createTournamentCode(tournamentId: TournamentId, amount: Int? = nil, info: TournamentInfo)
- TournamentEvents(tournamentCode: TournamentCode)
- updateTournament(tournamentCode: TournamentCode, updatedInfo: TournamentUpdate? = nil)
- TournamentInfo(tournamentCode: TournamentCode)
- TournamentRegion: The region hosting tournament. Currently, Korea cannot host tournament so providing .KR value as TournamentRegion will return nil.
- named: Tournament name.
- hostUrl: The server's url hosting tournament. Must support protocol http (with port 80 open) or https (with port 443 open).
- amount: Optional parameter specifying the number of TournamentCode to generate. Maximum value is 1000. If not specified, will be considered as 1.
- TournamentInfo: Informations about the tournament policy including: spectator type, team size (minimum 1 and maximum 5), pick type, allowed summoners, map type.
Since this method is asynchrone, there is not return value. Response will be provided with a handler closure with parameters: ((ProviderId, TournamentId, [TournamentCode])?, String?)
. Tuple is composed of Tournament ProviderId, TournamentId and a list of TournamentCode generated. It is equivalent as making calls to createTournamentProvider, createTournament and createTournamentCode. Result will be nil only if parameter rule was broken. The String parameter contains the first error description encountered if existing.
guard let spectatorType = SpectatorType(.None) else { return }
guard let pickType = PickType(.TournamentDraft) else { return }
guard let mapType = MapType(.SummonersRift) else { return }
guard let tournamentRegion = TournamentRegion(.EUW) else { return }
guard let tournamentInfo = TournamentInfo(spectatorType: spectatorType, teamSize: 5, pickType: pickType, allowedSummonerIds: [SummonerId("xc8IRVLGV1Gb75sbz8JoLdRvIJ_yAKNsSG1RBQVtnGZqZV8")], mapType: mapType, metadata: "Other informations") else { return }
league.lolAPI.newTournament(hostRegion: tournamentRegion, named: "My League Tournament", hostUrl: "https://myLeagueTournament.com", amount: 7, info: tournamentInfo) { (result, errorMsg) in
if let (providerId, tournamentId, tournamentCodes) = result {
print("Success!")
}
else {
print("Request failed cause: \(errorMsg ?? "No error description")")
}
}
- TournamentRegion: The region hosting tournament. Currently, Korea cannot host tournament so providing .KR value as TournamentRegion will return nil.
- hostUrl: The server's url hosting tournament. Must support protocol http (with port 80 open) or https (with port 443 open).
Since this method is asynchrone, there is not return value. Response will be provided with a handler closure with parameters: (ProviderId?, String?)
. ProviderId is the unique identifier of the Provider (host and region) and will be nil only if parameter rule was broken. The String parameter contains the first error description encountered if existing.
guard let tournamentRegion = TournamentRegion(.EUW) else { return }
league.lolAPI.createTournamentProvider(hostRegion: tournamentRegion, hostUrl: "https://myLeagueTournament.com") { (providerId, errorMsg) in
if let providerId = providerId {
print("Success!")
}
else {
print("Request failed cause: \(errorMsg ?? "No error description")")
}
}
- ProviderId: Represents the unique identifier for a Provider. A provider is composed of a hostUrl and a region hosting tournament. See createTournamentProvider section above.
- named: Tournament name.
Since this method is asynchrone, there is not return value. Response will be provided with a handler closure with parameters: (TournamentId?, String?)
. TournamentId is the unique identifier of the Tournament instance (name and provider) and will be nil only if parameter rule was broken. The String parameter contains the first error description encountered if existing.
league.lolAPI.createTournament(providerId: ProviderId(43), named: "My League Tournament") { (tournamentId, errorMsg) in
if let tournamentId = tournamentId {
print("Success!")
}
else {
print("Request failed cause: \(errorMsg ?? "No error description")")
}
}
- TournamentId: Represents the unique identifier for a Tournament. A tournament is composed of a provider and a name. See createTournament section above.
- amount: Optional parameter specifying the number of TournamentCode to generate. Maximum value is 1000. If not specified, will be considered as 1.
- TournamentInfo: Informations about the tournament policy including: spectator type, team size (minimum 1 and maximum 5), pick type, allowed summoners, map type.
Since this method is asynchrone, there is not return value. Response will be provided with a handler closure with parameters: ([TournamentCode]?, String?)
. TournamentCode array contains all code generated. Those code allows owner to access confidential game data about the tournament. Result will be nil only if parameter rule was broken. The String parameter contains the first error description encountered if existing.
guard let spectatorType = SpectatorType(.None) else { return }
guard let pickType = PickType(.TournamentDraft) else { return }
guard let mapType = MapType(.SummonersRift) else { return }
guard let tournamentInfo = TournamentInfo(spectatorType: spectatorType, teamSize: 5, pickType: pickType, allowedSummonerIds: [SummonerId("xc8IRVLGV1Gb75sbz8JoLdRvIJ_yAKNsSG1RBQVtnGZqZV8")], mapType: mapType, metadata: "Other informations") else { return }
league.lolAPI.createTournamentCode(tournamentId: TournamentId(44), amount: 7, info: tournamentInfo) { (tournamentCodes, errorMsg) in
if let tournamentCodes = tournamentCodes {
print("Success!")
}
else {
print("Request failed cause: \(errorMsg ?? "No error description")")
}
}
- TournamentCode: A code generated that allows user to access confidential game data about the tournament. See createTournamentCode section above.
Since this method is asynchrone, there is not return value. Response will be provided with a handler closure with parameters: ([TournamentEvent]?, String?)
. TournamentEvent array contains records of actions and changes in tournament and will be nil only if TournamentCode was not found or invalid. The String parameter contains the first error description encountered if existing.
league.lolAPI.getTournamentEvents(tournamentCode: TournamentCode("Tournament Code")) { (events, errorMsg) in
if let events = events {
print("Success!")
}
else {
print("Request failed cause: \(errorMsg ?? "No error description")")
}
}
- TournamentCode: A code generated that allows user to access confidential game data about the tournament. See createTournamentCode section above.
- TournamentUpdate: Optional parameter containing all modified values. If this value is nil, no modification will be applied. Values you can change are: allowed summoners, spectator type, pick type and map type. Only allowed summoners are optional and if nil, all summoners are allowed to join.
Since this method is asynchrone, there is not return value. This method has no result to provide but if an error occurred, description will be passed by the handler closure with parameter: (String?)
. If String is nil, then modification were propagated to Riot server, in any other case, String parameter will contain the first error description encountered.
guard let spectatorType = SpectatorType(.None) else { return }
guard let pickType = PickType(.TournamentDraft) else { return }
guard let mapType = MapType(.SummonersRift) else { return }
league.lolAPI.updateTournament(tournamentCode: TournamentCode("Tournament Code"), updatedInfo: TournamentUpdate(spectatorType: spectatorType, pickType: pickType, allowedSummonerIds: [SummonerId("xc8IRVLGV1Gb75sbz8JoLdRvIJ_yAKNsSG1RBQVtnGZqZV8")], mapType: mapType)) { (errorMsg) in
if let errorMsg = errorMsg {
print("Request failed cause: \(errorMsg)")
}
}
- TournamentCode: A code generated that allows user to access confidential game data about the tournament. See createTournamentCode section above.
Since this method is asynchrone, there is not return value. Response will be provided with a handler closure with parameters: (TournamentDetails?, String?)
. TournamentDetail contains all information provided during tournament creation and will be nil only if TournamentCode was not found or invalid. The String parameter contains the first error description encountered if existing.
league.lolAPI.getTournamentInfo(tournamentCode: TournamentCode("Tournament Code")) { (tournamentInfo, errorMsg) in
if let tournamentInfo = tournamentInfo {
print("Success!")
}
else {
print("Request failed cause: \(errorMsg ?? "No error description")")
}
}