Fixed IV not showing

Brian [2016-08-10 04:54:42]
Fixed IV not showing
Filename
PokemonGo/RocketAPI/Window/App.config
PokemonGo/RocketAPI/Window/Extensions.cs
PokemonGo/RocketAPI/Window/MainForm.cs
PokemonGo/RocketAPI/Window/PokemonGo.RocketBot.csproj
PokemonGo/RocketAPI/Window/Properties/AssemblyInfo.cs
PokemonGo/RocketAPI/Window/SettingsForm.Designer.cs
PokemonGo/RocketAPI/Window/SettingsForm.cs
diff --git a/PokemonGo/RocketAPI/Window/App.config b/PokemonGo/RocketAPI/Window/App.config
index bdadf3e..c59cc2e 100644
--- a/PokemonGo/RocketAPI/Window/App.config
+++ b/PokemonGo/RocketAPI/Window/App.config
@@ -54,7 +54,7 @@
     <!--transfer pokemon with CP less than this value if cp transfer type is selected. Whitelist in Program.cs-->
     <add key="TransferIVThreshold" value="0" />
     <!--transfer pokemon with IV less than this value if iv transfer type is selected. Whitelist in Program.cs-->
-    <add key="TravelSpeed" value="60" />
+    <add key="TravelSpeed" value="20" />
     <!--The speed to travel in km/h-->
     <add key="ImageSize" value="50" />
     <!--PokeUi image size-->
diff --git a/PokemonGo/RocketAPI/Window/Extensions.cs b/PokemonGo/RocketAPI/Window/Extensions.cs
new file mode 100644
index 0000000..29ea9ff
--- /dev/null
+++ b/PokemonGo/RocketAPI/Window/Extensions.cs
@@ -0,0 +1,17 @@
+using POGOProtos.Data;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PokemonGo.RocketAPI.Window
+{
+    public static class Extensions
+    {
+        public static float GetIV(this PokemonData poke)
+        {
+            return (poke.IndividualAttack + poke.IndividualDefense + poke.IndividualStamina) / 45.0f;
+        }
+    }
+}
diff --git a/PokemonGo/RocketAPI/Window/MainForm.cs b/PokemonGo/RocketAPI/Window/MainForm.cs
index 6e94dce..91ee305 100644
--- a/PokemonGo/RocketAPI/Window/MainForm.cs
+++ b/PokemonGo/RocketAPI/Window/MainForm.cs
@@ -4,6 +4,7 @@ using System.Drawing;
 using System.IO;
 using System.Linq;
 using System.Net;
+using System.Reflection;
 using System.Text.RegularExpressions;
 using System.Threading;
 using System.Threading.Tasks;
@@ -20,12 +21,14 @@ using PokemonGo.RocketAPI.Extensions;
 using PokemonGo.RocketAPI.Helpers;
 using POGOProtos.Data;
 using POGOProtos.Enums;
+using POGOProtos.Inventory;
 using POGOProtos.Inventory.Item;
 using POGOProtos.Map.Fort;
 using POGOProtos.Map.Pokemon;
 using POGOProtos.Networking.Responses;
 using static System.Reflection.Assembly;

+
 namespace PokemonGo.RocketAPI.Window
 {
     public partial class MainForm : Form
@@ -72,12 +75,6 @@ namespace PokemonGo.RocketAPI.Window
             CenterToScreen();
         }

-        public sealed override string Text
-        {
-            get { return base.Text; }
-            set { base.Text = value; }
-        }
-
         private void MainForm_Load(object sender, EventArgs e)
         {
             gMapControl1.MapProvider = GoogleMapProvider.Instance;
@@ -133,7 +130,7 @@ namespace PokemonGo.RocketAPI.Window

         public static double GetRuntime()
         {
-            return (DateTime.Now - TimeStarted).TotalSeconds/3600;
+            return (DateTime.Now - TimeStarted).TotalSeconds / 3600;
         }

         public void CheckVersion()
@@ -155,7 +152,7 @@ namespace PokemonGo.RocketAPI.Window
                             match.Groups[3],
                             match.Groups[4]));
                 // makes sense to display your version and say what the current one is on github
