public static void Wait( [Description("The summoner of which the game should be waited for")] string username, [Description("The check rate per second"), DefaultValue(5), MoreThan(0)] int checkRate) { var summoner = Helper.TryApi(() => Api.GetSummoner(Settings.Default.Region, username), checkRate); if (summoner == null) { Console.WriteLine("No such summoner found."); return; } RiotSharp.CurrentGameEndpoint.CurrentGame game = null; do { try { game = Api.GetCurrentGame(Platform, summoner.Id); } catch (RiotSharpException) { Thread.Sleep(1000 * checkRate); } }while (game == null); Console.WriteLine("Game found."); }
private static string GetSpectatorArgument(RiotSharp.CurrentGameEndpoint.CurrentGame game) { var endpoint = ""; switch (Settings.Default.Region) { case Region.euw: endpoint = "spectator.euw1.lol.riotgames.com:80"; break; default: throw new NotImplementedException(); } return($"\"spectator {endpoint} {game.Observers.EncryptionKey} {game.GameId} {Platform}\""); }
public static void CSTrainer( [Description("The summoner of which the game should be waited for")] string username, [Description("The check rate per second"), DefaultValue(5), MoreThan(0)] int checkRate, [Description("The .wav to be played or empty for default")] string sound) { var summoner = Helper.TryApi(() => Api.GetSummoner(Settings.Default.Region, username), checkRate); if (summoner == null) { Console.WriteLine("No such summoner found."); return; } Console.WriteLine("Waiting for custom game..."); RiotSharp.CurrentGameEndpoint.CurrentGame game = null; while (game == null || game.GameType != GameType.CustomGame || game.GameStartTime.Year < 2000) { game = Helper.TryApi(() => Api.GetCurrentGame(Platform, summoner.Id), checkRate); Thread.Sleep(1000 * checkRate); } var localTime = game.GameStartTime.ToLocalTime(); var targetTime = localTime.AddMinutes(5).AddSeconds(5); Console.WriteLine("Game found. Started at {0}", localTime); Console.WriteLine("Waiting until {0}...", targetTime); var diff = targetTime - DateTime.Now; Thread.Sleep((int)diff.TotalMilliseconds); Console.WriteLine("5 Minutes have passed. Finish up your wave!"); Helper.PlaySound(sound, "LoLTool.ChimeSound.wav"); }