Added PokemonsNotToCatch filter (configurable via Settings.cs)

Spegeli [2016-07-23 05:34:27]
Added PokemonsNotToCatch filter (configurable via Settings.cs)
Filename
PokemonGo.RocketAPI.Console/App.config
PokemonGo.RocketAPI.Console/Program.cs
PokemonGo.RocketAPI.Console/Settings.cs
PokemonGo.RocketAPI.Console/UserSettings.Designer.cs
PokemonGo.RocketAPI.Console/UserSettings.cs
PokemonGo.RocketAPI.Logic/Inventory.cs
PokemonGo.RocketAPI.Logic/Logic.cs
PokemonGo.RocketAPI.Logic/Navigation.cs
PokemonGo.RocketAPI.Logic/Utils/Git.cs
PokemonGo.RocketAPI.Logic/Utils/LocationUtils.cs
PokemonGo.RocketAPI.Logic/Utils/Statistics.cs
PokemonGo.RocketAPI.Logic/Utils/StringUtils.cs
PokemonGo.RocketAPI/Client.cs
PokemonGo.RocketAPI/Enums/AuthType.cs
PokemonGo.RocketAPI/Enums/MiscEnums.cs
PokemonGo.RocketAPI/Enums/RequestType.cs
PokemonGo.RocketAPI/Exceptions/AccessTokenExpiredException.cs
PokemonGo.RocketAPI/Exceptions/InvalidResponseException.cs
PokemonGo.RocketAPI/Exceptions/PTCOfflineException.cs
PokemonGo.RocketAPI/Extensions/DateTimeExtensions.cs
PokemonGo.RocketAPI/Extensions/HttpClientExtensions.cs
PokemonGo.RocketAPI/Helpers/HttpClientHelper.cs
PokemonGo.RocketAPI/Helpers/JsonHelper.cs
PokemonGo.RocketAPI/Helpers/ProtoHelper.cs
PokemonGo.RocketAPI/Helpers/RandomHelper.cs
PokemonGo.RocketAPI/Helpers/RequestBuilder.cs
PokemonGo.RocketAPI/Helpers/RetryHandler.cs
PokemonGo.RocketAPI/Helpers/S2Helper.cs
PokemonGo.RocketAPI/Helpers/Utils.cs
PokemonGo.RocketAPI/ISettings.cs
PokemonGo.RocketAPI/Logging/ConsoleLogger.cs
PokemonGo.RocketAPI/Logging/ILogger.cs
PokemonGo.RocketAPI/Logging/Logger.cs
PokemonGo.RocketAPI/Login/GoogleLogin.cs
PokemonGo.RocketAPI/Login/PtcLogin.cs
PokemonGo.RocketAPI/PokemonGo.RocketAPI.csproj
PokemonGo.RocketAPI/Properties/AssemblyInfo.cs
PokemonGo.RocketAPI/Resources.cs
diff --git a/PokemonGo.RocketAPI.Console/App.config b/PokemonGo.RocketAPI.Console/App.config
index 111e210..7cdf5c0 100644
--- a/PokemonGo.RocketAPI.Console/App.config
+++ b/PokemonGo.RocketAPI.Console/App.config
@@ -17,26 +17,11 @@
       </dependentAssembly>
     </assemblyBinding>
   </runtime>
-  <userSettings>
+  <userSettings>
     <PokemonGo.RocketAPI.Console.UserSettings>
-      <setting name="AuthType" serializeAs="String">
-        <value>Ptc</value>
-      </setting>
-      <setting name="PtcUsername" serializeAs="String">
-        <value>username</value>
-      </setting>
-      <setting name="PtcPassword" serializeAs="String">
-        <value>password</value>
-      </setting>
       <setting name="GoogleRefreshToken" serializeAs="String">
         <value />
       </setting>
-      <setting name="DefaultLatitude" serializeAs="String">
-        <value>0</value>
-      </setting>
-      <setting name="DefaultLongitude" serializeAs="String">
-        <value>0</value>
-      </setting>
       <setting name="DefaultAltitude" serializeAs="String">
         <value>10</value>
       </setting>
@@ -49,6 +34,30 @@
       <setting name="WalkingSpeedInKilometerPerHour" serializeAs="String">
         <value>50</value>
       </setting>
-    </PokemonGo.RocketAPI.Console.UserSettings>
+      <setting name="AuthType" serializeAs="String">
+        <value>Google</value>
+      </setting>
+      <setting name="DefaultLatitude" serializeAs="String">
+        <value>0</value>
+      </setting>
+      <setting name="DefaultLongitude" serializeAs="String">
+        <value>0</value>
+      </setting>
+      <setting name="EvolveAllPokemonWithEnoughCandy" serializeAs="String">
+        <value>False</value>
+      </setting>
+      <setting name="TransferDuplicatePokemon" serializeAs="String">
+        <value>True</value>
+      </setting>
+      <setting name="PtcUsername" serializeAs="String">
+        <value>username</value>
+      </setting>
+      <setting name="PtcPassword" serializeAs="String">
+        <value>password</value>
+      </setting>
+      <setting name="UsePokemonToNotCatchFilter" serializeAs="String">
+        <value>False</value>
+      </setting>
+    </PokemonGo.RocketAPI.Console.UserSettings>
   </userSettings>
 </configuration>
\ No newline at end of file
diff --git a/PokemonGo.RocketAPI.Console/Program.cs b/PokemonGo.RocketAPI.Console/Program.cs
index 2d8bf93..c7a6017 100644
--- a/PokemonGo.RocketAPI.Console/Program.cs
+++ b/PokemonGo.RocketAPI.Console/Program.cs
@@ -1,28 +1,19 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Net;
-using System.Reflection;
-using System.Text.RegularExpressions;
+#region
+
+using System;
 using System.Threading;
 using System.Threading.Tasks;
-using AllEnum;
-using PokemonGo.RocketAPI.Enums;
 using PokemonGo.RocketAPI.Exceptions;
