Fix TransferPokemon and some wrong var references

FeroxRev [2016-07-21 07:49:19]
Fix TransferPokemon and some wrong var references
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 22553b5..8635667 100644
--- a/PokemonGo.RocketAPI.Logic/Inventory.cs
+++ b/PokemonGo.RocketAPI.Logic/Inventory.cs
@@ -27,10 +27,10 @@ namespace PokemonGo.RocketAPI.Logic
         {
             var myPokemon = await GetMyPokemon();

-            return myPokemon.OrderBy(x => x.Cp)
+            return myPokemon
                 .GroupBy(p => p.PokemonId)
                 .Where(x => x.Count() > 1)
-                .SelectMany(p => p.Skip(1).ToList());
+                .SelectMany(p => p.OrderByDescending(x => x.Cp).Skip(1).ToList());
         }
     }
 }
diff --git a/PokemonGo.RocketAPI.Logic/Logic.cs b/PokemonGo.RocketAPI.Logic/Logic.cs
index 9ff9318..a1d566b 100644
--- a/PokemonGo.RocketAPI.Logic/Logic.cs
+++ b/PokemonGo.RocketAPI.Logic/Logic.cs
@@ -27,33 +27,31 @@ namespace PokemonGo.RocketAPI.Logic
         public async void Execute()
         {
             Console.WriteLine($"Starting Execute on login server: {_clientSettings.AuthType}");
-
-            var client = new Client(_clientSettings);
-
+
             if (_clientSettings.AuthType == AuthType.Ptc)
-                await client.DoPtcLogin(_clientSettings.PtcUsername, _clientSettings.PtcPassword);
+                await _client.DoPtcLogin(_clientSettings.PtcUsername, _clientSettings.PtcPassword);
             else if (_clientSettings.AuthType == AuthType.Google)
-                await client.DoGoogleLogin();
+                await _client.DoGoogleLogin();

             while (true)
             {
                 try
                 {
-                    await client.SetServer();
-                    //await RepeatAction(10, async () => await ExecuteFarmingPokestopsAndPokemons(client));
+                    await _client.SetServer();
+                    await RepeatAction(10, async () => await ExecuteFarmingPokestopsAndPokemons(_client));
                     await TransferDuplicatePokemon();

                     /*
                 * Example calls below
                 *
-                var profile = await client.GetProfile();
-                var settings = await client.GetSettings();
-                var mapObjects = await client.GetMapObjects();
-                var inventory = await client.GetInventory();
+                var profile = await _client.GetProfile();
+                var settings = await _client.GetSettings();
+                var mapObjects = await _client.GetMapObjects();
+                var inventory = await _client.GetInventory();
                 var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon).Where(p => p != null && p?.PokemonId > 0);
                 */
                 }
-                catch(Exception ex)
+                catch (Exception ex)
                 {
                     Console.WriteLine($"Exception: {ex}");
                 }
@@ -141,6 +139,7 @@ namespace PokemonGo.RocketAPI.Logic
             {
                 var transfer = await _client.TransferPokemon(duplicatePokemon.Id);
                 System.Console.WriteLine($"Transfer {duplicatePokemon.PokemonId} with {duplicatePokemon.Cp})");
+                await Task.Delay(500);
             }
         }
     }
You may download the files in Public Git.