Merge branch

FeroxRev [2016-07-21 00:43:54]
Merge branch
Filename
PokemonGo/RocketAPI/Client.cs
PokemonGo/RocketAPI/Console/Program.cs
diff --git a/PokemonGo/RocketAPI/Client.cs b/PokemonGo/RocketAPI/Client.cs
index 55f434e..e9a8c73 100644
--- a/PokemonGo/RocketAPI/Client.cs
+++ b/PokemonGo/RocketAPI/Client.cs
@@ -291,5 +291,21 @@ namespace PokemonGo.RocketAPI
             var inventoryRequest = RequestBuilder.GetRequest(_unknownAuth, _currentLat, _currentLng, 30, RequestType.GET_INVENTORY);
             return await _httpClient.PostProtoPayload<Request, GetInventoryResponse>($"https://{_apiUrl}/rpc", inventoryRequest);
         }
+
+        public async Task<InventoryResponse.Types.TransferPokemonOutProto> TransferPokemon(ulong pokemonId)
+        {
+            var customRequest = new InventoryResponse.Types.TransferPokemonProto
+            {
+                PokemonId = pokemonId
+            };
+
+            var releasePokemonRequest = RequestBuilder.GetRequest(_unknownAuth, _currentLat, _currentLng, 30,
+                new Request.Types.Requests()
+                {
+                    Type = (int)RequestType.RELEASE_POKEMON,
+                    Message = customRequest.ToByteString()
+                });
+            return await _httpClient.PostProto<Request, InventoryResponse.Types.TransferPokemonOutProto>($"https://{_apiUrl}/rpc", releasePokemonRequest);
+        }
     }
 }
diff --git a/PokemonGo/RocketAPI/Console/Program.cs b/PokemonGo/RocketAPI/Console/Program.cs
index a15a1e2..0328577 100644
--- a/PokemonGo/RocketAPI/Console/Program.cs
+++ b/PokemonGo/RocketAPI/Console/Program.cs
@@ -39,7 +39,7 @@ namespace PokemonGo.RocketAPI.Console
             });
              System.Console.ReadLine();
         }
-
+
         static async void Execute()
         {
             var client = new Client(ClientSettings);
@@ -82,6 +82,8 @@ namespace PokemonGo.RocketAPI.Console
             }
         }

+        private static int checkForDuplicates = -1;
+
         private static async Task ExecuteCatchAllNearbyPokemons(Client client)
         {
             var mapObjects = await client.GetMapObjects();
@@ -100,7 +102,31 @@ namespace PokemonGo.RocketAPI.Console
                 }
                 while(caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed);

-                System.Console.WriteLine(caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess ? $"[{DateTime.Now.ToString("HH:mm:ss")}] We caught a {pokemon.PokemonId}" : $"[{DateTime.Now.ToString("HH:mm:ss")}] {pokemon.PokemonId} got away..");
+                System.Console.WriteLine(caughtPokemonResponse.Payload[0].Status == 1 ? $"We caught a {GetFriendlyPokemonName(pokemon.PokedexTypeId)}" : $"{GetFriendlyPokemonName(pokemon.PokedexTypeId)} got away..");
+
+                checkForDuplicates++;
+                if (checkForDuplicates % 50 == 0)
+                {
+                    checkForDuplicates = 0;
+                    System.Console.WriteLine($"Check for duplicates");
+                    var inventory = await client.GetInventory();
+                    var allpokemons = inventory.Payload[0].Bag.Items.Select(i => i.Item?.Pokemon).Where(p => p != null && p?.PokemonType != InventoryResponse.Types.PokemonProto.Types.PokemonIds.PokemonUnset);
+
+                    var dupes = allpokemons.OrderBy(x => x.Cp).Select((x, i) => new { index = i, value = x })
+                      .GroupBy(x => x.value.PokemonType)
+                      .Where(x => x.Skip(1).Any());
+
+                    for (int i = 0; i < dupes.Count(); i++)
+                    {
+                        for (int j = 0; j < dupes.ElementAt(i).Count() - 1; j++)
+                        {
+                            var dubpokemon = dupes.ElementAt(i).ElementAt(j).value;
+                            var transfer = await client.TransferPokemon(dubpokemon.Id);
+                            System.Console.WriteLine($"Transfer {dubpokemon.PokemonType} with {dubpokemon.Cp} CP (highest has {dupes.ElementAt(i).Last().value.Cp})");
+                        }
+                    }
+                }
+
                 await Task.Delay(5000);
             }
         }
You may download the files in Public Git.