-using PokemonGo.RocketAPI.Extensions;
-using PokemonGo.RocketAPI.GeneratedCode;
-using System.Net.Http;
-using System.Text;
-using Google.Protobuf;
-using PokemonGo.RocketAPI.Helpers;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Console
 {
-    class Program
+    internal class Program
     {

-        static void Main(string[] args)
+        private static void Main(string[] args)
         {
             Logger.SetLogger(new Logging.ConsoleLogger(LogLevel.Info));

@@ -34,7 +25,10 @@ namespace PokemonGo.RocketAPI.Console
                 }
                 catch (PtcOfflineException)
                 {
-                    Logger.Normal("PTC Servers are probably down OR your credentials are wrong. Try google");
+                    Logger.Error("PTC Servers are probably down OR your credentials are wrong. Try google");
+                    Logger.Error("Trying again in 60 seconds...");
+                    Thread.Sleep(60000);
+                    new Logic.Logic(new Settings()).Execute().Wait();
                 }
                 catch (Exception ex)
                 {
diff --git a/PokemonGo.RocketAPI.Console/Settings.cs b/PokemonGo.RocketAPI.Console/Settings.cs
index 113081d..b48453c 100644
--- a/PokemonGo.RocketAPI.Console/Settings.cs
+++ b/PokemonGo.RocketAPI.Console/Settings.cs
@@ -1,17 +1,17 @@
-using System.Configuration;
+#region
+
 using PokemonGo.RocketAPI.Enums;
-using PokemonGo.RocketAPI.GeneratedCode;
 using System;
-using System.Globalization;
-using System.Runtime.CompilerServices;
 using System.Collections.Generic;
 using AllEnum;

+#endregion
+
+
 namespace PokemonGo.RocketAPI.Console
 {
     public class Settings : ISettings
     {
-        //public AuthType AuthType => (AuthType)Enum.Parse(typeof(AuthType), UserSettings.Default.AuthType);
         public AuthType AuthType => (AuthType)Enum.Parse(typeof(AuthType), UserSettings.Default.AuthType, true);
         public string PtcUsername => UserSettings.Default.PtcUsername;
         public string PtcPassword => UserSettings.Default.PtcPassword;
@@ -24,6 +24,7 @@ namespace PokemonGo.RocketAPI.Console
         public double WalkingSpeedInKilometerPerHour => UserSettings.Default.WalkingSpeedInKilometerPerHour;
         public bool EvolveAllPokemonWithEnoughCandy => UserSettings.Default.EvolveAllPokemonWithEnoughCandy;
         public bool TransferDuplicatePokemon => UserSettings.Default.TransferDuplicatePokemon;
+        public bool UsePokemonToNotCatchFilter => UserSettings.Default.UsePokemonToNotCatchFilter;

         public string GoogleRefreshToken
         {
@@ -56,29 +57,29 @@ namespace PokemonGo.RocketAPI.Console
                     new KeyValuePair<ItemId, int>(ItemId.ItemRevive, 10),
                     new KeyValuePair<ItemId, int>(ItemId.ItemMaxRevive, 50),

-                     new KeyValuePair<ItemId, int>(ItemId.ItemLuckyEgg, 200),
-
-                     new KeyValuePair<ItemId, int>(ItemId.ItemIncenseOrdinary, 100),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemIncenseSpicy, 100),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemIncenseCool, 100),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemIncenseFloral, 100),
-
-                     new KeyValuePair<ItemId, int>(ItemId.ItemTroyDisk, 100),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemXAttack, 100),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemXDefense, 100),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemXMiracle, 100),
-
-                     new KeyValuePair<ItemId, int>(ItemId.ItemRazzBerry, 20),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemBlukBerry, 10),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemNanabBerry, 10),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemWeparBerry, 30),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemPinapBerry, 30),
-
-                     new KeyValuePair<ItemId, int>(ItemId.ItemSpecialCamera, 100),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemIncubatorBasicUnlimited, 100),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemIncubatorBasic, 100),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemPokemonStorageUpgrade, 100),
-                     new KeyValuePair<ItemId, int>(ItemId.ItemItemStorageUpgrade, 100),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemLuckyEgg, 200),
+
+                    new KeyValuePair<ItemId, int>(ItemId.ItemIncenseOrdinary, 100),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemIncenseSpicy, 100),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemIncenseCool, 100),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemIncenseFloral, 100),
+
+                    new KeyValuePair<ItemId, int>(ItemId.ItemTroyDisk, 100),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemXAttack, 100),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemXDefense, 100),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemXMiracle, 100),
+
+                    new KeyValuePair<ItemId, int>(ItemId.ItemRazzBerry, 20),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemBlukBerry, 10),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemNanabBerry, 10),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemWeparBerry, 30),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemPinapBerry, 30),
+
+                    new KeyValuePair<ItemId, int>(ItemId.ItemSpecialCamera, 100),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemIncubatorBasicUnlimited, 100),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemIncubatorBasic, 100),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemPokemonStorageUpgrade, 100),
+                    new KeyValuePair<ItemId, int>(ItemId.ItemItemStorageUpgrade, 100),
                 };
             }
             set
@@ -143,7 +144,7 @@ namespace PokemonGo.RocketAPI.Console
         {
             get
             {
-                //Type of pokemons not to transfer
+                //Do not transfer those
                 return new[]
             {
                     PokemonId.Dragonite,
@@ -161,5 +162,23 @@ namespace PokemonGo.RocketAPI.Console
             }
         }

+        public ICollection<PokemonId> PokemonsNotToCatch
+        {
+            get
+            {
+                //Do not catch those
+                return new[]
+                {
+                    //add pokemon here
+                   PokemonId.Pidgey,
+                   PokemonId.Rattata
+                };
+            }
+            set
+            {
+                throw new NotImplementedException();
+            }
+        }
+
     }
 }
diff --git a/PokemonGo.RocketAPI.Console/UserSettings.Designer.cs b/PokemonGo.RocketAPI.Console/UserSettings.Designer.cs
index ca444b0..9d9db6c 100644
--- a/PokemonGo.RocketAPI.Console/UserSettings.Designer.cs
+++ b/PokemonGo.RocketAPI.Console/UserSettings.Designer.cs
@@ -85,7 +85,7 @@ namespace PokemonGo.RocketAPI.Console {

         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("Ptc")]
+        [global::System.Configuration.DefaultSettingValueAttribute("Google")]
         public string AuthType {
             get {
                 return ((string)(this["AuthType"]));
@@ -97,73 +97,85 @@ namespace PokemonGo.RocketAPI.Console {

         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("Jarolon")]
-        public string PtcUsername {
+        [global::System.Configuration.DefaultSettingValueAttribute("0")]
+        public double DefaultLatitude {
             get {
-                return ((string)(this["PtcUsername"]));
+                return ((double)(this["DefaultLatitude"]));
             }
             set {
-                this["PtcUsername"] = value;
+                this["DefaultLatitude"] = value;
             }
         }

         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("5dfM56Rh")]
-        public string PtcPassword {
+        [global::System.Configuration.DefaultSettingValueAttribute("0")]
+        public double DefaultLongitude {
             get {
-                return ((string)(this["PtcPassword"]));
+                return ((double)(this["DefaultLongitude"]));
             }
             set {
-                this["PtcPassword"] = value;
+                this["DefaultLongitude"] = value;
             }
         }

         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("48.78")]
-        public double DefaultLatitude {
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]
+        public bool EvolveAllPokemonWithEnoughCandy {
             get {
-                return ((double)(this["DefaultLatitude"]));
+                return ((bool)(this["EvolveAllPokemonWithEnoughCandy"]));
             }
             set {
-                this["DefaultLatitude"] = value;
+                this["EvolveAllPokemonWithEnoughCandy"] = value;
             }
         }

         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("9.18274")]
-        public double DefaultLongitude {
+        [global::System.Configuration.DefaultSettingValueAttribute("True")]
+        public bool TransferDuplicatePokemon {
             get {
-                return ((double)(this["DefaultLongitude"]));
+                return ((bool)(this["TransferDuplicatePokemon"]));
             }
             set {
-                this["DefaultLongitude"] = value;
+                this["TransferDuplicatePokemon"] = value;
             }
         }

         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("True")]
-        public bool EvolveAllPokemonWithEnoughCandy {
+        [global::System.Configuration.DefaultSettingValueAttribute("username")]
+        public string PtcUsername {
             get {
-                return ((bool)(this["EvolveAllPokemonWithEnoughCandy"]));
+                return ((string)(this["PtcUsername"]));
             }
             set {
-                this["EvolveAllPokemonWithEnoughCandy"] = value;
+                this["PtcUsername"] = value;
             }
         }

         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-        [global::System.Configuration.DefaultSettingValueAttribute("True")]
-        public bool TransferDuplicatePokemon {
+        [global::System.Configuration.DefaultSettingValueAttribute("password")]
+        public string PtcPassword {
             get {
-                return ((bool)(this["TransferDuplicatePokemon"]));
+                return ((string)(this["PtcPassword"]));
             }
             set {
-                this["TransferDuplicatePokemon"] = value;
+                this["PtcPassword"] = value;
+            }
+        }
+
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("False")]
+        public bool UsePokemonToNotCatchFilter {
+            get {
+                return ((bool)(this["UsePokemonToNotCatchFilter"]));
+            }
+            set {
+                this["UsePokemonToNotCatchFilter"] = value;
             }
         }
     }
diff --git a/PokemonGo.RocketAPI.Console/UserSettings.cs b/PokemonGo.RocketAPI.Console/UserSettings.cs
index b83c870..6553b03 100644
--- a/PokemonGo.RocketAPI.Console/UserSettings.cs
+++ b/PokemonGo.RocketAPI.Console/UserSettings.cs
@@ -1,7 +1,13 @@
-namespace PokemonGo.RocketAPI.Console
-{
+#region
+
+using System.ComponentModel;
+using System.Configuration;

+#endregion

+
+namespace PokemonGo.RocketAPI.Console
+{
     // This class allows you to handle specific events on the settings class:
     //  The SettingChanging event is raised before a setting's value is changed.
     //  The PropertyChanged event is raised after a setting's value is changed.
@@ -9,25 +15,14 @@
     //  The SettingsSaving event is raised before the setting values are saved.
     internal sealed partial class UserSettings
     {
-
-        public UserSettings()
-        {
-            // // To add event handlers for saving and changing settings, uncomment the lines below:
-            //
-            // this.SettingChanging += this.SettingChangingEventHandler;
-            //
-            // this.SettingsSaving += this.SettingsSavingEventHandler;
-            //
-        }
-
-        private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e)
+        private void SettingChangingEventHandler(object sender, SettingChangingEventArgs e)
         {
             // Add code to handle the SettingChangingEvent event here.
         }

-        private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e)
+        private void SettingsSavingEventHandler(object sender, CancelEventArgs e)
         {
             // Add code to handle the SettingsSaving event here.
         }
     }
-}
+}
\ No newline at end of file
diff --git a/PokemonGo.RocketAPI.Logic/Inventory.cs b/PokemonGo.RocketAPI.Logic/Inventory.cs
index b9275aa..2f8f0dd 100644
--- a/PokemonGo.RocketAPI.Logic/Inventory.cs
+++ b/PokemonGo.RocketAPI.Logic/Inventory.cs
@@ -1,9 +1,14 @@
-using System.Collections.Generic;
+#region
+
+using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using AllEnum;
 using PokemonGo.RocketAPI.GeneratedCode;

