Merge pull request #520 from DetectiveSquirrel/Beta-Build

Detective Squirrel [2016-07-29 17:29:49]
Merge pull request #520 from DetectiveSquirrel/Beta-Build

Beta build merge
Filename
PokemonGo/RocketAPI/Window/MainForm.Designer.cs
PokemonGo/RocketAPI/Window/MainForm.cs
README.md
diff --git a/PokemonGo/RocketAPI/Window/MainForm.Designer.cs b/PokemonGo/RocketAPI/Window/MainForm.Designer.cs
index a41b76d..2c3859c 100644
--- a/PokemonGo/RocketAPI/Window/MainForm.Designer.cs
+++ b/PokemonGo/RocketAPI/Window/MainForm.Designer.cs
@@ -33,7 +33,7 @@
             this.statusStrip1 = new System.Windows.Forms.StatusStrip();
             this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel();
             this.menuStrip1 = new System.Windows.Forms.MenuStrip();
-            this.startBotToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.startStopBotToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.mapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.todoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.pokemonToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
@@ -79,7 +79,7 @@
             // menuStrip1
             //
             this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.startBotToolStripMenuItem,
+            this.startStopBotToolStripMenuItem,
             this.mapToolStripMenuItem,
             this.todoToolStripMenuItem,
             this.pokemonToolStripMenuItem2,
@@ -93,10 +93,10 @@
             //
             // startBotToolStripMenuItem
             //
-            this.startBotToolStripMenuItem.Name = "startBotToolStripMenuItem";
-            this.startBotToolStripMenuItem.Size = new System.Drawing.Size(64, 20);
-            this.startBotToolStripMenuItem.Text = "Start Bot";
-            this.startBotToolStripMenuItem.Click += new System.EventHandler(this.startBotToolStripMenuItem_Click);
+            this.startStopBotToolStripMenuItem.Name = "startStopBotToolStripMenuItem";
+            this.startStopBotToolStripMenuItem.Size = new System.Drawing.Size(64, 20);
+            this.startStopBotToolStripMenuItem.Text = "Start Bot";
+            this.startStopBotToolStripMenuItem.Click += new System.EventHandler(this.startStopBotToolStripMenuItem_Click);
             //
             // mapToolStripMenuItem
             //
@@ -173,7 +173,7 @@
         private System.Windows.Forms.MenuStrip menuStrip1;
         private System.Windows.Forms.ToolStripMenuItem todoToolStripMenuItem;
         private System.Windows.Forms.ToolStripStatusLabel statusLabel;
-        private System.Windows.Forms.ToolStripMenuItem startBotToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem startStopBotToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem showAllToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem showAllToolStripMenuItem1;
         private System.Windows.Forms.ToolStripMenuItem pokemonToolStripMenuItem2;
diff --git a/PokemonGo/RocketAPI/Window/MainForm.cs b/PokemonGo/RocketAPI/Window/MainForm.cs
index fa85042..67fd3eb 100644
--- a/PokemonGo/RocketAPI/Window/MainForm.cs
+++ b/PokemonGo/RocketAPI/Window/MainForm.cs
@@ -38,6 +38,7 @@ namespace PokemonGo.RocketAPI.Window
         private static int Currentlevel = -1;
         private static int TotalExperience = 0;
         private static int TotalPokemon = 0;
+        private static bool Stopping = false;
         private static bool ForceUnbanning = false;
         private static bool FarmingStops = false;
         private static bool FarmingPokemons = false;
@@ -110,6 +111,17 @@ namespace PokemonGo.RocketAPI.Window
             }
         }

+        public void ConsoleClear()
+        {
+            if (InvokeRequired)
+            {
+                Invoke(new Action(ConsoleClear));
+                return;
+            }
+
+            logTextBox.Clear();
+        }
+
         public void SetStatusText(string text)
         {
             if (InvokeRequired)
@@ -284,17 +296,27 @@ namespace PokemonGo.RocketAPI.Window
                     await Task.Delay(25);

                 // await ForceUnban(client);
-                ColoredConsoleWrite(Color.Red, $"No nearby useful locations found. Please wait 10 seconds.");
-                await Task.Delay(10000);
-                CheckVersion();
-                Execute();
+                if (!Stopping)
+                {
+                    ColoredConsoleWrite(Color.Red, $"No nearby useful locations found. Please wait 10 seconds.");
+                    await Task.Delay(10000);
+                    CheckVersion();
+                    Execute();
+                } else
+                {
+                    ConsoleClear();
+                    ColoredConsoleWrite(Color.Red, $"Bot successfully stopped.");
+                    startStopBotToolStripMenuItem.Text = "Start";
+                    Stopping = false;
+                    bot_started = false;
+                }
             }