-                ColoredConsoleWrite(Color.Green, "Your version is " + GetExecutingAssembly().GetName().Version);
+                ColoredConsoleWrite(Color.Green, "Your version is " + Assembly.GetExecutingAssembly().GetName().Version);
                 ColoredConsoleWrite(Color.Green, "Github version is " + gitVersion);
                 ColoredConsoleWrite(Color.Green,
                     "You can find it at www.GitHub.com/1461748123/Pokemon-Go-Rocket-API/releases");
@@ -297,8 +294,8 @@ namespace PokemonGo.RocketAPI.Window
                 }
                 else
                 {
-                    ColoredConsoleWrite(Color.Cyan, "Email: " + ClientSettings.Email);
-                    ColoredConsoleWrite(Color.Cyan, "Password: " + ClientSettings.Password + "\n");
+                    ColoredConsoleWrite(Color.Cyan, "Email: " + ClientSettings.GoogleUsername);
+                    ColoredConsoleWrite(Color.Cyan, "Password: " + ClientSettings.GooglePassword + "\n");
                 }*/
                 var lat2 = Convert.ToString(ClientSettings.DefaultLatitude);
                 var longit2 = Convert.ToString(ClientSettings.DefaultLongitude);
@@ -334,7 +331,7 @@ namespace PokemonGo.RocketAPI.Window
                         await TransferAllButStrongestUnwantedPokemon(_client);
                         break;
                     case "All":
-                        await TransferAllGivenPokemons(_client, pokemons);
+                        await TransferAllGivenPokemons(_client, pokemons, ClientSettings.TransferIvThreshold);
                         break;
                     case "Duplicate":
                         await TransferDuplicatePokemon(_client);
@@ -360,8 +357,11 @@ namespace PokemonGo.RocketAPI.Window
                     RecycleItems(_client);
                 //client.RecycleItems(client);

+                if (ClientSettings.TravelSpeed > 30)
+                    ColoredConsoleWrite(Color.Red, "WARNING: You are travelling over 30km/h. Your ip might get flag!");
                 await Task.Delay(5000);
                 PrintLevel(_client);
+
                 await ExecuteFarmingPokestopsAndPokemons(_client);

                 while (_forceUnbanning)
@@ -370,8 +370,8 @@ namespace PokemonGo.RocketAPI.Window
                 // await ForceUnban(client);
                 if (!_stopping)
                 {
-                    ColoredConsoleWrite(Color.Red, $"No nearby useful locations found. Please wait 10 seconds.");
-                    await Task.Delay(10000);
+                    ColoredConsoleWrite(Color.Red, $"No nearby useful locations found. Please wait 5 seconds.");
+                    await Task.Delay(5000);
                     Execute();
                 }
                 else
@@ -411,6 +411,25 @@ namespace PokemonGo.RocketAPI.Window
                 ColoredConsoleWrite(Color.Red, "Null Refference - Restarting");
                 if (!_stopping) Execute();
             }
+            catch (AccessTokenExpiredException)
+            {
+                ColoredConsoleWrite(Color.Red, "Access Token Expired - Restarting");
+                if (!_stopping) Execute();
+            }
+            catch (GoogleException ex)
+            {
+                ColoredConsoleWrite(Color.Red, "Please check your google login information again");
+            }
+            catch (LoginFailedException)
+            {
+                ColoredConsoleWrite(Color.Red, "Login failed, please check your ptc login information again");
+            }
+            catch (InvalidResponseException)
+            {
+                ColoredConsoleWrite(Color.Red, "Invalid response - Restarting");
+                if (!_stopping) Execute();
+            }
+
             catch (Exception ex)
             {
                 ColoredConsoleWrite(Color.Red, ex.ToString());
@@ -481,7 +500,7 @@ namespace PokemonGo.RocketAPI.Window
                     var request =
                         (HttpWebRequest)
                             WebRequest.Create("http://boosting-service.de/pokemon/index.php?pokeName=" + name_english);
-                    var response = (HttpWebResponse) request.GetResponse();
+                    var response = (HttpWebResponse)request.GetResponse();
                     pokemonName = new StreamReader(response.GetResponseStream()).ReadToEnd();
                 }
                 else