+#endregion
+
+
 namespace PokemonGo.RocketAPI.Logic
 {
     public class Inventory
@@ -78,7 +83,7 @@ namespace PokemonGo.RocketAPI.Logic
                     if (settings.CandyToEvolve == 0)
                         continue;

-                    var amountToSkip = (familyCandy.Candy + settings.CandyToEvolve - 1) / settings.CandyToEvolve + 2;
+                    var amountToSkip = familyCandy.Candy / settings.CandyToEvolve;

                     results.AddRange(pokemonList.Where(x => x.PokemonId == pokemon.Key && x.Favorite == 0)
                         .OrderByDescending(x => x.Cp)
@@ -94,7 +99,13 @@ namespace PokemonGo.RocketAPI.Logic
             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());
+                .SelectMany(
+                    p =>
+                        p.Where(x => x.Favorite == 0)
+                            .OrderByDescending(x => x.Cp)
+                            .ThenBy(n => n.StaminaMax)
+                            .Skip(1)
+                            .ToList());
         }

         public async Task<IEnumerable<PokemonData>> GetPokemonToEvolve(IEnumerable<PokemonId> filter = null)
@@ -123,8 +134,10 @@ namespace PokemonGo.RocketAPI.Logic
                 if (settings.EvolutionIds.Count == 0)
                     continue;

-                var pokemonCandyNeededAlready = pokemonToEvolve.Count(p => pokemonSettings.Single(x => x.PokemonId == p.PokemonId).FamilyId == settings.FamilyId) * settings.CandyToEvolve;
-                if (familyCandy.Candy - pokemonCandyNeededAlready > settings.CandyToEvolve)
+                var pokemonCandyNeededAlready =
+                    pokemonToEvolve.Count(
+                        p => pokemonSettings.Single(x => x.PokemonId == p.PokemonId).FamilyId == settings.FamilyId) *
+                    settings.CandyToEvolve; if (familyCandy.Candy - pokemonCandyNeededAlready > settings.CandyToEvolve)
                     pokemonToEvolve.Add(pokemon);
             }

@@ -158,8 +171,15 @@ namespace PokemonGo.RocketAPI.Logic
             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 });
+                .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 == (ItemId)x.Item_).Value,
+                            Unseen = x.Unseen
+                        });
         }
     }
 }
diff --git a/PokemonGo.RocketAPI.Logic/Logic.cs b/PokemonGo.RocketAPI.Logic/Logic.cs
index 6a830b6..6b5ea11 100644
--- a/PokemonGo.RocketAPI.Logic/Logic.cs
+++ b/PokemonGo.RocketAPI.Logic/Logic.cs
@@ -1,4 +1,6 @@
-using System;
+#region
+
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Reflection.Emit;
@@ -11,6 +13,10 @@ using PokemonGo.RocketAPI.Extensions;
 using PokemonGo.RocketAPI.GeneratedCode;
 using PokemonGo.RocketAPI.Logic.Utils;
 using PokemonGo.RocketAPI.Helpers;
+using System.Collections;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Logic
 {
@@ -21,6 +27,7 @@ namespace PokemonGo.RocketAPI.Logic
         private readonly Inventory _inventory;
         private readonly Statistics _stats;
         private readonly Navigation _navigation;
+        private GetPlayerResponse _playerProfile;

         public Logic(ISettings clientSettings)
         {
@@ -41,9 +48,17 @@ namespace PokemonGo.RocketAPI.Logic
                 Logger.Error($"Window will be auto closed in 15 seconds!");
                 await Task.Delay(15000);
                 System.Environment.Exit(1);
+            }else
+            {
+                Logger.Error($"Make sure Lat & Lng is right. Exit Program if not! Lat: {_client.CurrentLat} Lng: {_client.CurrentLng}");
+                for (int i = 3; i > 0; i--)
+                {
+                    Logger.Error($"Script will continue in {i*5} seconds!");
+                    await Task.Delay(5000);
+                }
             }

-            Logger.Normal(ConsoleColor.DarkGreen, $"Starting Execute on login server: {_clientSettings.AuthType}");
+            Logger.Normal(ConsoleColor.DarkGreen, $"Logging in via: {_clientSettings.AuthType}");
             while (true)
             {
                 try
@@ -61,6 +76,41 @@ namespace PokemonGo.RocketAPI.Logic
                 {
                     Logger.Error($"Access token expired");
                 }
+                catch (TaskCanceledException)
+                {
+                    Logger.Error("Task Canceled Exception - Restarting");
+                    await Execute();
+                }
+                catch (UriFormatException)
+                {
+                    Logger.Error("UriFormatException - Restarting");
+                    await Execute();
+                }
+                catch (ArgumentOutOfRangeException)
+                {
+                    Logger.Error("ArgumentOutOfRangeException - Restarting");
+                    await Execute();
+                }
+                catch (ArgumentNullException)
+                {
+                    Logger.Error("ArgumentNullException - Restarting");
+                    await Execute();
+                }
+                catch (NullReferenceException)
+                {
+                    Logger.Error("NullReferenceException - Restarting");
+                    await Execute();
+                }
+                catch (InvalidResponseException)
+                {
+                    Logger.Error("InvalidResponseException - Restarting");
+                    await Execute();
+                }
+                catch (AggregateException)
+                {
+                    Logger.Error("AggregateException - Restarting");
+                    await Execute();
+                }
                 await Task.Delay(10000);
             }
         }
