RecycleItems() use now DarkCyan as output color

Spegeli [2016-07-22 03:50:06]
RecycleItems() use now DarkCyan as output color
Filename
PokemonGo.RocketAPI.Logic/Inventory.cs
PokemonGo.RocketAPI.Logic/Logic.cs
diff --git a/PokemonGo.RocketAPI.Logic/Inventory.cs b/PokemonGo.RocketAPI.Logic/Inventory.cs
index 9e3f67b..a8cbf1f 100644
--- a/PokemonGo.RocketAPI.Logic/Inventory.cs
+++ b/PokemonGo.RocketAPI.Logic/Inventory.cs
@@ -1,109 +1,109 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using AllEnum;
-using PokemonGo.RocketAPI.GeneratedCode;
-
-namespace PokemonGo.RocketAPI.Logic
-{
-    public class Inventory
-    {
-        private readonly Client _client;
-
-        public Inventory(Client client)
-        {
-            _client = client;
-        }
-
-        public async Task<IEnumerable<PokemonData>> GetPokemons()
-        {
-            var inventory = await _client.GetInventory();
-            return
-                inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon)
-                    .Where(p => p != null && p?.PokemonId > 0);
-        }
-
-        public async Task<IEnumerable<PokemonFamily>> GetPokemonFamilies()
-        {
-            var inventory = await _client.GetInventory();
-            return
-                inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokemonFamily)
-                    .Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
-        }
-
-        public async Task<IEnumerable<PokemonSettings>> GetPokemonSettings()
-        {
-            var templates = await _client.GetItemTemplates();
-            return
-                templates.ItemTemplates.Select(i => i.PokemonSettings)
-                    .Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
-        }
-
-
-        public async Task<IEnumerable<PokemonData>> GetDuplicatePokemonToTransfer(bool keepPokemonsThatCanEvolve = false)
-        {
-            var myPokemon = await GetPokemons();
-
-            var pokemonList = myPokemon as IList<PokemonData> ?? myPokemon.ToList();
-            if (keepPokemonsThatCanEvolve)
-            {
-                var results = new List<PokemonData>();
-                var pokemonsThatCanBeTransfered = pokemonList.GroupBy(p => p.PokemonId)
-                    .Where(x => x.Count() > 1).ToList();
-
-                var myPokemonSettings = await GetPokemonSettings();
-                var pokemonSettings = myPokemonSettings as IList<PokemonSettings> ?? myPokemonSettings.ToList();
-
-                var myPokemonFamilies = await GetPokemonFamilies();
-                var pokemonFamilies = myPokemonFamilies as PokemonFamily[] ?? myPokemonFamilies.ToArray();
-
-                foreach (var pokemon in pokemonsThatCanBeTransfered)
-                {
-                    var settings = pokemonSettings.Single(x => x.PokemonId == pokemon.Key);
-                    var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using AllEnum;
+using PokemonGo.RocketAPI.GeneratedCode;
+
+namespace PokemonGo.RocketAPI.Logic
+{
+    public class Inventory
+    {
+        private readonly Client _client;
+
+        public Inventory(Client client)
+        {
+            _client = client;
+        }
+
+        public async Task<IEnumerable<PokemonData>> GetPokemons()
+        {
+            var inventory = await _client.GetInventory();
+            return
+                inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon)
+                    .Where(p => p != null && p?.PokemonId > 0);
+        }
+
+        public async Task<IEnumerable<PokemonFamily>> GetPokemonFamilies()
+        {
+            var inventory = await _client.GetInventory();
+            return
+                inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokemonFamily)
+                    .Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
+        }
+
+        public async Task<IEnumerable<PokemonSettings>> GetPokemonSettings()
+        {
+            var templates = await _client.GetItemTemplates();
+            return
+                templates.ItemTemplates.Select(i => i.PokemonSettings)
+                    .Where(p => p != null && p?.FamilyId != PokemonFamilyId.FamilyUnset);
+        }
+
+
+        public async Task<IEnumerable<PokemonData>> GetDuplicatePokemonToTransfer(bool keepPokemonsThatCanEvolve = false)
+        {
+            var myPokemon = await GetPokemons();
+
+            var pokemonList = myPokemon as IList<PokemonData> ?? myPokemon.ToList();
+            if (keepPokemonsThatCanEvolve)
+            {
+                var results = new List<PokemonData>();
+                var pokemonsThatCanBeTransfered = pokemonList.GroupBy(p => p.PokemonId)
+                    .Where(x => x.Count() > 1).ToList();
+
+                var myPokemonSettings = await GetPokemonSettings();
+                var pokemonSettings = myPokemonSettings as IList<PokemonSettings> ?? myPokemonSettings.ToList();
+
+                var myPokemonFamilies = await GetPokemonFamilies();
+                var pokemonFamilies = myPokemonFamilies as PokemonFamily[] ?? myPokemonFamilies.ToArray();
+
+                foreach (var pokemon in pokemonsThatCanBeTransfered)
+                {
+                    var settings = pokemonSettings.Single(x => x.PokemonId == pokemon.Key);
+                    var familyCandy = pokemonFamilies.Single(x => settings.FamilyId == x.FamilyId);
                     var amountToSkip = (familyCandy.Candy + settings.CandyToEvolve - 1)/settings.CandyToEvolve;

                     if (settings.EvolutionIds.Count == 0)
-                        continue;
-
-                    results.AddRange(pokemonList.Where(x => x.PokemonId == pokemon.Key && x.Favorite == 0)
-                        .OrderByDescending(x => x.Cp)
-                        .ThenBy(n => n.StaminaMax)
-                        .Skip(amountToSkip)
-                        .ToList());
-
-                }
-
-                return results;
-            }
-
-            return pokemonList
-                .GroupBy(p => p.PokemonId)
-                .Where(x => x.Count() > 1)
-                .SelectMany(p => p.Where(x => x.Favorite == 0).OrderByDescending(x => x.Cp).ThenBy(n => n.StaminaMax).Skip(1).ToList());
-        }
-
-        public async Task<IEnumerable<Item>> GetItems()
-        {
-            var inventory = await _client.GetInventory();
-            return inventory.InventoryDelta.InventoryItems
-                .Select(i => i.InventoryItemData?.Item)
-                .Where(p => p != null);
-        }
-
-        public async Task<int> GetItemAmountByType(MiscEnums.Item type)
-        {
-            var pokeballs = await GetItems();
-            return pokeballs.FirstOrDefault(i => (MiscEnums.Item)i.Item_ == type)?.Count ?? 0;
-        }
-
-        public async Task<IEnumerable<Item>> GetItemsToRecycle(ISettings settings)
-        {
-            var myItems = await GetItems();
-
-            return myItems
-                .Where(x => settings.itemRecycleFilter.Any(f => f.Key == ((ItemId)x.Item_) && x.Count > f.Value))
-                .Select(x => new Item { Item_ = x.Item_, Count = x.Count - settings.itemRecycleFilter.Single(f => f.Key == (AllEnum.ItemId)x.Item_).Value, Unseen = x.Unseen });
-        }
-    }
-}
+                        continue;
+
+                    results.AddRange(pokemonList.Where(x => x.PokemonId == pokemon.Key && x.Favorite == 0)
+                        .OrderByDescending(x => x.Cp)
+                        .ThenBy(n => n.StaminaMax)
+                        .Skip(amountToSkip)
+                        .ToList());
+
+                }
+
+                return results;
+            }
+
+            return pokemonList
+                .GroupBy(p => p.PokemonId)
+                .Where(x => x.Count() > 1)
+                .SelectMany(p => p.Where(x => x.Favorite == 0).OrderByDescending(x => x.Cp).ThenBy(n => n.StaminaMax).Skip(1).ToList());
+        }
+
+        public async Task<IEnumerable<Item>> GetItems()
+        {
+            var inventory = await _client.GetInventory();
+            return inventory.InventoryDelta.InventoryItems
+                .Select(i => i.InventoryItemData?.Item)
+                .Where(p => p != null);
+        }
+
+        public async Task<int> GetItemAmountByType(MiscEnums.Item type)
+        {
+            var pokeballs = await GetItems();
+            return pokeballs.FirstOrDefault(i => (MiscEnums.Item)i.Item_ == type)?.Count ?? 0;
+        }
+
+        public async Task<IEnumerable<Item>> GetItemsToRecycle(ISettings settings)
+        {
+            var myItems = await GetItems();
+
+            return myItems
+                .Where(x => settings.itemRecycleFilter.Any(f => f.Key == ((ItemId)x.Item_) && x.Count > f.Value))
+                .Select(x => new Item { Item_ = x.Item_, Count = x.Count - settings.itemRecycleFilter.Single(f => f.Key == (AllEnum.ItemId)x.Item_).Value, Unseen = x.Unseen });
+        }
+    }
+}
diff --git a/PokemonGo.RocketAPI.Logic/Logic.cs b/PokemonGo.RocketAPI.Logic/Logic.cs
index 193bd60..e84c1b2 100644
--- a/PokemonGo.RocketAPI.Logic/Logic.cs
+++ b/PokemonGo.RocketAPI.Logic/Logic.cs
@@ -50,7 +50,7 @@ namespace PokemonGo.RocketAPI.Logic
                 try
                 {
                     await _client.SetServer();
-                    await TransferDuplicatePokemon(true);
+                    await TransferDuplicatePokemon(false);
                     await RecycleItems();
                     await RepeatAction(10, async () => await ExecuteFarmingPokestopsAndPokemons(_client));

@@ -154,7 +154,7 @@ namespace PokemonGo.RocketAPI.Logic
                 Logger.Normal(ConsoleColor.Yellow, caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess ? $"We caught a {pokemon.PokemonId} with CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp}, used {balls_used} x {pokeball} and received XP {caughtPokemonResponse.Scores.Xp.Sum()}" : $"{pokemon.PokemonId} with CP {encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp} got away while using a {pokeball}..");

                 await RandomHelper.RandomDelay(500, 1000);
-                await TransferDuplicatePokemon(true);
+                await TransferDuplicatePokemon(false);

                 await RandomHelper.RandomDelay(2500, 5000);
             }
@@ -206,7 +206,7 @@ namespace PokemonGo.RocketAPI.Logic
             foreach (var item in items)
             {
                 var transfer = await _client.RecycleItem((AllEnum.ItemId)item.Item_, item.Count);
-                Logger.Normal(ConsoleColor.DarkBlue, $"Recycled {item.Count}x {(AllEnum.ItemId)item.Item_}");
+                Logger.Normal(ConsoleColor.DarkCyan, $"Recycled {item.Count}x {(AllEnum.ItemId)item.Item_}");

                 _stats.addItemsRemoved(item.Count);
                 _stats.updateConsoleTitle();
You may download the files in Public Git.