-            catch (TaskCanceledException) { ColoredConsoleWrite(Color.Red, "Task Canceled Exception - Restarting"); Execute(); }
-            catch (UriFormatException) { ColoredConsoleWrite(Color.Red, "System URI Format Exception - Restarting"); Execute(); }
-            catch (ArgumentOutOfRangeException) { ColoredConsoleWrite(Color.Red, "ArgumentOutOfRangeException - Restarting"); Execute(); }
-            catch (ArgumentNullException) { ColoredConsoleWrite(Color.Red, "Argument Null Refference - Restarting"); Execute(); }
-            catch (NullReferenceException) { ColoredConsoleWrite(Color.Red, "Null Refference - Restarting"); Execute(); }
-            catch (Exception ex) { ColoredConsoleWrite(Color.Red, ex.ToString()); Execute(); }
+            catch (TaskCanceledException) { ColoredConsoleWrite(Color.Red, "Task Canceled Exception - Restarting"); if (!Stopping) Execute();}
+            catch (UriFormatException) { ColoredConsoleWrite(Color.Red, "System URI Format Exception - Restarting"); if (!Stopping) Execute(); }
+            catch (ArgumentOutOfRangeException) { ColoredConsoleWrite(Color.Red, "ArgumentOutOfRangeException - Restarting"); if (!Stopping) Execute(); }
+            catch (ArgumentNullException) { ColoredConsoleWrite(Color.Red, "Argument Null Refference - Restarting"); if (!Stopping) Execute(); }
+            catch (NullReferenceException) { ColoredConsoleWrite(Color.Red, "Null Refference - Restarting"); if (!Stopping) Execute(); }
+            catch (Exception ex) { ColoredConsoleWrite(Color.Red, ex.ToString()); if (!Stopping) Execute(); }
         }

         private static string CallAPI(string elem, double lat, double lon)
@@ -342,7 +364,7 @@ namespace PokemonGo.RocketAPI.Window

             foreach (var pokemon in pokemons)
             {
-                if (ForceUnbanning)
+                if (ForceUnbanning || Stopping)
                     break;

                 FarmingPokemons = true;
@@ -425,11 +447,11 @@ namespace PokemonGo.RocketAPI.Window
             }
             HashSet<FortData> pokeStopSet = new HashSet<FortData>(pokeStops);
             IEnumerable<FortData> nextPokeStopList = null;
-            if (!ForceUnbanning)
+            if (!ForceUnbanning && !Stopping)
                 ColoredConsoleWrite(Color.Cyan, $"Visiting {pokeStops.Count()} PokeStops");
             foreach (var pokeStop in pokeStops)
             {
-                if (ForceUnbanning)
+                if (ForceUnbanning || Stopping)
                     break;

                 FarmingStops = true;
@@ -486,7 +508,7 @@ namespace PokemonGo.RocketAPI.Window

         private async Task ForceUnban(Client client)
         {
-            if (!ForceUnbanning)
+            if (!ForceUnbanning && !Stopping)
             {
                 ColoredConsoleWrite(Color.LightGreen, "Waiting for last farming action to be complete...");
                 ForceUnbanning = true;
@@ -539,7 +561,7 @@ namespace PokemonGo.RocketAPI.Window
             }
             else
             {
-                ColoredConsoleWrite(Color.Red, "A force unban attempt is in action... Please wait.");
+                ColoredConsoleWrite(Color.Red, "A action is in play... Please wait.");
             }


@@ -945,26 +967,41 @@ namespace PokemonGo.RocketAPI.Window
             settingsForm.Show();
         }

-        private void startBotToolStripMenuItem_Click(object sender, EventArgs e)
+        private static bool bot_started = false;
+        private void startStopBotToolStripMenuItem_Click(object sender, EventArgs e)
         {
-            startBotToolStripMenuItem.Enabled = false;
-            Task.Run(() =>
+            if (!bot_started)
             {
-                try
+                bot_started = true;
+                startStopBotToolStripMenuItem.Text = "Stop Bot";
+                Task.Run(() =>
                 {
-                    //ColoredConsoleWrite(ConsoleColor.White, "Coded by Ferox - edited by NecronomiconCoding");
-                    CheckVersion();
-                    Execute();
-                }
-                catch (PtcOfflineException)
+                    try
+                    {
+                        //ColoredConsoleWrite(ConsoleColor.White, "Coded by Ferox - edited by NecronomiconCoding");
+                        CheckVersion();
+                        Execute();
+                    }
+                    catch (PtcOfflineException)
+                    {
+                        ColoredConsoleWrite(Color.Red, "PTC Servers are probably down OR your credentials are wrong. Try google");
+                    }
+                    catch (Exception ex)
+                    {
+                        ColoredConsoleWrite(Color.Red, $"Unhandled exception: {ex}");
+                    }
+                });
+            } else
+            {
+                if (!ForceUnbanning)
                 {
-                    ColoredConsoleWrite(Color.Red, "PTC Servers are probably down OR your credentials are wrong. Try google");
-                }
-                catch (Exception ex)
+                    Stopping = true;
+                    ColoredConsoleWrite(Color.Red, $"Stopping the bot.. Waiting for the last action to be complete.");
+                } else
                 {
-                    ColoredConsoleWrite(Color.Red, $"Unhandled exception: {ex}");
+                    ColoredConsoleWrite(Color.Red, $"An action is in play, please wait until it's done.");
                 }
-            });
+            }
         }

         private void showAllToolStripMenuItem3_Click(object sender, EventArgs e)