@@ -71,11 +121,10 @@ namespace PokemonGo.RocketAPI.Logic

             while (true)
             {
-                try
-                {
+
+                    _playerProfile = await _client.GetProfile();
                     _stats.updateConsoleTitle(_inventory);

-                    var profile = await _client.GetProfile();
                     var _currentLevelInfos = await Statistics._getcurrentLevelInfos(_inventory);

                     Logger.Normal(ConsoleColor.Yellow, "----------------------------");
@@ -86,10 +135,10 @@ namespace PokemonGo.RocketAPI.Logic
                     Logger.Normal(ConsoleColor.DarkGray, $"Longitude: {_clientSettings.DefaultLongitude}");
                     Logger.Normal(ConsoleColor.Yellow, "----------------------------");
                     Logger.Normal(ConsoleColor.DarkGray, "Your Account:\n");
-                    Logger.Normal(ConsoleColor.DarkGray, $"Name: {profile.Profile.Username}");
-                    Logger.Normal(ConsoleColor.DarkGray, $"Team: {profile.Profile.Team}");
+                    Logger.Normal(ConsoleColor.DarkGray, $"Name: {_playerProfile.Profile.Username}");
+                    Logger.Normal(ConsoleColor.DarkGray, $"Team: {_playerProfile.Profile.Team}");
                     Logger.Normal(ConsoleColor.DarkGray, $"Level: {_currentLevelInfos}");
-                    Logger.Normal(ConsoleColor.DarkGray, $"Stardust: {profile.Profile.Currency.ToArray()[1].Amount}");
+                    Logger.Normal(ConsoleColor.DarkGray, $"Stardust: {_playerProfile.Profile.Currency.ToArray()[1].Amount}");
                     Logger.Normal(ConsoleColor.Yellow, "----------------------------");

                     if (_clientSettings.EvolveAllPokemonWithEnoughCandy) await EvolveAllPokemonWithEnoughCandy(_clientSettings.PokemonsToEvolve);
@@ -106,15 +155,6 @@ namespace PokemonGo.RocketAPI.Logic
                 var inventory = await _client.GetInventory();
                 var pokemons = inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.Pokemon).Where(p => p != null && p?.PokemonId > 0);
                 */
-                }
-                catch (AccessTokenExpiredException)
-                {
-                    throw;
-                }
-                catch (Exception ex)
-                {
-                    Logger.Error($"Exception: {ex}");
-                }

                 await Task.Delay(10000);
             }
@@ -122,7 +162,7 @@ namespace PokemonGo.RocketAPI.Logic

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

         public async Task RepeatAction(int repeat, Func<Task> action)
@@ -163,10 +203,18 @@ namespace PokemonGo.RocketAPI.Logic
         private async Task ExecuteCatchAllNearbyPokemons()
         {
             var mapObjects = await _client.GetMapObjects();
+
+            //var pokemons = mapObjects.MapCells.SelectMany(i => i.CatchablePokemons).OrderBy(i => LocationUtils.CalculateDistanceInMeters(new Navigation.Location(_client.CurrentLat, _client.CurrentLng), new Navigation.Location(i.Latitude, i.Longitude)));
             var pokemons = mapObjects.MapCells.SelectMany(i => i.CatchablePokemons).OrderBy(i => LocationUtils.CalculateDistanceInMeters(new Navigation.Location(_client.CurrentLat, _client.CurrentLng), new Navigation.Location(i.Latitude, i.Longitude)));
+            if (_clientSettings.UsePokemonToNotCatchFilter)
+            {
+                ICollection<PokemonId> filter = _clientSettings.PokemonsNotToCatch;
+                pokemons = mapObjects.MapCells.SelectMany(i => i.CatchablePokemons).Where(p => !filter.Contains(p.PokemonId)).OrderBy(i => LocationUtils.CalculateDistanceInMeters(new Navigation.Location(_client.CurrentLat, _client.CurrentLng), new Navigation.Location(i.Latitude, i.Longitude)));
+            }
+
             if (pokemons != null && pokemons.Any())
                 Logger.Normal(ConsoleColor.Green, $"Found {pokemons.Count()} catchable Pokemon");
-
+
             foreach (var pokemon in pokemons)
             {
                 var distance = Navigation.DistanceBetween2Coordinates(_client.CurrentLat, _client.CurrentLng, pokemon.Latitude, pokemon.Longitude);
@@ -219,8 +267,8 @@ namespace PokemonGo.RocketAPI.Logic
                 _stats.updateConsoleTitle(_inventory);
                 Logger.Normal(ConsoleColor.Yellow,
                     caughtPokemonResponse.Status == CatchPokemonResponse.Types.CatchStatus.CatchSuccess
-                    ? $"(POKEBATTLE) We caught a {pokemon.PokemonId} with CP {encounter?.WildPokemon?.PokemonData?.Cp} ({CalculatePokemonPerfection(encounter?.WildPokemon?.PokemonData).ToString("0.00")}% perfect) and CaptureProbability: {encounter?.CaptureProbability.CaptureProbability_.First()}, used {bestPokeball} and received XP {caughtPokemonResponse.Scores.Xp.Sum()}"
-                    : $"(POKEBATTLE) {pokemon.PokemonId} with CP {encounter?.WildPokemon?.PokemonData?.Cp} CaptureProbability: {encounter?.CaptureProbability.CaptureProbability_.First()} {caughtPokemonResponse.Status} while using a {bestPokeball}.."
+                    ? $"(POKEBATTLE) {pokemon.PokemonId} (CP {encounter?.WildPokemon?.PokemonData?.Cp}) ({CalculatePokemonPerfection(encounter?.WildPokemon?.PokemonData).ToString("0.00")}% perfect) | Chance: {encounter?.CaptureProbability.CaptureProbability_.First()} | {Math.Round(distance)}m distance | with {bestPokeball} and received XP {caughtPokemonResponse.Scores.Xp.Sum()}"
+                    : $"(POKEBATTLE) {pokemon.PokemonId} (CP {encounter?.WildPokemon?.PokemonData?.Cp}) | Change: {encounter?.CaptureProbability.CaptureProbability_.First()} {caughtPokemonResponse.Status} | {Math.Round(distance)}m distance | using a {bestPokeball}.."
                     );
                 await RandomHelper.RandomDelay(1750, 2250);
             }
@@ -367,15 +415,19 @@ namespace PokemonGo.RocketAPI.Logic

         private async Task DisplayPlayerLevelInTitle()
         {
+            _playerProfile = _playerProfile.Profile != null ? _playerProfile : await _client.GetProfile();
+            var playerName = _playerProfile.Profile.Username != null ? _playerProfile.Profile.Username : "";
             var playerStats = await _inventory.GetPlayerStats();
             var playerStat = playerStats.FirstOrDefault();
             if (playerStat != null)
             {
-                var message = $"Character Level {playerStat.Level:0} - ({(playerStat.Experience - playerStat.PrevLevelXp):0} / {(playerStat.NextLevelXp - playerStat.PrevLevelXp):0})";
-                System.Console.Title = message;
+                var message =
+                    $"Character Level {playerName} {playerStat.Level:0} - ({playerStat.Experience - playerStat.PrevLevelXp:0} / {playerStat.NextLevelXp - playerStat.PrevLevelXp:0} XP)";
+                Console.Title = message;
                 Logger.Normal(message);
             }
             await Task.Delay(5000);
         }
+
     }
 }
