diff --git a/PoGo.NecroBot.CLI/Program.cs b/PoGo.NecroBot.CLI/Program.cs index 2f968b3fa..a885bda79 100644 --- a/PoGo.NecroBot.CLI/Program.cs +++ b/PoGo.NecroBot.CLI/Program.cs @@ -38,6 +38,7 @@ private static void Main(string[] args) Logger.Write("Press a Key to continue...", LogLevel.Warning); Console.ReadKey(); + return; } var session = new Session(new ClientSettings(settings), new LogicSettings(settings)); session.Client.ApiFailure = new ApiFailureStrategy(session); diff --git a/PoGo.NecroBot.Logic/Inventory.cs b/PoGo.NecroBot.Logic/Inventory.cs index f2564abd5..61b80f85a 100644 --- a/PoGo.NecroBot.Logic/Inventory.cs +++ b/PoGo.NecroBot.Logic/Inventory.cs @@ -245,44 +245,6 @@ public async Task> GetItemsToRecycle(ISession session) var itemsToRecylce = new List(); var myItems = (await GetItems()).ToList(); - var amountOfPokeballsToKeep = _logicSettings.TotalAmountOfPokeballsToKeep; - var amountOfPotionsToKeep = _logicSettings.TotalAmountOfPotionsToKeep; - var amountOfRevivesToKeep = _logicSettings.TotalAmountOfRevivesToKeep; - - var currentAmountOfPokeballs = await GetItemAmountByType(ItemId.ItemPokeBall); - var currentAmountOfGreatballs = await GetItemAmountByType(ItemId.ItemGreatBall); - var currentAmountOfUltraballs = await GetItemAmountByType(ItemId.ItemUltraBall); - var currentAmountOfMasterballs = await GetItemAmountByType(ItemId.ItemMasterBall); - - if (session.LogicSettings.ShowPokeballCountsBeforeRecycle) - Logger.Write(session.Translation.GetTranslation(TranslationString.CurrentPokeballInv, - currentAmountOfPokeballs, currentAmountOfGreatballs, currentAmountOfUltraballs, - currentAmountOfMasterballs)); - - if (!_logicSettings.ItemRecycleFilter.Any(s => _pokeballs.Contains(s.Key))) - { - if (session.LogicSettings.VerboseRecycling) - Logger.Write(session.Translation.GetTranslation(TranslationString.CheckingForBallsToRecycle, amountOfPokeballsToKeep), LogLevel.Recycling); - var pokeballsToRecycle = GetPokeballsToRecycle(session, myItems); - itemsToRecylce.AddRange(pokeballsToRecycle); - } - - if (!_logicSettings.ItemRecycleFilter.Any(s => _potions.Contains(s.Key))) - { - if (session.LogicSettings.VerboseRecycling) - Logger.Write(session.Translation.GetTranslation(TranslationString.CheckingForPotionsToRecycle, amountOfPotionsToKeep), LogLevel.Recycling); - var potionsToRecycle = GetPotionsToRecycle(session, myItems); - itemsToRecylce.AddRange(potionsToRecycle); - } - - if (!_logicSettings.ItemRecycleFilter.Any(s => _revives.Contains(s.Key))) - { - if (session.LogicSettings.VerboseRecycling) - Logger.Write(session.Translation.GetTranslation(TranslationString.CheckingForRevivesToRecycle, amountOfRevivesToKeep), LogLevel.Recycling); - var revivesToRecycle = GetRevivesToRecycle(session, myItems); - itemsToRecylce.AddRange(revivesToRecycle); - } - var otherItemsToRecylce = myItems .Where(x => _logicSettings.ItemRecycleFilter.Any(f => f.Key == x.ItemId && x.Count > f.Value)) .Select( diff --git a/PoGo.NecroBot.Logic/Settings.cs b/PoGo.NecroBot.Logic/Settings.cs index 37f195f51..fc3ebe036 100644 --- a/PoGo.NecroBot.Logic/Settings.cs +++ b/PoGo.NecroBot.Logic/Settings.cs @@ -243,18 +243,18 @@ public class GlobalSettings //PokemonId.Kangaskhan, //PokemonId.MrMime, //PokemonId.Tauros, - //PokemonId.Gyarados, + PokemonId.Gyarados, //PokemonId.Lapras, PokemonId.Ditto, //PokemonId.Vaporeon, //PokemonId.Jolteon, //PokemonId.Flareon, //PokemonId.Porygon, - //PokemonId.Snorlax, + PokemonId.Snorlax, PokemonId.Articuno, PokemonId.Zapdos, PokemonId.Moltres, - //PokemonId.Dragonite, + PokemonId.Dragonite, PokemonId.Mewtwo, PokemonId.Mew }; @@ -473,17 +473,17 @@ public static GlobalSettings Load(string path) settings = new GlobalSettings(); } - if (settings.DefaultAltitude <= 0) + if (settings.DefaultAltitude == 0) { settings.DefaultAltitude = Default.DefaultAltitude; } - if (settings.DefaultLatitude <= 0) + if (settings.DefaultLatitude == 0) { settings.DefaultLatitude = Default.DefaultLatitude; } - if (settings.DefaultLongitude <= 0) + if (settings.DefaultLongitude == 0) { settings.DefaultLongitude = Default.DefaultLongitude; } diff --git a/PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs b/PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs index fa5e0d311..5e9b55cc2 100644 --- a/PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs @@ -26,33 +26,50 @@ public static async Task Execute(ISession session, CancellationToken cancellatio if (!session.LogicSettings.VerboseRecycling) Logger.Write(session.Translation.GetTranslation(TranslationString.RecyclingQuietly), LogLevel.Recycling); - var items = await session.Inventory.GetItemsToRecycle(session); - - foreach (var item in items) + if (session.LogicSettings.TotalAmountOfPokeballsToKeep != 0) { - cancellationToken.ThrowIfCancellationRequested(); + var currentAmountOfPokeballs = await session.Inventory.GetItemAmountByType(ItemId.ItemPokeBall); + var currentAmountOfGreatballs = await session.Inventory.GetItemAmountByType(ItemId.ItemGreatBall); + var currentAmountOfUltraballs = await session.Inventory.GetItemAmountByType(ItemId.ItemUltraBall); + var currentAmountOfMasterballs = await session.Inventory.GetItemAmountByType(ItemId.ItemMasterBall); - await session.Client.Inventory.RecycleItem(item.ItemId, item.Count); + if (session.LogicSettings.ShowPokeballCountsBeforeRecycle) + Logger.Write(session.Translation.GetTranslation(TranslationString.CurrentPokeballInv, + currentAmountOfPokeballs, currentAmountOfGreatballs, currentAmountOfUltraballs, + currentAmountOfMasterballs)); - if (session.LogicSettings.VerboseRecycling) - session.EventDispatcher.Send(new ItemRecycledEvent {Id = item.ItemId, Count = item.Count}); + await OptimizedRecycleBalls(session, cancellationToken); + } - DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500); + if (session.LogicSettings.TotalAmountOfPotionsToKeep>=0) + { + await OptimizedRecyclePotions(session, cancellationToken); } - if (session.LogicSettings.TotalAmountOfPokeballsToKeep != 0) + if (session.LogicSettings.TotalAmountOfRevivesToKeep>=0) { - await OptimizedRecycleBalls(session, cancellationToken); + await OptimizedRecycleRevives(session, cancellationToken); } - if (session.LogicSettings.TotalAmountOfPotionsToKeep != 0) + currentTotalItems = await session.Inventory.GetTotalItemCount(); + if ((session.Profile.PlayerData.MaxItemStorage * session.LogicSettings.RecycleInventoryAtUsagePercentage) > currentTotalItems) { - await OptimizedRecyclePotions(session, cancellationToken); + await session.Inventory.RefreshCachedInventory(); + return; } - if (session.LogicSettings.TotalAmountOfRevivesToKeep != 0) + var items = await session.Inventory.GetItemsToRecycle(session); + + foreach (var item in items) { - await OptimizedRecycleRevives(session, cancellationToken); + cancellationToken.ThrowIfCancellationRequested(); + + await session.Client.Inventory.RecycleItem(item.ItemId, item.Count); + + if (session.LogicSettings.VerboseRecycling) + session.EventDispatcher.Send(new ItemRecycledEvent { Id = item.ItemId, Count = item.Count }); + + DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500); } await session.Inventory.RefreshCachedInventory(); @@ -67,8 +84,6 @@ private static async Task OptimizedRecycleBalls(ISession session, CancellationTo int pokeBallsToRecycle = 0; int greatBallsToRecycle = 0; - /* - */ int totalBallsCount = pokeBallsCount + greatBallsCount + ultraBallsCount + masterBallsCount; if (totalBallsCount > session.LogicSettings.TotalAmountOfPokeballsToKeep)