项目作者: bryanhitc

项目描述 :
An API wrapper for the League of Legends client.
高级语言: C#
项目地址: git://github.com/bryanhitc/lcu-sharp.git
创建时间: 2018-12-22T04:31:52Z
项目社区:https://github.com/bryanhitc/lcu-sharp

开源协议:MIT License

下载


lcu-sharp

An API wrapper for the League of Legends client.

For the LCU API documentation, check out Rift Explorer.

Usage

Request example

  1. // Initialize a connection to the league client.
  2. var api = await LeagueClientApi.ConnectAsync();
  3. // Show the client.
  4. await api.RiotClientEndpoint.ShowUxAsync();
  5. await Task.Delay(1000);
  6. // Update the current summoner's profile icon to 23.
  7. var body = new { profileIconId = 23 };
  8. var queryParameters = Enumerable.Empty<string>();
  9. var json = await api.RequestHandler.GetJsonResponseAsync(HttpMethod.Put, "lol-summoner/v1/current-summoner/icon",
  10. queryParameters, body);
  11. // Minimize the client.
  12. await Task.Delay(1000);
  13. await api.RiotClientEndpoint.MinimizeUxAsync();

Usage Request Run

Event example

  1. public event EventHandler<LeagueEvent> GameFlowChanged;
  2. private readonly TaskCompletionSource<bool> _work = new TaskCompletionSource<bool>(false);
  3. public async Task EventExampleAsync()
  4. {
  5. // Initialize a connection to the league client.
  6. var api = await LeagueClientApi.ConnectAsync();
  7. Console.WriteLine("Connected!");
  8. // Register game flow event.
  9. GameFlowChanged += OnGameFlowChanged;
  10. api.EventHandler.Subscribe("/lol-gameflow/v1/gameflow-phase", GameFlowChanged);
  11. // Wait until work is complete.
  12. await _work.Task;
  13. Console.WriteLine("Done.");
  14. }
  15. private void OnGameFlowChanged(object sender, LeagueEvent e)
  16. {
  17. var result = e.Data.ToString();
  18. var state = string.Empty;
  19. switch (result)
  20. {
  21. case "None":
  22. state = "main menu";
  23. break;
  24. case "Lobby":
  25. state = "lobby";
  26. break;
  27. case "ChampSelect":
  28. state = "champ select";
  29. break;
  30. case "GameStart":
  31. state = "game started";
  32. break;
  33. case "InProgress":
  34. state = "game";
  35. break;
  36. case "WaitingForStats":
  37. state = "waiting for stats";
  38. break;
  39. default:
  40. state = $"unknown state: {result}";
  41. break;
  42. }
  43. // Print new state and set work to complete.
  44. Console.WriteLine($"Status update: Entered {state}.");
  45. _work.SetResult(true);
  46. }

Usage Event Run

License

Copyright (c) 2020 Bryan Hitchcock. All rights reserved.

Licensed under the MIT license.