\ No newline at end of file
diff --git a/PokemonGo.RocketAPI.Logic/Navigation.cs b/PokemonGo.RocketAPI.Logic/Navigation.cs
index eb71c7e..23eef21 100644
--- a/PokemonGo.RocketAPI.Logic/Navigation.cs
+++ b/PokemonGo.RocketAPI.Logic/Navigation.cs
@@ -1,9 +1,14 @@
-using System;
+#region
+
+using System;
 using System.Runtime.InteropServices;
 using System.Threading.Tasks;
 using PokemonGo.RocketAPI.GeneratedCode;
 using PokemonGo.RocketAPI.Logic.Utils;

+#endregion
+
+
 namespace PokemonGo.RocketAPI.Logic
 {
     public class Navigation
diff --git a/PokemonGo.RocketAPI.Logic/Utils/Git.cs b/PokemonGo.RocketAPI.Logic/Utils/Git.cs
index fe6eb04..c971241 100644
--- a/PokemonGo.RocketAPI.Logic/Utils/Git.cs
+++ b/PokemonGo.RocketAPI.Logic/Utils/Git.cs
@@ -1,9 +1,13 @@
-using System;
+#region
+
+using System;
 using System.Net;
 using System.Reflection;
 using System.Text.RegularExpressions;
 using System.Threading;
-using System.Threading.Tasks;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Helpers
 {
diff --git a/PokemonGo.RocketAPI.Logic/Utils/LocationUtils.cs b/PokemonGo.RocketAPI.Logic/Utils/LocationUtils.cs
index 4ff42f7..9ae5052 100644
--- a/PokemonGo.RocketAPI.Logic/Utils/LocationUtils.cs
+++ b/PokemonGo.RocketAPI.Logic/Utils/LocationUtils.cs
@@ -1,10 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+#region
+
+using System;
 using static PokemonGo.RocketAPI.Logic.Navigation;

+#endregion
+
+
 namespace PokemonGo.RocketAPI.Logic.Utils
 {
     public static class LocationUtils
diff --git a/PokemonGo.RocketAPI.Logic/Utils/Statistics.cs b/PokemonGo.RocketAPI.Logic/Utils/Statistics.cs
index b2649c8..00e6bdf 100644
--- a/PokemonGo.RocketAPI.Logic/Utils/Statistics.cs
+++ b/PokemonGo.RocketAPI.Logic/Utils/Statistics.cs
@@ -1,14 +1,12 @@
-using System;
-using System.Collections.Generic;
+#region
+
+using System;
 using System.Linq;
-using System.Text;
 using System.Threading.Tasks;
-using PokemonGo.RocketAPI.Enums;
-using PokemonGo.RocketAPI.Exceptions;
-using PokemonGo.RocketAPI.Extensions;
 using PokemonGo.RocketAPI.GeneratedCode;
-using PokemonGo.RocketAPI.Logic.Utils;
-using PokemonGo.RocketAPI.Helpers;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Logic.Utils
 {
@@ -44,7 +42,8 @@ namespace PokemonGo.RocketAPI.Logic.Utils
                 var _ep = (stat.NextLevelXp - stat.PrevLevelXp) - (stat.Experience - stat.PrevLevelXp);
                 var _hours = Math.Round(_ep / (_totalExperience / _getSessionRuntime()),2);

-                output = $"{stat.Level} (LvLUp in {_hours}hours // EXP required: {_ep})";
+                output = $"{stat.Level} (LvLUp in {_hours}hours // {stat.Experience - stat.PrevLevelXp - GetXpDiff(stat.Level)}/{stat.NextLevelXp - stat.PrevLevelXp - GetXpDiff(stat.Level)} XP)";
+                //output = $"{stat.Level} (LvLUp in {_hours}hours // EXP required: {_ep})";
             }
             return output;
         }
@@ -79,5 +78,93 @@ namespace PokemonGo.RocketAPI.Logic.Utils
         {
             return string.Format("{0} - LvL: {1:0}    EXP/H: {2:0.0} EXP   P/H: {3:0.0} Pokemon(s)   Stardust: {4:0}   Pokemon Transfered: {5:0}   Items Removed: {6:0}", "Statistics", _currentLevelInfos, _totalExperience / _getSessionRuntime(), _totalPokemons / _getSessionRuntime(), _totalStardust, _totalPokemonsTransfered, _totalItemsRemoved);
         }
+
+        public static int GetXpDiff(int Level)
+        {
+            switch (Level)
+            {
+                case 1:
+                    return 0;
+                case 2:
+                    return 1000;
+                case 3:
+                    return 2000;
+                case 4:
+                    return 3000;
+                case 5:
+                    return 4000;
+                case 6:
+                    return 5000;
+                case 7:
+                    return 6000;
+                case 8:
+                    return 7000;
+                case 9:
+                    return 8000;
+                case 10:
+                    return 9000;
+                case 11:
+                    return 10000;
+                case 12:
+                    return 10000;
+                case 13:
+                    return 10000;
+                case 14:
+                    return 10000;
+                case 15:
+                    return 15000;
+                case 16:
+                    return 20000;
+                case 17:
+                    return 20000;
+                case 18:
+                    return 20000;
+                case 19:
+                    return 25000;
+                case 20:
+                    return 25000;
+                case 21:
+                    return 50000;
+                case 22:
+                    return 75000;
+                case 23:
+                    return 100000;
+                case 24:
+                    return 125000;
+                case 25:
+                    return 150000;
+                case 26:
+                    return 190000;
+                case 27:
+                    return 200000;
+                case 28:
+                    return 250000;
+                case 29:
+                    return 300000;
+                case 30:
+                    return 350000;
+                case 31:
+                    return 500000;
+                case 32:
+                    return 500000;
+                case 33:
+                    return 750000;
+                case 34:
+                    return 1000000;
+                case 35:
+                    return 1250000;
+                case 36:
+                    return 1500000;
+                case 37:
+                    return 2000000;
+                case 38:
+                    return 2500000;
+                case 39:
+                    return 1000000;
+                case 40:
+                    return 1000000;
+            }
+            return 0;
+        }
     }
 }
\ No newline at end of file
diff --git a/PokemonGo.RocketAPI.Logic/Utils/StringUtils.cs b/PokemonGo.RocketAPI.Logic/Utils/StringUtils.cs
index c9ab0f7..cf8f9e0 100644
--- a/PokemonGo.RocketAPI.Logic/Utils/StringUtils.cs
+++ b/PokemonGo.RocketAPI.Logic/Utils/StringUtils.cs
@@ -1,10 +1,12 @@
-using System;
+#region
+
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using PokemonGo.RocketAPI.GeneratedCode;

