diff --git a/PoGo.NecroBot.Logic/ILogicSettings.cs b/PoGo.NecroBot.Logic/ILogicSettings.cs index f273bbd01..c9a195d17 100644 --- a/PoGo.NecroBot.Logic/ILogicSettings.cs +++ b/PoGo.NecroBot.Logic/ILogicSettings.cs @@ -88,6 +88,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/Inventory.cs b/PoGo.NecroBot.Logic/Inventory.cs index de6a0cf44..060424a42 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/Settings.cs b/PoGo.NecroBot.Logic/Settings.cs index bd7cf6a7a..9561e7043 100644 --- a/PoGo.NecroBot.Logic/Settings.cs +++ b/PoGo.NecroBot.Logic/Settings.cs @@ -101,6 +101,7 @@ public class GlobalSettings public bool AutomaticallyLevelUpPokemon = false; public int AmountOfTimesToUpgradeLoop = 5; + public int GetMinStarDustForLevelUp = 5000; public bool AutoUpdate = true; public double DefaultAltitude = 10; @@ -589,6 +590,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; 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