@@ -492,14 +511,14 @@ namespace PokemonGo.RocketAPI.Window
                 UpdateMap();
                 var encounterPokemonResponse =
                     await client.Encounter.EncounterPokemon(pokemon.EncounterId, pokemon.SpawnPointId);
-                var pokemonCP = encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp;
-                var pokemonIV = Math.Round(Perfect(encounterPokemonResponse?.WildPokemon?.PokemonData));
+                var pokemonCp = encounterPokemonResponse?.WildPokemon?.PokemonData?.Cp;
+                var pokemonIv = Math.Round(Perfect(encounterPokemonResponse?.WildPokemon?.PokemonData));
                 CatchPokemonResponse caughtPokemonResponse;
-                ColoredConsoleWrite(Color.Green, $"Encounter a {pokemonName} with {pokemonCP} CP and {pokemonIV}% IV");
+                ColoredConsoleWrite(Color.Green, $"Encounter a {pokemonName} with {pokemonCp} CP and {pokemonIv}% IV");
                 do
                 {
                     if (ClientSettings.RazzBerryMode == "cp")
-                        if (pokemonCP > ClientSettings.RazzBerrySetting)
+                        if (pokemonCp > ClientSettings.RazzBerrySetting)
                             await UseRazzBerry(client, pokemon.EncounterId, pokemon.SpawnPointId);
                     if (ClientSettings.RazzBerryMode == "probability")
                         if (encounterPokemonResponse.CaptureProbability.CaptureProbability_.First() <
@@ -508,7 +527,7 @@ namespace PokemonGo.RocketAPI.Window
                     caughtPokemonResponse =
                         await
                             CatchPokemon(pokemon.EncounterId, pokemon.SpawnPointId, pokemon.Latitude, pokemon.Longitude,
-                                ItemId.ItemPokeBall, pokemonCP);
+                                ItemId.ItemPokeBall, pokemonCp);
                     ; //note: reverted from settings because this should not be part of settings but part of logic
                 } while (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchMissed ||
                          caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchEscape);
@@ -516,18 +535,18 @@ namespace PokemonGo.RocketAPI.Window
                 if (caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess)
                 {
                     var c = Color.LimeGreen;
-                    if (pokemonIV >= 80)
+                    if (pokemonIv >= 80)
                     {
                         c = Color.Yellow;
                     }
-                    ColoredConsoleWrite(c, $"We caught a {pokemonName} with {pokemonCP} CP and {pokemonIV}% IV");
+                    ColoredConsoleWrite(c, $"We caught a {pokemonName} with {pokemonCp} CP and {pokemonIv}% IV");
                     //foreach (int xp in caughtPokemonResponse.CaptureAward.Xp)
                     //    TotalExperience += xp;
                     _totalExperience += caughtPokemonResponse.CaptureAward.Xp.Sum();
                     _totalPokemon += 1;
                 }
                 else
-                    ColoredConsoleWrite(Color.Red, $"{pokemonName} with {pokemonCP} CP and {pokemonIV}% IV got away..");
+                    ColoredConsoleWrite(Color.Red, $"{pokemonName} with {pokemonCp} CP and {pokemonIv}% IV got away..");


                 // I believe a switch is more efficient and easier to read.
@@ -537,7 +556,7 @@ namespace PokemonGo.RocketAPI.Window
                         await TransferAllButStrongestUnwantedPokemon(client);
                         break;
                     case "All":
-                        await TransferAllGivenPokemons(client, pokemons2);
+                        await TransferAllGivenPokemons(client, pokemons2, ClientSettings.TransferIvThreshold);
                         break;
                     case "Duplicate":
                         await TransferDuplicatePokemon(client);