diff --git a/README.md b/README.md
index f396ae3..74a65a8 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,9 @@
 # Pokemon-Go-Rocket-API

+# Discusion not controlled by me but by user 1461748123
+* Discord channel for user and developer discussions.
+* https://discord.gg/y6EU2qY
+
 #Window
 ![alt tag](https://github.com/DetectiveSquirrel/Pokemon-Go-Rocket-API/blob/master/MainWindow.png)
 ![alt tag](https://github.com/DetectiveSquirrel/Pokemon-Go-Rocket-API/blob/master/MainPokeUi.png)
@@ -27,17 +31,27 @@ A Pokémon Go bot in C#
 * Logs everything into Logs.txt

 ## Getting Started
-
-Go to PokemonGo\RocketAPI\Window\App.config -> Edit the Settings you like -> Build and Run (CTRL+F5)
+Build and Run (CTRL+F5)

 # Settings
 ## AuthType
-* *Google* - Google login
-* *Ptc* - Pokémon Trainer Club login with username/password combination
+* *google* - Google login
+* *ptc* - Pokémon Trainer Club

 ## PtcUsername
-* *username* for PTC account. No need for when using Google.
-* *password* for PTC account. No need for when using Google.
+* *username* - for PTC account. No need for when using Google.
+
+## PtcPassword
+* *password* - for PTC account. No need for when using Google.
+
+## Email
+* *email@gmail.com* - for Google account. No need for when using PTC.
+
+## Password
+* *password* - for Google account. No need for when using PTC.
+
+## GoogleRefreshToken
+* *token* - for Google account. No need for wen using PTC. (Obsolete)

 ## DefaultLatitude
 * *12.345678* - Latitude of your location you want to use the bot in. Number between -90 and +90. Doesn't matter how many numbers stand after the comma.
@@ -68,7 +82,8 @@ Go to PokemonGo\RocketAPI\Window\App.config -> Edit the Settings you like -> Bui
 * *probability* - Use RazzBerry when Pokémon catch chance is under a specific percentage.

 ## RazzBerrySetting
-* *value* - CP: Use RazzBerry when Pokémon is over this value | Probability Mode: Use Razzberry when % of catching is under this value
+* *cp value* - If RazzBerryMode is cp. Use RazzBerry when Pokémon is over this value
+* *probability value* - If RazzBerryMode is probability. Use Razzberry when % of catching is under this value. Between 0 and 1.

 ## TransferType
 * *none* - disables transferring
@@ -80,6 +95,19 @@ Go to PokemonGo\RocketAPI\Window\App.config -> Edit the Settings you like -> Bui
 ## TransferCPThreshold
 * *CP* - transfers all Pokémon with less CP than this value.

+## TransferIVThreshold
+* *IV* - transfers all Pokémon with less IV than this value. Between 0 and 1.
+
+## TravelSpeed
+* *Speed* - Travel speed in km/h
+
+## ImageSize
+* *px* - Pixel size for Pokémon Thumbnails
+
+## CatchPokemon
+* *true* - Catch Pokémon and get Items from PokéStops
+* *false* - Don't catch Pokémon and get Items from PokéStops
+
 ## EvolveAllGivenPokemons
 * *false* - Evolves no Pokémon.
 * *true* - Evolves all Pokémon.
\ No newline at end of file
You may download the files in Public Git.