add program transfer all but strongest unwanted pokemon

Martin Podlubny [2016-07-20 18:43:46]
add program transfer all but strongest unwanted pokemon
Filename
PokemonGo/RocketAPI/Console/Program.cs
diff --git a/PokemonGo/RocketAPI/Console/Program.cs b/PokemonGo/RocketAPI/Console/Program.cs
index 043f242..0f0d7dc 100644
--- a/PokemonGo/RocketAPI/Console/Program.cs
+++ b/PokemonGo/RocketAPI/Console/Program.cs
@@ -10,6 +10,7 @@ using PokemonGo.RocketAPI.Extensions;
 using PokemonGo.RocketAPI.GeneratedCode;
 using PokemonGo.RocketAPI.Helpers;
 using static PokemonGo.RocketAPI.GeneratedCode.InventoryResponse.Types;
+using static PokemonGo.RocketAPI.GeneratedCode.InventoryResponse.Types.PokemonProto.Types;

 namespace PokemonGo.RocketAPI.Console
 {
@@ -168,7 +169,56 @@ namespace PokemonGo.RocketAPI.Console
                 await Task.Delay(3000);
             }
         }
+
+        private static async Task TransferAllButStrongestUnwantedPokemon(Client client)
+        {
+            System.Console.WriteLine("[!] firing up the meat grinder");
+
+            var unwantedPokemonTypes = new[]
+            {
+                PokemonIds.V0016PokemonPidgey,
+                PokemonIds.V0019PokemonRattata,
+                PokemonIds.V0013PokemonWeedle,
+                PokemonIds.V0041PokemonZubat,
+                PokemonIds.V0010PokemonCaterpie,
+                PokemonIds.V0017PokemonPidgeotto,
+                PokemonIds.V0029PokemonNidoran,
+                PokemonIds.V0046PokemonParas,
+                PokemonIds.V0048PokemonVenonat,
+                PokemonIds.V0054PokemonPsyduck,
+                PokemonIds.V0060PokemonPoliwag,
+                PokemonIds.V0079PokemonSlowpoke,
+                PokemonIds.V0096PokemonDrowzee,
+                PokemonIds.V0092PokemonGastly,
+                PokemonIds.V0118PokemonGoldeen,
+                PokemonIds.V0120PokemonStaryu,
+                PokemonIds.V0129PokemonMagikarp,
+                PokemonIds.V0133PokemonEevee,
+                PokemonIds.V0147PokemonDratini
+            };

+            var inventory = await client.GetInventory();
+            var pokemons = inventory.Payload[0].Bag
+                                .Items
+                                .Select(i => i.Item?.Pokemon)
+                                .Where(p => p != null && p?.PokemonType != PokemonIds.PokemonUnset)
+                                .ToArray();
+
+            foreach (var unwantedPokemonType in unwantedPokemonTypes)
+            {
+                var pokemonOfDesiredType = pokemons.Where(p => p.PokemonType == unwantedPokemonType)
+                                                   .OrderByDescending(p => p.Cp)
+                                                   .ToList();
+
+                var unwantedPokemon = pokemonOfDesiredType.Skip(1) // keep the strongest one for potential battle-evolving
+                                                          .ToList();
+
+                System.Console.WriteLine($"Grinding {unwantedPokemon.Count} pokemons of type {unwantedPokemonType}");
+                await TransferAllGivenPokemons(client, unwantedPokemon);
+            }
+
+            System.Console.WriteLine("[!] finished grinding all the meat");
+        }

         private static string GetFriendlyPokemonName(MapObjectsResponse.Types.Payload.Types.PokemonIds id)
         {
You may download the files in Public Git.