public static void CustomBuildService() { try { if (Builds.Keys.Any(b => b.Equals(Player.Instance.CleanChampionName())) && Builds.FirstOrDefault(b => b.Key.Equals(Player.Instance.CleanChampionName())).Value.TryParseData(out CurrentChampionBuild)) { Logger.Send(Player.Instance.CleanChampionName() + " build Loaded!"); // and set up event listeners SetUpEventListeners(); if (Player.Instance.IsInShopRange()) { Buy.BuyNextItem(CurrentChampionBuild); } } else { // An error occured during parsing. Catch the error and print it in the console Logger.Send("The selected AutoShop JSON could not be parsed.", Logger.LogLevel.Error); Logger.Send("Using Default Build!", Logger.LogLevel.Warn); UseDefaultBuild(); //Logger.Send("No build is currently used!", Logger.LogLevel.Warn); } } catch (Exception ex) { // An exception occured somewhere else. Notify the user of the error, and print the exception to the console Logger.Send("Exception occurred on initialization of AutoShop:", ex, Logger.LogLevel.Error); // Warn the user about the exception Logger.Send("Exception occurred during AutoShop initialization. AutoShop will most likely NOT work properly!", Logger.LogLevel.Warn); } }
/// <summary> /// Fired when buying is allowed /// </summary> /// <param name="args">Arguments of the event</param> private static void Events_OnBuyAllow(EventArgs args) { // Notify the user that we are going to try to buy items now Logger.Send("Can buy items", Logger.LogLevel.Info); // Attempt to buy as many consecutive items on the build as we can Buy.BuyNextItem(CurrentChampionBuild); }
/// <summary> /// Fired when buying is allowed /// </summary> /// <param name="args">Arguments of the event</param> private static void Events_OnBuyAllow(EventArgs args) { // Notify the user that we are going to try to buy items now Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(DateTime.Now.ToString("[H:mm:ss - ") + "AramBuddy Info] Can buy items"); Console.ResetColor(); // Attempt to buy as many consecutive items on the build as we can Buy.BuyNextItem(CurrentChampionBuild); }
/// <summary> /// Fired when buying is allowed /// </summary> /// <param name="args">Arguments of the event</param> private static void Events_OnBuyAllow(EventArgs args) { if (Core.GameTickCount - LastBuyAllow > 500) { var deathtime = Player.Instance.DeathTimer() * 1000; // To Prevent Instantly buying item when event is fired var rnd = (float)(new Random().Next(Math.Max(500, (int)(deathtime * 0.05f)) / 3, Math.Max(1000, (int)(deathtime * 0.1f))) + Game.Ping); // Notify the user that we are going to try to buy items now Logger.Send("Can buy items: " + (rnd / 1000).ToString("F1") + " Second/s Delay", Logger.LogLevel.Event); // Attempt to buy as many consecutive items on the build as we can Core.DelayAction(() => Buy.BuyNextItem(CurrentChampionBuild), (int)rnd); LastBuyAllow = Core.GameTickCount; } }
/// <summary> /// Initializes the AutoShop system /// </summary> public static void Init() { try { Buy.CanShop = !Player.Instance.Buffs.Any(b => b.DisplayName.Equals("aramshopdisableplayer", StringComparison.CurrentCultureIgnoreCase)) || Player.Instance.IsDead; //var useDefaultBuild = false; // When the game starts AramBuddy.Events.OnGameStart += Events_OnGameStart; // Check if the index file exists if (!File.Exists(TempFile)) { // If not, create the index file Buy.CreateIndexFile(); } if (!Directory.Exists(BuildPath)) { Directory.CreateDirectory(BuildPath); } // Loop through all the builds in the build path directory foreach (var build in Directory.GetFiles(BuildPath)) { // Get the name of the champion from the build var parsed = build.Replace(".json", "").Replace(BuildPath + "\\", ""); // Add the build to the Builds dictionary in a ChampionName : BuildData format Builds.Add(parsed, File.ReadAllText(build)); } // Check if there are any builds for our champion if (Builds.Keys.All(b => b.CleanChampionName() != Player.Instance.CleanChampionName())) { // If not, warn the user Logger.Send("There are no builds for your champion. " + Player.Instance.ChampionName, Logger.LogLevel.Warn); Build.GetBuildFromService(); } /*if (useDefaultBuild) * return;*/ // Check if the parse of the build for the champion completed successfully and output it to public // variable CurrentChampionBuild if (Builds.Any(b => b.Key.CleanChampionName() == Player.Instance.CleanChampionName()) && Builds.FirstOrDefault(b => b.Key.CleanChampionName() == Player.Instance.CleanChampionName()).Value.TryParseData(out CurrentChampionBuild)) { // If the parse is successful, notify the user that the initialization process is finished Logger.Send(Config.CurrentPatchUsed + " " + Player.Instance.ChampionName + " Build Loaded !"); Logger.Send("AutoShop has been fully and succesfully initialized!"); // and set up event listeners SetUpEventListeners(); Buy.BuyNextItem(CurrentChampionBuild); } } catch (Exception ex) { // An exception occured somewhere else. Notify the user of the error, and print the exception to the console Logger.Send("Exception occurred on initialization of AutoShop:", ex, Logger.LogLevel.Error); // Warn the user about the exception Logger.Send("Exception occurred during AutoShop initialization. AutoShop will most likely NOT work properly!", Logger.LogLevel.Warn); } }
/// <summary> /// Initializes the AutoShop system /// </summary> public static void Init() { try { Buy.CanShop = !Player.Instance.Buffs.Any(b => b.DisplayName.Equals("aramshopdisableplayer", StringComparison.CurrentCultureIgnoreCase)) || Player.Instance.IsDead; var useDefaultBuild = false; // When the game starts AramBuddy.Events.OnGameStart += Events_OnGameStart; // Item Bought Event, reduce the temp value when we buy the item. Events.OnBuyItem += delegate { Core.DelayAction( () => { // Try to buy more than one item if we can afford it Buy.BuyNextItem(CurrentChampionBuild); }, new Random().Next(900 + Game.Ping, 2750 + Game.Ping)); }; // Create the build path directory Directory.CreateDirectory(BuildPath); // Check if the index file exists if (!File.Exists(TempFile)) { // If not, create the index file Buy.CreateIndexFile(); } // Loop through all the builds in the build path directory foreach (var build in Directory.GetFiles(BuildPath)) { // Get the name of the champion from the build var parsed = build.Replace(".json", "").Replace(BuildPath + "\\", ""); // Add the build to the Builds dictionary in a ChampionName : BuildData format Builds.Add(parsed, File.ReadAllText(build)); } // Check if there are any builds for our champion if (Builds.Keys.All(b => b != Player.Instance.ChampionName)) { // If not, warn the user Logger.Send("There are no builds for your champion.", Logger.LogLevel.Warn); // and Use Default build if (Builds.Keys.Any(b => b.Equals(Build.BuildName()))) { DefaultBuild(); Logger.Send("Using default build path!", Logger.LogLevel.Warn); } else { // Creates Default Build for the AutoShop Logger.Send("Creating default build path!", Logger.LogLevel.Warn); Build.Create(); useDefaultBuild = true; } } if (useDefaultBuild) { return; } // Check if the parse of the build for the champion completed successfully and output it to public // variable CurrentChampionBuild if (Builds.Any(b => b.Key == Player.Instance.ChampionName) && Builds.FirstOrDefault(b => b.Key == Player.Instance.ChampionName).Value.TryParseData(out CurrentChampionBuild)) { // If the parse is successful, notify the user that the initialization process is finished Logger.Send("AutoShop has been fully and succesfully initialized!", Logger.LogLevel.Info); // and set up event listeners SetUpEventListeners(); Buy.BuyNextItem(CurrentChampionBuild); } } catch (Exception ex) { // An exception occured somewhere else. Notify the user of the error, and print the exception to the console Logger.Send("Exception occurred on initialization of AutoShop:", ex, Logger.LogLevel.Error); // Warn the user about the exception Logger.Send("Exception occurred during AutoShop initialization. AutoShop will most likely NOT work properly!", Logger.LogLevel.Warn); } }
/// <summary> /// Initializes the AutoShop system /// </summary> public static void Init() { try { // When the game starts AramBuddy.Events.OnGameStart += Events_OnGameStart; // Create the build path directory Directory.CreateDirectory(BuildPath); // Check if the index file exists if (!File.Exists(TempPath + "\\buildindex" + Player.Instance.NetworkId + ".dat")) { // If not, create the index file Buy.CreateIndexFile(); } // Loop through all the builds in the build path directory foreach (string build in Directory.GetFiles(BuildPath)) { // Get the name of the champion from the build string parsed = build.Replace(".json", "").Replace(BuildPath + "\\", ""); // Add the build to the Builds dictionary in a ChampionName : BuildData format Builds.Add(parsed, File.ReadAllText(build)); } // Check if there are any builds for our champion if (Builds.Keys.All(b => b != Player.Instance.ChampionName)) { // If not, warn the user Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine(DateTime.Now.ToString("[H:mm:ss - ") + "AramBuddy Warning] There are no builds for your champion."); // and Use Default build if (Builds.Keys.Any(b => b.Equals(Build.BuildName()))) { Console.WriteLine(DateTime.Now.ToString("[H:mm:ss - ") + "AramBuddy Warning] Using default build path!"); Console.ResetColor(); } else { // Creates Default Build for the AutoShop Console.WriteLine(DateTime.Now.ToString("[H:mm:ss - ") + "AramBuddy Warning] Creating default build path!"); Build.Create(); Console.ResetColor(); } } // Check if the parse of the build for the champion completed successfully and output it to public // variable CurrentChampionBuild if (Builds.Any(b => b.Key == Player.Instance.ChampionName) && Builds.FirstOrDefault(b => b.Key == Player.Instance.ChampionName).Value.TryParseData(out CurrentChampionBuild)) { // If the parse is successful, notify the user that the initialization process is finished Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(DateTime.Now.ToString("[H:mm:ss - ") + "AramBuddy Info] AutoShop has been fully and succesfully initialized!"); // and set up event listeners SetUpEventListeners(); Console.ResetColor(); } else { Core.DelayAction( () => { // Use Default build if (Builds.Keys.Any(b => b.Equals(Build.BuildName())) && Builds.FirstOrDefault(b => b.Key.Equals(Build.BuildName())).Value.TryParseData(out CurrentChampionBuild)) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine(DateTime.Now.ToString("[H:mm:ss - ") + "AramBuddy Info] " + Build.BuildName() + " build Loaded!"); Console.ResetColor(); // and set up event listeners SetUpEventListeners(); if (Player.Instance.IsInShopRange()) { Buy.BuyNextItem(CurrentChampionBuild); } } else { // An error occured during parsing. Catch the error and print it in the console Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(DateTime.Now.ToString("[H:mm:ss - ") + "AramBuddy Error] The selected AutoShop JSON could not be parsed."); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine(DateTime.Now.ToString("[H:mm:ss - ") + "AramBuddy Warning] No build is currently used!"); Console.ResetColor(); } }, 9000); } } catch (Exception ex) { // An exception occured somewhere else. Notify the user of the error, and print the exception to the console Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine( DateTime.Now.ToString(Environment.NewLine + "[H:mm:ss - ") + "AramBuddy Error] Exception occurred on initialization of AutoShop:"); Console.ResetColor(); Console.Write(ex); // Warn the user about the exception Console.ForegroundColor = ConsoleColor.Magenta; Console.WriteLine( DateTime.Now.ToString("H:mm:ss - ") + "AramBuddy Warning] Exception occurred during AutoShop initialization. AutoShop will most likely NOT work properly!"); Console.ResetColor(); } }