@@ -566,7 +585,7 @@ namespace PokemonGo.RocketAPI.Window
         {
             SynchronizationContext.Post(o =>
             {
-                _playerMarker.Position = (PointLatLng) o;
+                _playerMarker.Position = (PointLatLng)o;

                 _searchAreaOverlay.Polygons.Clear();
             }, new PointLatLng(latitude, longitude));
@@ -755,7 +774,7 @@ namespace PokemonGo.RocketAPI.Window
                 return string.Empty;

             return enumerable.GroupBy(i => i.ItemId)
-                .Select(kvp => new {ItemName = kvp.Key.ToString().Substring(4), Amount = kvp.Sum(x => x.ItemCount)})
+                .Select(kvp => new { ItemName = kvp.Key.ToString().Substring(4), Amount = kvp.Sum(x => x.ItemCount) })
                 .Select(y => $"{y.Amount}x {y.ItemName}")
                 .Aggregate((a, b) => $"{a}, {b}");
         }
@@ -766,7 +785,7 @@ namespace PokemonGo.RocketAPI.Window
             var unwantedPokemonTypes = new List<PokemonId>();
             for (var i = 1; i <= 151; i++)
             {
-                unwantedPokemonTypes.Add((PokemonId) i);
+                unwantedPokemonTypes.Add((PokemonId)i);
             }

             var inventory = await client.Inventory.GetInventory();
@@ -791,7 +810,7 @@ namespace PokemonGo.RocketAPI.Window

         public static float Perfect(PokemonData poke)
         {
-            return (poke.IndividualAttack + poke.IndividualDefense + poke.IndividualStamina)/(3.0f*15.0f)*100.0f;
+            return (poke.IndividualAttack + poke.IndividualDefense + poke.IndividualStamina) / (3.0f * 15.0f) * 100.0f;
         }

         private async Task TransferAllGivenPokemons(Client client, IEnumerable<PokemonData> unwantedPokemons,
@@ -825,7 +844,7 @@ namespace PokemonGo.RocketAPI.Window
                             (HttpWebRequest)
                                 WebRequest.Create("http://boosting-service.de/pokemon/index.php?pokeName=" +
                                                   name_english);
-                        var response = (HttpWebResponse) request.GetResponse();
+                        var response = (HttpWebResponse)request.GetResponse();
                         pokemonName = new StreamReader(response.GetResponseStream()).ReadToEnd();
                     }
                     else
@@ -856,7 +875,7 @@ namespace PokemonGo.RocketAPI.Window
                 inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokemonData)
                     .Where(p => p != null && p?.PokemonId > 0);

-            var dupes = allpokemons.OrderBy(x => x.Cp).Select((x, i) => new {index = i, value = x})
+            var dupes = allpokemons.OrderBy(x => x.Cp).Select((x, i) => new { index = i, value = x })
                 .GroupBy(x => x.value.PokemonId)
                 .Where(x => x.Skip(1).Any());

@@ -876,7 +895,7 @@ namespace PokemonGo.RocketAPI.Window
                                 (HttpWebRequest)
                                     WebRequest.Create("http://boosting-service.de/pokemon/index.php?pokeName=" +
                                                       name_english);
-                            var response = (HttpWebResponse) request.GetResponse();
+                            var response = (HttpWebResponse)request.GetResponse();
                             pokemonName = new StreamReader(response.GetResponseStream()).ReadToEnd();
                         }
                         else
@@ -896,7 +915,7 @@ namespace PokemonGo.RocketAPI.Window
                 inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokemonData)
                     .Where(p => p != null && p?.PokemonId > 0);

-            var dupes = allpokemons.OrderBy(x => Perfect(x)).Select((x, i) => new {index = i, value = x})
+            var dupes = allpokemons.OrderBy(x => Perfect(x)).Select((x, i) => new { index = i, value = x })
                 .GroupBy(x => x.value.PokemonId)
                 .Where(x => x.Skip(1).Any());

@@ -916,7 +935,7 @@ namespace PokemonGo.RocketAPI.Window
                                 (HttpWebRequest)
                                     WebRequest.Create("http://boosting-service.de/pokemon/index.php?pokeName=" +
                                                       name_english);
-                            var response = (HttpWebResponse) request.GetResponse();
+                            var response = (HttpWebResponse)request.GetResponse();
                             pokemonName = new StreamReader(response.GetResponseStream()).ReadToEnd();
                         }
                         else
@@ -1008,7 +1027,7 @@ namespace PokemonGo.RocketAPI.Window
             if (ClientSettings.LevelOutput == "levelup")
                 await Task.Delay(1000);
             else
