From b5cd5479bf3089cfc4480e0298aff68390f9534a Mon Sep 17 00:00:00 2001 From: cawk Date: Sun, 31 Jul 2016 16:43:45 +0100 Subject: [PATCH 1/2] Add minimum stardust for levelling up --- PoGo.NecroBot.Logic/Inventory.cs | 10 +++++++++- PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/PoGo.NecroBot.Logic/Inventory.cs b/PoGo.NecroBot.Logic/Inventory.cs index b425e48c4..1af1b1b6f 100644 --- a/PoGo.NecroBot.Logic/Inventory.cs +++ b/PoGo.NecroBot.Logic/Inventory.cs @@ -185,6 +185,14 @@ public async Task GetHighestPokemonOfTypeByCp(PokemonData pokemon) .OrderByDescending(x => x.Cp) .FirstOrDefault(); } + public async Task GetStarDust() + { + var StarDust =await _client.Player.GetPlayer(); + var gdrfds = StarDust.PlayerData.Currencies; + var SplitStar = gdrfds[1].Amount; + return SplitStar; + + } public async Task GetHighestPokemonOfTypeByIv(PokemonData pokemon) { @@ -201,7 +209,7 @@ public async Task> GetHighestsCp(int limit) var pokemons = myPokemon.ToList(); return pokemons.OrderByDescending(x => x.Cp).ThenBy(n => n.StaminaMax).Take(limit); } - + public async Task> GetHighestsPerfect(int limit) { var myPokemon = await GetPokemons(); diff --git a/PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs b/PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs index 6c405fb6d..989880c9c 100644 --- a/PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs @@ -18,6 +18,10 @@ public static async Task Execute(ISession session, CancellationToken cancellatio { return; } + if (await session.Inventory.GetStarDust() <= session.LogicSettings.GetMinStarDustForLevelUp) + { + return; + } if (session.LogicSettings.LevelUpByCPorIv.ToLower().Contains("iv")) { for (int i = 0; i < session.LogicSettings.AmountOfTimesToUpgradeLoop; i++) @@ -39,7 +43,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio } else if (upgradeResult.Result.ToString().Contains("ErrorUpgradeNotAvailable")) { - Logging.Logger.Write("Pokemon Is At Max Level For Your Level"); + Logger.Write("Pokemon Is At Max Level For Your Level"); break; } else @@ -53,6 +57,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio } else if (session.LogicSettings.LevelUpByCPorIv.ToLower().Contains("cp")) { + for (int i = 0; i < session.LogicSettings.AmountOfTimesToUpgradeLoop; i++) { var rand = new Random(); @@ -71,7 +76,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio } else if (upgradeResult.Result.ToString().Contains("ErrorUpgradeNotAvailable")) { - Logging.Logger.Write("Pokemon Is At Max Level For Your Level"); + Logger.Write("Pokemon Is At Max Level For Your Level"); break; } else From e840dbc621d2869de46aeb5fae68af6a2daaa035 Mon Sep 17 00:00:00 2001 From: cawk Date: Sun, 31 Jul 2016 16:43:55 +0100 Subject: [PATCH 2/2] Add Settings --- PoGo.NecroBot.Logic/ILogicSettings.cs | 2 ++ PoGo.NecroBot.Logic/Settings.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/PoGo.NecroBot.Logic/ILogicSettings.cs b/PoGo.NecroBot.Logic/ILogicSettings.cs index 5777b3b58..6ad7ea70b 100644 --- a/PoGo.NecroBot.Logic/ILogicSettings.cs +++ b/PoGo.NecroBot.Logic/ILogicSettings.cs @@ -82,6 +82,8 @@ public interface ILogicSettings int KeepMinDuplicatePokemon { get; } bool PrioritizeIvOverCp { get; } int AmountOfTimesToUpgradeLoop { get; } + + int GetMinStarDustForLevelUp { get; } int MaxTravelDistanceInMeters { get; } bool UseGpxPathing { get; } string GpxFile { get; } diff --git a/PoGo.NecroBot.Logic/Settings.cs b/PoGo.NecroBot.Logic/Settings.cs index d80824fa4..b176b06fa 100644 --- a/PoGo.NecroBot.Logic/Settings.cs +++ b/PoGo.NecroBot.Logic/Settings.cs @@ -103,6 +103,7 @@ public class GlobalSettings public bool AutomaticallyLevelUpPokemon = false; public int AmountOfTimesToUpgradeLoop = 5; + public int GetMinStarDustForLevelUp = 5000; public bool AutoUpdate = true; public double DefaultAltitude = 10; @@ -584,6 +585,7 @@ public LogicSettings(GlobalSettings settings) public bool AutomaticallyLevelUpPokemon => _settings.AutomaticallyLevelUpPokemon; public int AmountOfTimesToUpgradeLoop => _settings.AmountOfTimesToUpgradeLoop; public string LevelUpByCPorIv => _settings.LevelUpByCPorIv; + public int GetMinStarDustForLevelUp => _settings.GetMinStarDustForLevelUp; public float UpgradePokemonIvMinimum => _settings.UpgradePokemonIvMinimum; public float UpgradePokemonCpMinimum => _settings.UpgradePokemonCpMinimum; public double WalkingSpeedInKilometerPerHour => _settings.WalkingSpeedInKilometerPerHour;