+#endregion
+
+
 namespace PokemonGo.RocketAPI.Logic.Utils
 {
     public static class StringUtils
diff --git a/PokemonGo.RocketAPI/Client.cs b/PokemonGo.RocketAPI/Client.cs
index d998d53..ca90cdc 100644
--- a/PokemonGo.RocketAPI/Client.cs
+++ b/PokemonGo.RocketAPI/Client.cs
@@ -1,4 +1,6 @@
-using System;
+#region
+
+using System;
 using System.IO;
 using System.Net;
 using System.Net.Http;
@@ -11,8 +13,9 @@ using PokemonGo.RocketAPI.Helpers;
 using PokemonGo.RocketAPI.Extensions;
 using PokemonGo.RocketAPI.Login;
 using static PokemonGo.RocketAPI.GeneratedCode.Response.Types;
-using System.Threading;
-using System.Windows.Forms;
+
+#endregion
+

 namespace PokemonGo.RocketAPI
 {
@@ -32,12 +35,26 @@ namespace PokemonGo.RocketAPI
         public Client(ISettings settings)
         {
             Settings = settings;
-            //SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);
-            if (File.Exists(Directory.GetCurrentDirectory() + "\\Coords.txt"))
+            if (File.Exists(Directory.GetCurrentDirectory() + "\\Coords.txt") && File.ReadAllText(Directory.GetCurrentDirectory() + "\\Coords.txt").Contains(":"))
             {
-                string latlngFromFile = File.ReadAllText(Directory.GetCurrentDirectory() + "\\Coords.txt");
-                String[] latlng = latlngFromFile.Split(':');
-                SetCoordinates(Convert.ToDouble(latlng[0]), Convert.ToDouble(latlng[1]), Settings.DefaultAltitude);
+                var latlngFromFile = File.ReadAllText(Directory.GetCurrentDirectory() + "\\Coords.txt");
+                var latlng = latlngFromFile.Split(':');
+                if (latlng[0].Length != 0 && latlng[1].Length != 0)
+                {
+                    try
+                    {
+                        SetCoordinates(Convert.ToDouble(latlng[0]), Convert.ToDouble(latlng[1]), Settings.DefaultAltitude);
+                    }
+                    catch (FormatException)
+                    {
+                        Logger.Error($"Coordinates in \"Coords.txt\" file is invalid, using the default coordinates ");
+                        SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);
+                    }
+                }
+                else
+                {
+                    SetCoordinates(Settings.DefaultLatitude, Settings.DefaultLongitude, Settings.DefaultAltitude);
+                }
             }
             else
             {
@@ -90,6 +107,7 @@ namespace PokemonGo.RocketAPI
                 var deviceCode = await GoogleLogin.GetDeviceCode();
                 tokenResponse = await GoogleLogin.GetAccessToken(deviceCode);
                 Settings.GoogleRefreshToken = tokenResponse?.refresh_token;
+                //Logger.Normal("Refreshtoken " + tokenResponse?.refresh_token + " saved");
                 AccessToken = tokenResponse?.id_token;
             }

diff --git a/PokemonGo.RocketAPI/Enums/AuthType.cs b/PokemonGo.RocketAPI/Enums/AuthType.cs
index 9ef6a42..5e383ea 100644
--- a/PokemonGo.RocketAPI/Enums/AuthType.cs
+++ b/PokemonGo.RocketAPI/Enums/AuthType.cs
@@ -1,8 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+#region
+
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Enums
 {
diff --git a/PokemonGo.RocketAPI/Enums/MiscEnums.cs b/PokemonGo.RocketAPI/Enums/MiscEnums.cs
index 52ab05e..676faa5 100644
--- a/PokemonGo.RocketAPI/Enums/MiscEnums.cs
+++ b/PokemonGo.RocketAPI/Enums/MiscEnums.cs
@@ -1,8 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+#region
+
+
+#endregion
+

 namespace PokemonGo.RocketAPI.GeneratedCode
 {
diff --git a/PokemonGo.RocketAPI/Enums/RequestType.cs b/PokemonGo.RocketAPI/Enums/RequestType.cs
index 9446697..a4a441d 100644
--- a/PokemonGo.RocketAPI/Enums/RequestType.cs
+++ b/PokemonGo.RocketAPI/Enums/RequestType.cs
@@ -1,8 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+#region
+
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Enums
 {
diff --git a/PokemonGo.RocketAPI/Exceptions/AccessTokenExpiredException.cs b/PokemonGo.RocketAPI/Exceptions/AccessTokenExpiredException.cs
index 5b2c9af..c2a4242 100644
--- a/PokemonGo.RocketAPI/Exceptions/AccessTokenExpiredException.cs
+++ b/PokemonGo.RocketAPI/Exceptions/AccessTokenExpiredException.cs
@@ -1,8 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+#region
+
+using System;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Exceptions
 {
diff --git a/PokemonGo.RocketAPI/Exceptions/InvalidResponseException.cs b/PokemonGo.RocketAPI/Exceptions/InvalidResponseException.cs
index 27ff90c..85dd8a7 100644
--- a/PokemonGo.RocketAPI/Exceptions/InvalidResponseException.cs
+++ b/PokemonGo.RocketAPI/Exceptions/InvalidResponseException.cs
@@ -1,8 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+#region
+
+using System;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Exceptions
 {
diff --git a/PokemonGo.RocketAPI/Exceptions/PTCOfflineException.cs b/PokemonGo.RocketAPI/Exceptions/PTCOfflineException.cs
index 86e088d..cd4c555 100644
--- a/PokemonGo.RocketAPI/Exceptions/PTCOfflineException.cs
+++ b/PokemonGo.RocketAPI/Exceptions/PTCOfflineException.cs
@@ -1,8 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+#region
+
+using System;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Exceptions
 {
diff --git a/PokemonGo.RocketAPI/Extensions/DateTimeExtensions.cs b/PokemonGo.RocketAPI/Extensions/DateTimeExtensions.cs
index b0d5c84..3fedd4b 100644
--- a/PokemonGo.RocketAPI/Extensions/DateTimeExtensions.cs
+++ b/PokemonGo.RocketAPI/Extensions/DateTimeExtensions.cs
@@ -1,8 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+#region
+
+using System;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Extensions
 {
diff --git a/PokemonGo.RocketAPI/Extensions/HttpClientExtensions.cs b/PokemonGo.RocketAPI/Extensions/HttpClientExtensions.cs
index 44710af..afdb998 100644
--- a/PokemonGo.RocketAPI/Extensions/HttpClientExtensions.cs
+++ b/PokemonGo.RocketAPI/Extensions/HttpClientExtensions.cs
@@ -1,14 +1,14 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
+#region
+
 using System.Net.Http;
-using System.Text;
 using System.Threading.Tasks;
 using Google.Protobuf;
-using PokemonGo.RocketAPI;
 using PokemonGo.RocketAPI.Exceptions;
 using PokemonGo.RocketAPI.GeneratedCode;

+#endregion
+
+
 namespace PokemonGo.RocketAPI.Extensions
 {
     public static class HttpClientExtensions
diff --git a/PokemonGo.RocketAPI/Helpers/HttpClientHelper.cs b/PokemonGo.RocketAPI/Helpers/HttpClientHelper.cs
index 42eec54..26c4959 100644
--- a/PokemonGo.RocketAPI/Helpers/HttpClientHelper.cs
+++ b/PokemonGo.RocketAPI/Helpers/HttpClientHelper.cs
@@ -1,11 +1,12 @@
-using System;
+#region
+
 using System.Collections.Generic;
-using System.Linq;
 using System.Net;
 using System.Net.Http;
-using System.Text;
 using System.Threading.Tasks;
-using Newtonsoft.Json.Linq;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Helpers
 {
diff --git a/PokemonGo.RocketAPI/Helpers/JsonHelper.cs b/PokemonGo.RocketAPI/Helpers/JsonHelper.cs
index 8255e6b..552510e 100644
--- a/PokemonGo.RocketAPI/Helpers/JsonHelper.cs
+++ b/PokemonGo.RocketAPI/Helpers/JsonHelper.cs
@@ -1,10 +1,10 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+#region
+
 using Newtonsoft.Json.Linq;

+#endregion
+
+
 namespace PokemonGo.RocketAPI.Helpers
 {
     public class JsonHelper
diff --git a/PokemonGo.RocketAPI/Helpers/ProtoHelper.cs b/PokemonGo.RocketAPI/Helpers/ProtoHelper.cs
index dca4505..1df95c8 100644
--- a/PokemonGo.RocketAPI/Helpers/ProtoHelper.cs
+++ b/PokemonGo.RocketAPI/Helpers/ProtoHelper.cs
@@ -1,10 +1,11 @@
-using System;
+#region
+
+using System;
 using System.Collections.Generic;
-using System.IO;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Google.Protobuf;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Helpers
 {
diff --git a/PokemonGo.RocketAPI/Helpers/RandomHelper.cs b/PokemonGo.RocketAPI/Helpers/RandomHelper.cs
index 6014794..98e1721 100644
--- a/PokemonGo.RocketAPI/Helpers/RandomHelper.cs
+++ b/PokemonGo.RocketAPI/Helpers/RandomHelper.cs
@@ -1,9 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+#region
+
+using System;
 using System.Threading.Tasks;

+#endregion
+
+
 namespace PokemonGo.RocketAPI.Helpers
 {
     public static class RandomHelper
diff --git a/PokemonGo.RocketAPI/Helpers/RequestBuilder.cs b/PokemonGo.RocketAPI/Helpers/RequestBuilder.cs
index 8efbe56..3b5bc3c 100644
--- a/PokemonGo.RocketAPI/Helpers/RequestBuilder.cs
+++ b/PokemonGo.RocketAPI/Helpers/RequestBuilder.cs
@@ -1,14 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
+#region
+
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Google.Protobuf;
 using PokemonGo.RocketAPI.Enums;
-using PokemonGo.RocketAPI.Extensions;
 using PokemonGo.RocketAPI.GeneratedCode;
-using PokemonGo.RocketAPI.Helpers;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Helpers
 {
diff --git a/PokemonGo.RocketAPI/Helpers/RetryHandler.cs b/PokemonGo.RocketAPI/Helpers/RetryHandler.cs
index 3862193..b65a51d 100644
--- a/PokemonGo.RocketAPI/Helpers/RetryHandler.cs
+++ b/PokemonGo.RocketAPI/Helpers/RetryHandler.cs
@@ -1,13 +1,14 @@
-using PokemonGo.RocketAPI.Logging;
+#region
+
 using System;
-using System.Collections.Generic;
-using System.Linq;
 using System.Net;
 using System.Net.Http;
-using System.Text;
 using System.Threading;
 using System.Threading.Tasks;

+#endregion
+
+
 namespace PokemonGo.RocketAPI.Helpers
 {
     class RetryHandler : DelegatingHandler
diff --git a/PokemonGo.RocketAPI/Helpers/S2Helper.cs b/PokemonGo.RocketAPI/Helpers/S2Helper.cs
index 8143f43..65cd325 100644
--- a/PokemonGo.RocketAPI/Helpers/S2Helper.cs
+++ b/PokemonGo.RocketAPI/Helpers/S2Helper.cs
@@ -1,7 +1,12 @@
-using System.Collections.Generic;
+#region
+
+using System.Collections.Generic;
 using System.Linq;
 using Google.Common.Geometry;

+#endregion
+
+
 namespace PokemonGo.RocketAPI.Helpers
 {
     public class S2Helper
diff --git a/PokemonGo.RocketAPI/Helpers/Utils.cs b/PokemonGo.RocketAPI/Helpers/Utils.cs
index 94f91d2..b28cf30 100644
--- a/PokemonGo.RocketAPI/Helpers/Utils.cs
+++ b/PokemonGo.RocketAPI/Helpers/Utils.cs
@@ -1,8 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+#region
+
+using System;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Helpers
 {
diff --git a/PokemonGo.RocketAPI/ISettings.cs b/PokemonGo.RocketAPI/ISettings.cs
index 5bfa4ee..d07a648 100644
--- a/PokemonGo.RocketAPI/ISettings.cs
+++ b/PokemonGo.RocketAPI/ISettings.cs
@@ -1,7 +1,11 @@
-using PokemonGo.RocketAPI.Enums;
-using PokemonGo.RocketAPI.GeneratedCode;
+#region
+
+using PokemonGo.RocketAPI.Enums;
 using System.Collections.Generic;

+#endregion
+
+
 namespace PokemonGo.RocketAPI
 {
     public interface ISettings
@@ -18,11 +22,14 @@ namespace PokemonGo.RocketAPI
         double WalkingSpeedInKilometerPerHour { get; }
         bool EvolveAllPokemonWithEnoughCandy { get; }
         bool TransferDuplicatePokemon { get; }
+        bool UsePokemonToNotCatchFilter { get; }

         ICollection<KeyValuePair<AllEnum.ItemId, int>> ItemRecycleFilter { get; set; }

         ICollection<AllEnum.PokemonId> PokemonsToEvolve { get; }

         ICollection<AllEnum.PokemonId> PokemonsNotToTransfer { get; }
+
+        ICollection<AllEnum.PokemonId> PokemonsNotToCatch { get; }
     }
 }
\ No newline at end of file
diff --git a/PokemonGo.RocketAPI/Logging/ConsoleLogger.cs b/PokemonGo.RocketAPI/Logging/ConsoleLogger.cs
index de9ddc5..9118371 100644
--- a/PokemonGo.RocketAPI/Logging/ConsoleLogger.cs
+++ b/PokemonGo.RocketAPI/Logging/ConsoleLogger.cs
@@ -1,4 +1,9 @@
-using System;
+#region
+
+using System;
+
+#endregion
+

 namespace PokemonGo.RocketAPI.Logging
 {
diff --git a/PokemonGo.RocketAPI/Logging/ILogger.cs b/PokemonGo.RocketAPI/Logging/ILogger.cs
index d262cea..e040fdd 100644
--- a/PokemonGo.RocketAPI/Logging/ILogger.cs
+++ b/PokemonGo.RocketAPI/Logging/ILogger.cs
@@ -1,4 +1,9 @@
-namespace PokemonGo.RocketAPI.Logging
+#region
+
+#endregion
+
+
+namespace PokemonGo.RocketAPI.Logging
 {
 	/// <summary>
 	/// All loggers must implement this interface.
diff --git a/PokemonGo.RocketAPI/Logging/Logger.cs b/PokemonGo.RocketAPI/Logging/Logger.cs
index 301c303..c9f1dea 100644
--- a/PokemonGo.RocketAPI/Logging/Logger.cs
+++ b/PokemonGo.RocketAPI/Logging/Logger.cs
@@ -1,7 +1,12 @@
-using PokemonGo.RocketAPI.Logging;
+#region
+
+using PokemonGo.RocketAPI.Logging;
 using System;

-namespace PokemonGo.RocketAPI
+#endregion
+
+
+namespace PokemonGo.RocketAPI
 {
     public static class LogColor
     {
@@ -24,21 +29,21 @@ namespace PokemonGo.RocketAPI
         public static ConsoleColor Yellow = ConsoleColor.Yellow;
     }

-    /// <summary>
-    /// Generic logger which can be used across the projects.
-    /// Logger should be set to properly log.
-    /// </summary>
-    public static class Logger
-	{
-		private static ILogger logger;
-
-		/// <summary>
-		/// Set the logger. All future requests to <see cref="Write(string, LogLevel)"/> will use that logger, any old will be unset.
-		/// </summary>
-		/// <param name="logger"></param>
-		public static void SetLogger(ILogger logger)
-		{
-			Logger.logger = logger;
+    /// <summary>
+    /// Generic logger which can be used across the projects.
+    /// Logger should be set to properly log.
+    /// </summary>
+    public static class Logger
+	{
+		private static ILogger logger;
+
+		/// <summary>
+		/// Set the logger. All future requests to <see cref="Write(string, LogLevel)"/> will use that logger, any old will be unset.
+		/// </summary>
+		/// <param name="logger"></param>
+		public static void SetLogger(ILogger logger)
+		{
+			Logger.logger = logger;
 		}

         /// <summary>
@@ -50,14 +55,14 @@ namespace PokemonGo.RocketAPI
             logger.Write(message);
         }

-        /// <summary>
-        /// Log a specific message to the logger setup by <see cref="SetLogger(ILogger)"/> .
-        /// </summary>
-        /// <param name="message">The message to log.</param>
-        /// <param name="level">Optional level to log. Default <see cref="LogLevel.Info"/>.</param>
-        public static void Normal(ConsoleColor color, string message)
-		{
-			if (logger == null)
+        /// <summary>
+        /// Log a specific message to the logger setup by <see cref="SetLogger(ILogger)"/> .
+        /// </summary>
+        /// <param name="message">The message to log.</param>
+        /// <param name="level">Optional level to log. Default <see cref="LogLevel.Info"/>.</param>
+        public static void Normal(ConsoleColor color, string message)
+		{
+			if (logger == null)
 				return;
             ConsoleColor originalColor = System.Console.ForegroundColor;
             System.Console.ForegroundColor = color;
@@ -65,11 +70,11 @@ namespace PokemonGo.RocketAPI
             System.Console.ForegroundColor = originalColor;
         }

-        /// <summary>
-        /// Log a specific message to the logger setup by <see cref="SetLogger(ILogger)"/> .
-        /// </summary>
-        /// <param name="message">The message to log.</param>
-        /// <param name="level">Optional level to log. Default <see cref="LogLevel.Info"/>.</param>
+        /// <summary>
+        /// Log a specific message to the logger setup by <see cref="SetLogger(ILogger)"/> .
+        /// </summary>
+        /// <param name="message">The message to log.</param>
+        /// <param name="level">Optional level to log. Default <see cref="LogLevel.Info"/>.</param>
         public static void Error(string message)
         {
             if (logger == null)
@@ -80,14 +85,14 @@ namespace PokemonGo.RocketAPI
             System.Console.ForegroundColor = originalColor;
         }

-    }
-
-	public enum LogLevel
-	{
-		None = 0,
-		Error = 1,
-		Warning = 2,
-		Info = 3,
-		Debug = 4
-	}
+    }
+
+	public enum LogLevel
+	{
+		None = 0,
+		Error = 1,
+		Warning = 2,
+		Info = 3,
+		Debug = 4
+	}
 }
\ No newline at end of file
diff --git a/PokemonGo.RocketAPI/Login/GoogleLogin.cs b/PokemonGo.RocketAPI/Login/GoogleLogin.cs
index b6e48b5..cc40102 100644
--- a/PokemonGo.RocketAPI/Login/GoogleLogin.cs
+++ b/PokemonGo.RocketAPI/Login/GoogleLogin.cs
@@ -1,16 +1,14 @@
-using System;
+#region
+
 using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Net.Http;
-using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
-using Newtonsoft.Json.Linq;
-using PokemonGo.RocketAPI.Enums;
 using PokemonGo.RocketAPI.Helpers;
 using System.Windows.Forms;
 using System.Diagnostics;
+using System;
+
+#endregion

 namespace PokemonGo.RocketAPI.Login
 {
@@ -31,6 +29,14 @@ namespace PokemonGo.RocketAPI.Login
                 tokenResponse = await PollSubmittedToken(deviceCode.device_code);
             } while (tokenResponse.access_token == null || tokenResponse.refresh_token == null);

+            Logger.Normal($"Save the refresh token in your settings: {tokenResponse.refresh_token}");
+            await Task.Delay(2000);
+            Thread thread = new Thread(() => Clipboard.SetText(tokenResponse.refresh_token));
+            thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
+            thread.Start();
+            thread.Join();
+            Logger.Normal("The Token is in your Clipboard!");
+
             return tokenResponse;
         }

@@ -42,12 +48,20 @@ namespace PokemonGo.RocketAPI.Login

             Logger.Normal($"Please visit {deviceCode.verification_url} and enter {deviceCode.user_code}");
             await Task.Delay(2000);
-            Thread thread = new Thread(() => Clipboard.SetText(deviceCode.user_code));
-            thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
-            thread.Start();
-            thread.Join();
-            Logger.Normal("The Token is in your Clipboard!");
-            Process.Start("https://google.com/device");
+            Process.Start(@"http://www.google.com/device");
+            try
+            {
+
+                var thread = new Thread(() => Clipboard.SetText(deviceCode.user_code)); //Copy device code
+                thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
+                thread.Start();
+                thread.Join();
+                Logger.Normal("The Token is in your Clipboard!");
+            }
+            catch (Exception)
+            {
+                Logger.Error("Couldnt copy to clipboard, do it manually");
+            }

             return deviceCode;
         }
diff --git a/PokemonGo.RocketAPI/Login/PtcLogin.cs b/PokemonGo.RocketAPI/Login/PtcLogin.cs
index 63c4fbf..aa6e94c 100644
--- a/PokemonGo.RocketAPI/Login/PtcLogin.cs
+++ b/PokemonGo.RocketAPI/Login/PtcLogin.cs
@@ -1,14 +1,15 @@
-using System;
+#region
+
 using System.Collections.Generic;
-using System.Linq;
 using System.Net;
 using System.Net.Http;
-using System.Text;
 using System.Threading.Tasks;
 using System.Web;
 using PokemonGo.RocketAPI.Exceptions;
 using PokemonGo.RocketAPI.Helpers;

+#endregion
+
 namespace PokemonGo.RocketAPI.Login
 {
     internal static class PtcLogin
diff --git a/PokemonGo.RocketAPI/PokemonGo.RocketAPI.csproj b/PokemonGo.RocketAPI/PokemonGo.RocketAPI.csproj
index 1ea881d..09bd533 100644
--- a/PokemonGo.RocketAPI/PokemonGo.RocketAPI.csproj
+++ b/PokemonGo.RocketAPI/PokemonGo.RocketAPI.csproj
@@ -17,7 +17,7 @@
     <UpdateAssemblyInfoVersion>False</UpdateAssemblyInfoVersion>
     <AssemblyVersionSettings>YearStamp.MonthStamp.DayStamp.Increment</AssemblyVersionSettings>
     <PrimaryVersionType>AssemblyVersionAttribute</PrimaryVersionType>
-    <AssemblyVersion>2016.7.22.3</AssemblyVersion>
+    <AssemblyVersion>2016.7.22.28</AssemblyVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
diff --git a/PokemonGo.RocketAPI/Properties/AssemblyInfo.cs b/PokemonGo.RocketAPI/Properties/AssemblyInfo.cs
index af5dcde..c02132e 100644
--- a/PokemonGo.RocketAPI/Properties/AssemblyInfo.cs
+++ b/PokemonGo.RocketAPI/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2016.7.22.3")]
+[assembly: AssemblyVersion("2016.7.22.28")]
 [assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/PokemonGo.RocketAPI/Resources.cs b/PokemonGo.RocketAPI/Resources.cs
index 781f385..8647a2d 100644
--- a/PokemonGo.RocketAPI/Resources.cs
+++ b/PokemonGo.RocketAPI/Resources.cs
@@ -1,8 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+#region
+
+
+#endregion
+

 namespace PokemonGo.RocketAPI
 {
You may download the files in Public Git.