-                await Task.Delay(ClientSettings.LevelTimeInterval*1000);
+                await Task.Delay(ClientSettings.LevelTimeInterval * 1000);
             PrintLevel(client);
         }

@@ -1034,10 +1053,10 @@ namespace PokemonGo.RocketAPI.Window
                     //Calculating the exp needed to level up
                     float expNextLvl = v.NextLevelXp - v.Experience;
                     //Calculating the exp made per second
-                    xpSec = Math.Round(_totalExperience/GetRuntime())/60/60;
+                    xpSec = Math.Round(_totalExperience / GetRuntime()) / 60 / 60;
                     //Calculating the seconds left to level up
                     if (xpSec != 0)
-                        secondsLeft = Convert.ToInt32(expNextLvl/xpSec);
+                        secondsLeft = Convert.ToInt32(expNextLvl / xpSec);
                     //formatting data to make an output like DateFormat
                     while (secondsLeft > 60)
                     {
@@ -1058,8 +1077,8 @@ namespace PokemonGo.RocketAPI.Window
                             " | Level: {0:0} - ({2:0} / {3:0}) | Runtime {1} | Stardust: {4:0}", v.Level,
                             _getSessionRuntimeInTimeFormat(), v.Experience - v.PrevLevelXp - XpDiff,
                             v.NextLevelXp - v.PrevLevelXp - XpDiff, profile.PlayerData.Currencies.ToArray()[1].Amount) +
-                        " | XP/Hour: " + Math.Round(_totalExperience/GetRuntime()) + " | Pokemon/Hour: " +
-                        Math.Round(_totalPokemon/GetRuntime()) + " | NextLevel in: " + hoursLeft + ":" + minutesLeft +
+                        " | XP/Hour: " + Math.Round(_totalExperience / GetRuntime()) + " | Pokemon/Hour: " +
+                        Math.Round(_totalPokemon / GetRuntime()) + " | NextLevel in: " + hoursLeft + ":" + minutesLeft +
                         ":" + secondsLeft);
                 }
             await Task.Delay(1000);
@@ -1242,31 +1261,36 @@ namespace PokemonGo.RocketAPI.Window
         {
             if (_client != null)
             {
-                try
+                if (
+                    MessageBox.Show($"Are you sure you want to use a lucky egg?", "Confirmation",
+                        MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
-                    var myItems = await GetItems(_client);
-                    var LuckyEggs = myItems.Where(i => i.ItemId == ItemId.ItemLuckyEgg);
-                    var LuckyEgg = LuckyEggs.FirstOrDefault();
-                    if (LuckyEgg != null)
+                    try
                     {
-                        var useItemXpBoostRequest = await _client.Inventory.UseItemXpBoost();
-                        ColoredConsoleWrite(Color.Green, $"Using a Lucky Egg, we have {LuckyEgg.Count} left.");
-                        ColoredConsoleWrite(Color.Yellow, $"Lucky Egg Valid until: {DateTime.Now.AddMinutes(30)}");
-
-                        var stripItem = sender as ToolStripMenuItem;
-                        stripItem.Enabled = false;
-                        await Task.Delay(30000);
-                        stripItem.Enabled = true;
+                        var myItems = await GetItems(_client);
+                        var LuckyEggs = myItems.Where(i => i.ItemId == ItemId.ItemLuckyEgg);
+                        var LuckyEgg = LuckyEggs.FirstOrDefault();
+                        if (LuckyEgg != null)
+                        {
+                            var useItemXpBoostRequest = await _client.Inventory.UseItemXpBoost();
+                            ColoredConsoleWrite(Color.Green, $"Using a Lucky Egg, we have {LuckyEgg.Count} left.");
+                            ColoredConsoleWrite(Color.Yellow, $"Lucky Egg Valid until: {DateTime.Now.AddMinutes(30)}");
+
+                            var stripItem = sender as ToolStripMenuItem;
+                            stripItem.Enabled = false;
+                            await Task.Delay(30000);
+                            stripItem.Enabled = true;
+                        }
+                        else
+                        {
+                            ColoredConsoleWrite(Color.Red, $"You don't have any Lucky Egg to use.");
+                        }
                     }
-                    else
+                    catch (Exception ex)
                     {
-                        ColoredConsoleWrite(Color.Red, $"You don't have any Lucky Egg to use.");
+                        ColoredConsoleWrite(Color.Red, $"Unhandled exception in using lucky egg: {ex}");
                     }
                 }
-                catch (Exception ex)
-                {
-                    ColoredConsoleWrite(Color.Red, $"Unhandled exception in using lucky egg: {ex}");
-                }
             }
             else
             {
@@ -1306,91 +1330,85 @@ namespace PokemonGo.RocketAPI.Window

         private void pokemonToolStripMenuItem2_Click(object sender, EventArgs e)
         {
-
         }

         private void pokeToolStripMenuItem_Click(object sender, EventArgs e)
         {
         }

-        private void objectListView1_SelectedIndexChanged(object sender, EventArgs e)
-        {
-        }
-
         #region POKEMON LIST

-        private IEnumerable<PokemonFamilyId> families;
+        private IEnumerable<Candy> families;

         private void InitializePokemonForm()
         {
             objectListView1.ButtonClick += PokemonListButton_Click;

-            pkmnName.ImageGetter = delegate(object rowObject)
+            pkmnName.ImageGetter = delegate (object rowObject)
             {
-                var pokemon = (PokemonData) rowObject;
+                var pokemon = (PokemonData)rowObject;

                 var key = pokemon.PokemonId.ToString();
                 if (!objectListView1.SmallImageList.Images.ContainsKey(key))
                 {
-                    var img = GetPokemonImage((int) pokemon.PokemonId);
+                    var img = GetPokemonImage((int)pokemon.PokemonId);
                     objectListView1.SmallImageList.Images.Add(key, img);
                 }
                 return key;
             };

-            objectListView1.CellToolTipShowing += delegate(object sender, ToolTipShowingEventArgs args)
+            objectListView1.CellToolTipShowing += delegate (object sender, ToolTipShowingEventArgs args)
             {
-                var pokemon = (PokemonData) args.Model;
+                var pokemon = (PokemonData)args.Model;

                 var family = families
-                    .Where(i => (int) i <= (int) pokemon.PokemonId)
+                    .Where(i => (int)i.FamilyId <= (int)pokemon.PokemonId)
                     .First();

-                args.Text = $"You have {GetCandies(pokemon.PokemonId).Result} {(PokemonId) family} Candy";
+                args.Text = $"You have {family.Candy_} {(PokemonId)family.FamilyId} Candy";
             };
         }

         private Image GetPokemonImage(int pokemonId)
         {
-            return (Image) Properties.Resources.ResourceManager.GetObject("Pokemon_" + pokemonId);
+            return (Image)Properties.Resources.ResourceManager.GetObject("Pokemon_" + pokemonId);
         }

-        public async Task<int> GetCandies(PokemonId poke)
-        {
-            var inventory = await _client.Inventory.GetInventory();
-            var templates = await _client.Download.GetItemTemplates();
-            var pokemontemplate =
-                templates.ItemTemplates.Select(i => i?.PokemonSettings).Where(i => i?.PokemonId == poke);
-            return
-                inventory.InventoryDelta.InventoryItems.Select(i => i?.InventoryItemData?.Candy)
-                    .Where(i => i?.FamilyId == pokemontemplate.SingleOrDefault().FamilyId)
-                    .SingleOrDefault()
-                    .Candy_;
-        }
-
-        private async void ReloadPokemonList()
+        private async Task ReloadPokemonList()
         {
             button1.Enabled = false;
             objectListView1.Enabled = false;

-            _client2 = new Client(ClientSettings, new ApiFailureStrategy());
             try
             {
+                _client2 = new Client(ClientSettings, new ApiFailureStrategy());
                 await _client2.Login.DoLogin();
                 var inventory = await _client2.Inventory.GetInventory();
                 var pokemons =
-                    inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokemonData)
+                    inventory.InventoryDelta.InventoryItems.Select(i => i?.InventoryItemData?.PokemonData)
                         .Where(p => p != null && p?.PokemonId > 0)
                         .OrderByDescending(key => key.Cp);
                 families = inventory.InventoryDelta.InventoryItems
-                    .Select(i => i.InventoryItemData.Candy.FamilyId)
-                    .Where(p => p > 0)
-                    .OrderByDescending(p => p);
+                    .Select(i => i.InventoryItemData.Candy)
+                    .Where(p => p != null && p.FamilyId > 0)
+                    .OrderByDescending(p => p.FamilyId);

                 var prevTopItem = objectListView1.TopItemIndex;
                 objectListView1.SetObjects(pokemons);
                 objectListView1.TopItemIndex = prevTopItem;
             }
+            catch (GoogleException ex)
+            {
+                ColoredConsoleWrite(Color.Red, "Please check your google login information again");
+            }
+            catch (LoginFailedException)
+            {
+                ColoredConsoleWrite(Color.Red, "Login failed, please check your ptc login information again");
+            }
+            catch (AccessTokenExpiredException ex)
+            {
+                ColoredConsoleWrite(Color.Red, ex.Message);
+            }
             catch (Exception ex)
             {
                 ColoredConsoleWrite(Color.Red, ex.ToString());
@@ -1405,7 +1423,7 @@ namespace PokemonGo.RocketAPI.Window
         {
             try
             {
-                var pokemon = (PokemonData) e.Model;
+                var pokemon = (PokemonData)e.Model;
                 if (e.ColumnIndex == 6)
                 {
                     TransferPokemon(pokemon);
@@ -1489,7 +1507,7 @@ namespace PokemonGo.RocketAPI.Window

         public async Task<IEnumerable<ItemData>> GetItemsToRecycle(ISettings _settings, Client client)
         {
-            var settings = (Settings) _settings;
+            var settings = (Settings)_settings;
             var myItems = await GetItems(client);

             return myItems
@@ -1514,7 +1532,7 @@ namespace PokemonGo.RocketAPI.Window
                 ColoredConsoleWrite(Color.DarkCyan, $"Recycled {item.Count}x {item.ItemId.ToString().Substring(4)}");
                 await Task.Delay(500);
             }
-            await Task.Delay(ClientSettings.RecycleItemsInterval*1000);
+            await Task.Delay(ClientSettings.RecycleItemsInterval * 1000);
             RecycleItems(client);
         }

@@ -1549,20 +1567,20 @@ namespace PokemonGo.RocketAPI.Window
             var ballCollection = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Item)
                 .Where(p => p != null)
                 .GroupBy(i => i.ItemId)
-                .Select(kvp => new {ItemId = kvp.Key, Amount = kvp.Sum(x => x.Count)})
+                .Select(kvp => new { ItemId = kvp.Key, Amount = kvp.Sum(x => x.Count) })
                 .Where(y => y.ItemId == ItemId.ItemPokeBall
                             || y.ItemId == ItemId.ItemGreatBall
                             || y.ItemId == ItemId.ItemUltraBall
                             || y.ItemId == ItemId.ItemMasterBall);

             var pokeBallsCount = ballCollection.Where(p => p.ItemId == ItemId.ItemPokeBall).
-                DefaultIfEmpty(new {ItemId = ItemId.ItemPokeBall, Amount = 0}).FirstOrDefault().Amount;
+                DefaultIfEmpty(new { ItemId = ItemId.ItemPokeBall, Amount = 0 }).FirstOrDefault().Amount;
             var greatBallsCount = ballCollection.Where(p => p.ItemId == ItemId.ItemGreatBall).
-                DefaultIfEmpty(new {ItemId = ItemId.ItemGreatBall, Amount = 0}).FirstOrDefault().Amount;
+                DefaultIfEmpty(new { ItemId = ItemId.ItemGreatBall, Amount = 0 }).FirstOrDefault().Amount;
             var ultraBallsCount = ballCollection.Where(p => p.ItemId == ItemId.ItemUltraBall).
-                DefaultIfEmpty(new {ItemId = ItemId.ItemUltraBall, Amount = 0}).FirstOrDefault().Amount;
+                DefaultIfEmpty(new { ItemId = ItemId.ItemUltraBall, Amount = 0 }).FirstOrDefault().Amount;
             var masterBallsCount = ballCollection.Where(p => p.ItemId == ItemId.ItemMasterBall).
-                DefaultIfEmpty(new {ItemId = ItemId.ItemMasterBall, Amount = 0}).FirstOrDefault().Amount;
+                DefaultIfEmpty(new { ItemId = ItemId.ItemMasterBall, Amount = 0 }).FirstOrDefault().Amount;

             // Use better balls for high CP pokemon
             if (masterBallsCount > 0 && pokemonCP >= 1000)
@@ -1608,9 +1626,23 @@ namespace PokemonGo.RocketAPI.Window
             return ItemId.ItemPokeBall;
         }

-        private void button1_Click(object sender, EventArgs e)
+        private async void button1_Click(object sender, EventArgs e)
         {
-            ReloadPokemonList();
+            if (pkmnIV.AspectGetter == null)
+            {
+                pkmnIV.AspectGetter = delegate (object rowObject)
+                {
+                    var data = rowObject as PokemonData;
+                    if (data != null)
+                    {
+                        return data.GetIV();
+                    }
+
+                    return 0.0f;
+                };
+            }
+
+            await ReloadPokemonList();
         }

         #endregion
diff --git a/PokemonGo/RocketAPI/Window/PokemonGo.RocketBot.csproj b/PokemonGo/RocketAPI/Window/PokemonGo.RocketBot.csproj
index 025f37e..0803b4c 100644
--- a/PokemonGo/RocketAPI/Window/PokemonGo.RocketBot.csproj
+++ b/PokemonGo/RocketAPI/Window/PokemonGo.RocketBot.csproj
@@ -80,6 +80,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="ApiFailureStrategy.cs" />
+    <Compile Include="Extensions.cs" />
     <Compile Include="LocationManager.cs" />
     <Compile Include="MainForm.cs">
       <SubType>Form</SubType>
diff --git a/PokemonGo/RocketAPI/Window/Properties/AssemblyInfo.cs b/PokemonGo/RocketAPI/Window/Properties/AssemblyInfo.cs
index 8c9e70c..25f2f58 100644
--- a/PokemonGo/RocketAPI/Window/Properties/AssemblyInfo.cs
+++ b/PokemonGo/RocketAPI/Window/Properties/AssemblyInfo.cs
@@ -35,5 +35,5 @@ using System.Runtime.InteropServices;
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]

-[assembly: AssemblyVersion("1.8.0.0")]
+[assembly: AssemblyVersion("1.8.0.1")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file
diff --git a/PokemonGo/RocketAPI/Window/SettingsForm.Designer.cs b/PokemonGo/RocketAPI/Window/SettingsForm.Designer.cs
index 816d7e0..e95e991 100644
--- a/PokemonGo/RocketAPI/Window/SettingsForm.Designer.cs
+++ b/PokemonGo/RocketAPI/Window/SettingsForm.Designer.cs
@@ -328,7 +328,6 @@
             this.AdressBox.Size = new System.Drawing.Size(331, 21);
             this.AdressBox.TabIndex = 25;
             this.AdressBox.Text = "Enter an address or a coordinate";
-            this.AdressBox.TextChanged += new System.EventHandler(this.AdressBox_TextChanged);
             this.AdressBox.Enter += new System.EventHandler(this.AdressBox_Enter);
             this.AdressBox.Leave += new System.EventHandler(this.AdressBox_Leave);
             //
diff --git a/PokemonGo/RocketAPI/Window/SettingsForm.cs b/PokemonGo/RocketAPI/Window/SettingsForm.cs
index 7d822aa..85e8b14 100644
--- a/PokemonGo/RocketAPI/Window/SettingsForm.cs
+++ b/PokemonGo/RocketAPI/Window/SettingsForm.cs
@@ -265,8 +265,6 @@ namespace PokemonGo.RocketAPI.Window
             }
         }

-        private void AdressBox_TextChanged(object sender, EventArgs e)
-        {
-        }
+
     }
 }
\ No newline at end of file
You may download the files in Public Git.