Add specific delay for item recycle

Brian [2016-08-23 15:55:32]
Add specific delay for item recycle
Filename
PokemonGo.RocketBot.Logic/ILogicSettings.cs
PokemonGo.RocketBot.Logic/Settings.cs
PokemonGo.RocketBot.Logic/Tasks/RecycleItemsTask.cs
PokemonGo.RocketBot.Logic/Tasks/RecycleSpecificItemTask.cs
PokemonGo.RocketBot.Window/Forms/SettingForm.Designer.cs
PokemonGo.RocketBot.Window/Forms/SettingForm.cs
diff --git a/PokemonGo.RocketBot.Logic/ILogicSettings.cs b/PokemonGo.RocketBot.Logic/ILogicSettings.cs
index 77de51f..687b3e7 100644
--- a/PokemonGo.RocketBot.Logic/ILogicSettings.cs
+++ b/PokemonGo.RocketBot.Logic/ILogicSettings.cs
@@ -174,7 +174,7 @@ namespace PokemonGo.RocketBot.Logic
         bool SnipePokemonNotInPokedex { get; }
         bool RandomizeRecycle { get; }
         int RandomRecycleValue { get; }
-        bool DelayBetweenRecycleActions { get; }
+        int DelayBetweenRecycle{ get; }
         int TotalAmountOfPokeballsToKeep { get; }
         int TotalAmountOfPotionsToKeep { get; }
         int TotalAmountOfRevivesToKeep { get; }
diff --git a/PokemonGo.RocketBot.Logic/Settings.cs b/PokemonGo.RocketBot.Logic/Settings.cs
index 4b71135..01a2b15 100644
--- a/PokemonGo.RocketBot.Logic/Settings.cs
+++ b/PokemonGo.RocketBot.Logic/Settings.cs
@@ -309,7 +309,7 @@ namespace PokemonGo.RocketBot.Logic

         [DefaultValue(2000)] public int DelayBetweenPokemonCatch;

-        [DefaultValue(true)] public bool DelayBetweenRecycleActions;
+        [DefaultValue(500)] public int DelayBetweenRecycle;

         [DefaultValue(true)] public bool DetailedCountsBeforeRecycling;

@@ -1380,6 +1380,7 @@ namespace PokemonGo.RocketBot.Logic
         public int ForceExcellentThrowOverCp => _settings.ForceExcellentThrowOverCp;
         public int DelayBetweenPokemonCatch => _settings.DelayBetweenPokemonCatch;
         public int DelayBetweenPlayerActions => _settings.DelayBetweenPlayerActions;
+        public int DelayBetweenRecycle => _settings.DelayBetweenRecycle;
         public bool UsePokemonToNotCatchFilter => _settings.UsePokemonToNotCatchFilter;
         public bool UsePokemonSniperFilterOnly => _settings.UsePokemonSniperFilterOnly;
         public int KeepMinDuplicatePokemon => _settings.KeepMinDuplicatePokemon;
@@ -1440,7 +1441,6 @@ namespace PokemonGo.RocketBot.Logic
         public bool SnipePokemonNotInPokedex => _settings.SnipePokemonNotInPokedex;
         public bool RandomizeRecycle => _settings.RandomizeRecycle;
         public int RandomRecycleValue => _settings.RandomRecycleValue;
-        public bool DelayBetweenRecycleActions => _settings.DelayBetweenRecycleActions;
         public int TotalAmountOfPokeballsToKeep => _settings.TotalAmountOfPokeballsToKeep;
         public int TotalAmountOfPotionsToKeep => _settings.TotalAmountOfPotionsToKeep;
         public int TotalAmountOfRevivesToKeep => _settings.TotalAmountOfRevivesToKeep;
diff --git a/PokemonGo.RocketBot.Logic/Tasks/RecycleItemsTask.cs b/PokemonGo.RocketBot.Logic/Tasks/RecycleItemsTask.cs
index d851dda..960b562 100644
--- a/PokemonGo.RocketBot.Logic/Tasks/RecycleItemsTask.cs
+++ b/PokemonGo.RocketBot.Logic/Tasks/RecycleItemsTask.cs
@@ -24,7 +24,7 @@ namespace PokemonGo.RocketBot.Logic.Tasks
             cancellationToken.ThrowIfCancellationRequested();

             var currentTotalItems = await session.Inventory.GetTotalItemCount();
-            if (session.Profile.PlayerData.MaxItemStorage*session.LogicSettings.RecycleInventoryAtUsagePercentage/100.0f >
+            if (session.Profile.PlayerData.MaxItemStorage * session.LogicSettings.RecycleInventoryAtUsagePercentage / 100.0f >
                 currentTotalItems)
                 return;

@@ -91,7 +91,7 @@ namespace PokemonGo.RocketBot.Logic.Tasks

             await session.Inventory.RefreshCachedInventory();
             currentTotalItems = await session.Inventory.GetTotalItemCount();
-            if (session.Profile.PlayerData.MaxItemStorage*session.LogicSettings.RecycleInventoryAtUsagePercentage/100.0f >
+            if (session.Profile.PlayerData.MaxItemStorage * session.LogicSettings.RecycleInventoryAtUsagePercentage / 100.0f >
                 currentTotalItems)
                 return;

@@ -104,9 +104,8 @@ namespace PokemonGo.RocketBot.Logic.Tasks
                 await session.Client.Inventory.RecycleItem(item.ItemId, item.Count);

                 if (session.LogicSettings.VerboseRecycling)
-                    session.EventDispatcher.Send(new ItemRecycledEvent {Id = item.ItemId, Count = item.Count});
-                if (session.LogicSettings.DelayBetweenRecycleActions)
-                    DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500);
+                    session.EventDispatcher.Send(new ItemRecycledEvent { Id = item.ItemId, Count = item.Count });
+                DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500);
             }

             await session.Inventory.RefreshCachedInventory();
@@ -126,9 +125,8 @@ namespace PokemonGo.RocketBot.Logic.Tasks
                 cancellationToken.ThrowIfCancellationRequested();
                 await session.Client.Inventory.RecycleItem(item, itemsToRecycle);
                 if (session.LogicSettings.VerboseRecycling)
-                    session.EventDispatcher.Send(new ItemRecycledEvent {Id = item, Count = itemsToRecycle});
-                if (session.LogicSettings.DelayBetweenRecycleActions)
-                    DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500);
+                    session.EventDispatcher.Send(new ItemRecycledEvent { Id = item, Count = itemsToRecycle });
+                DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500);
             }
         }

@@ -140,7 +138,7 @@ namespace PokemonGo.RocketBot.Logic.Tasks
             var masterBallsCount = await session.Inventory.GetItemAmountByType(ItemId.ItemMasterBall);

             var totalBallsCount = pokeBallsCount + greatBallsCount + ultraBallsCount + masterBallsCount;
-            var random = rnd.Next(-1*session.LogicSettings.RandomRecycleValue,
+            var random = rnd.Next(-1 * session.LogicSettings.RandomRecycleValue,
                 session.LogicSettings.RandomRecycleValue + 1);

             if (totalBallsCount > session.LogicSettings.TotalAmountOfPokeballsToKeep)
@@ -181,7 +179,7 @@ namespace PokemonGo.RocketBot.Logic.Tasks
             var maxPotionCount = await session.Inventory.GetItemAmountByType(ItemId.ItemMaxPotion);

             var totalPotionsCount = potionCount + superPotionCount + hyperPotionsCount + maxPotionCount;
-            var random = rnd.Next(-1*session.LogicSettings.RandomRecycleValue,
+            var random = rnd.Next(-1 * session.LogicSettings.RandomRecycleValue,
                 session.LogicSettings.RandomRecycleValue + 1);
             if (totalPotionsCount > session.LogicSettings.TotalAmountOfPotionsToKeep)
             {
@@ -222,7 +220,7 @@ namespace PokemonGo.RocketBot.Logic.Tasks
             var maxReviveCount = await session.Inventory.GetItemAmountByType(ItemId.ItemMaxRevive);

             var totalRevivesCount = reviveCount + maxReviveCount;
-            var random = rnd.Next(-1*session.LogicSettings.RandomRecycleValue,
+            var random = rnd.Next(-1 * session.LogicSettings.RandomRecycleValue,
                 session.LogicSettings.RandomRecycleValue + 1);
             if (totalRevivesCount > session.LogicSettings.TotalAmountOfRevivesToKeep)
             {
@@ -255,7 +253,7 @@ namespace PokemonGo.RocketBot.Logic.Tasks
             var wepar = await session.Inventory.GetItemAmountByType(ItemId.ItemWeparBerry);

             var totalBerryCount = razz + bluk + nanab + pinap + wepar;
-            var random = rnd.Next(-1*session.LogicSettings.RandomRecycleValue,
+            var random = rnd.Next(-1 * session.LogicSettings.RandomRecycleValue,
                 session.LogicSettings.RandomRecycleValue + 1);
             if (totalBerryCount > session.LogicSettings.TotalAmountOfBerriesToKeep)
             {
diff --git a/PokemonGo.RocketBot.Logic/Tasks/RecycleSpecificItemTask.cs b/PokemonGo.RocketBot.Logic/Tasks/RecycleSpecificItemTask.cs
index d81a36f..fa334db 100644
--- a/PokemonGo.RocketBot.Logic/Tasks/RecycleSpecificItemTask.cs
+++ b/PokemonGo.RocketBot.Logic/Tasks/RecycleSpecificItemTask.cs
@@ -3,6 +3,7 @@ using PokemonGo.RocketBot.Logic.Logging;
 using PokemonGo.RocketBot.Logic.State;
 using POGOProtos.Inventory.Item;
 using POGOProtos.Networking.Responses;
+using PokemonGo.RocketBot.Logic.Utils;

 namespace PokemonGo.RocketBot.Logic.Tasks
 {
@@ -23,6 +24,7 @@ namespace PokemonGo.RocketBot.Logic.Tasks
                     $"Unable to recycle {count}x {itemId.ToString().Substring(4)}",
                     LogLevel.Error);
             }
+            DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 500);
         }
     }
 }
\ No newline at end of file
diff --git a/PokemonGo.RocketBot.Window/Forms/SettingForm.Designer.cs b/PokemonGo.RocketBot.Window/Forms/SettingForm.Designer.cs
index 8766141..343921c 100644
--- a/PokemonGo.RocketBot.Window/Forms/SettingForm.Designer.cs
+++ b/PokemonGo.RocketBot.Window/Forms/SettingForm.Designer.cs
@@ -243,7 +243,8 @@
             this.label59 = new System.Windows.Forms.Label();
             this.tbMaxTravelDistanceInMeters = new System.Windows.Forms.TextBox();
             this.groupBox15 = new System.Windows.Forms.GroupBox();
-            this.cbDelayBetweenRecycleActions = new System.Windows.Forms.CheckBox();
+            this.label48 = new System.Windows.Forms.Label();
+            this.tbDelayBetweenRecycle = new System.Windows.Forms.TextBox();
             this.label49 = new System.Windows.Forms.Label();
             this.tbDelayBetweenPlayerActions = new System.Windows.Forms.TextBox();
             this.label50 = new System.Windows.Forms.Label();
@@ -1435,7 +1436,7 @@
             this.clbIgnore.Location = new System.Drawing.Point(6, 44);
             this.clbIgnore.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
             this.clbIgnore.Name = "clbIgnore";
-            this.clbIgnore.Size = new System.Drawing.Size(259, 112);
+            this.clbIgnore.Size = new System.Drawing.Size(259, 76);
             this.clbIgnore.TabIndex = 0;
             //
             // tBMaxBerriesToUsePerPokemon
@@ -1497,7 +1498,7 @@
             this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
             this.groupBox1.Name = "groupBox1";
             this.groupBox1.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.groupBox1.Size = new System.Drawing.Size(220, 452);
+            this.groupBox1.Size = new System.Drawing.Size(220, 456);
             this.groupBox1.TabIndex = 20;
             this.groupBox1.TabStop = false;
             this.groupBox1.Text = "Exclude Transfer";
@@ -1842,7 +1843,7 @@
             this.groupBox4.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
             this.groupBox4.Name = "groupBox4";
             this.groupBox4.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.groupBox4.Size = new System.Drawing.Size(220, 455);
+            this.groupBox4.Size = new System.Drawing.Size(220, 459);
             this.groupBox4.TabIndex = 5;
             this.groupBox4.TabStop = false;
             this.groupBox4.Text = "Power Up";
@@ -2022,7 +2023,7 @@
             this.groupBox3.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
             this.groupBox3.Name = "groupBox3";
             this.groupBox3.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.groupBox3.Size = new System.Drawing.Size(220, 455);
+            this.groupBox3.Size = new System.Drawing.Size(220, 459);
             this.groupBox3.TabIndex = 16;
             this.groupBox3.TabStop = false;
             this.groupBox3.Text = "Evolve";
@@ -2414,9 +2415,9 @@
             this.groupBox17.Controls.Add(this.cbRandomizeRecycle);
             this.groupBox17.Controls.Add(this.label51);
             this.groupBox17.Controls.Add(this.tbRandomRecycleValue);
-            this.groupBox17.Location = new System.Drawing.Point(8, 332);
+            this.groupBox17.Location = new System.Drawing.Point(325, 297);
             this.groupBox17.Name = "groupBox17";
-            this.groupBox17.Size = new System.Drawing.Size(311, 85);
+            this.groupBox17.Size = new System.Drawing.Size(358, 85);
             this.groupBox17.TabIndex = 19;
             this.groupBox17.TabStop = false;
             this.groupBox17.Text = "Recycle Behavior";
@@ -2442,7 +2443,7 @@
             //
             // tbRandomRecycleValue
             //
-            this.tbRandomRecycleValue.Location = new System.Drawing.Point(182, 46);
+            this.tbRandomRecycleValue.Location = new System.Drawing.Point(226, 46);
             this.tbRandomRecycleValue.Margin = new System.Windows.Forms.Padding(3, 5, 3, 5);
             this.tbRandomRecycleValue.Name = "tbRandomRecycleValue";
             this.tbRandomRecycleValue.Size = new System.Drawing.Size(123, 23);
@@ -2549,27 +2550,35 @@
             //
             // groupBox15
             //
-            this.groupBox15.Controls.Add(this.cbDelayBetweenRecycleActions);
+            this.groupBox15.Controls.Add(this.label48);
+            this.groupBox15.Controls.Add(this.tbDelayBetweenRecycle);
             this.groupBox15.Controls.Add(this.label49);
             this.groupBox15.Controls.Add(this.tbDelayBetweenPlayerActions);
             this.groupBox15.Controls.Add(this.label50);
             this.groupBox15.Controls.Add(this.tbDelayBetweenPokemonCatch);
             this.groupBox15.Location = new System.Drawing.Point(8, 213);
             this.groupBox15.Name = "groupBox15";
-            this.groupBox15.Size = new System.Drawing.Size(311, 113);
+            this.groupBox15.Size = new System.Drawing.Size(311, 169);
             this.groupBox15.TabIndex = 18;
             this.groupBox15.TabStop = false;
-            this.groupBox15.Text = "Auction Behavior";
+            this.groupBox15.Text = "Action Behavior";
             //
-            // cbDelayBetweenRecycleActions
+            // label48
             //
-            this.cbDelayBetweenRecycleActions.AutoSize = true;
-            this.cbDelayBetweenRecycleActions.Location = new System.Drawing.Point(9, 85);
-            this.cbDelayBetweenRecycleActions.Name = "cbDelayBetweenRecycleActions";
-            this.cbDelayBetweenRecycleActions.Size = new System.Drawing.Size(189, 19);
-            this.cbDelayBetweenRecycleActions.TabIndex = 17;
-            this.cbDelayBetweenRecycleActions.Text = "Delay Between Recycle Actions";
-            this.cbDelayBetweenRecycleActions.UseVisualStyleBackColor = true;
+            this.label48.AutoSize = true;
+            this.label48.Location = new System.Drawing.Point(6, 90);
+            this.label48.Name = "label48";
+            this.label48.Size = new System.Drawing.Size(168, 15);
+            this.label48.TabIndex = 21;
+            this.label48.Text = "Delay Between Recycling (ms):";
+            //
+            // tbDelayBetweenRecycle
+            //
+            this.tbDelayBetweenRecycle.Location = new System.Drawing.Point(182, 87);
+            this.tbDelayBetweenRecycle.Margin = new System.Windows.Forms.Padding(3, 5, 3, 5);
+            this.tbDelayBetweenRecycle.Name = "tbDelayBetweenRecycle";
+            this.tbDelayBetweenRecycle.Size = new System.Drawing.Size(123, 23);
+            this.tbDelayBetweenRecycle.TabIndex = 22;
             //
             // label49
             //
@@ -2888,7 +2897,6 @@
         private System.Windows.Forms.TextBox tbDelayBetweenPlayerActions;
         private System.Windows.Forms.Label label50;
         private System.Windows.Forms.TextBox tbDelayBetweenPokemonCatch;
-        private System.Windows.Forms.CheckBox cbDelayBetweenRecycleActions;
         private System.Windows.Forms.GroupBox groupBox17;
         private System.Windows.Forms.CheckBox cbRandomizeRecycle;
         private System.Windows.Forms.Label label51;
@@ -2915,5 +2923,7 @@
         private System.Windows.Forms.Label GoogleApiLabel;
         private System.Windows.Forms.CheckBox cbShowWalkingSpeed;
         private System.Windows.Forms.CheckBox cbUseWalkingSpeedVariant;
+        private System.Windows.Forms.Label label48;
+        private System.Windows.Forms.TextBox tbDelayBetweenRecycle;
     }
 }
\ No newline at end of file
diff --git a/PokemonGo.RocketBot.Window/Forms/SettingForm.cs b/PokemonGo.RocketBot.Window/Forms/SettingForm.cs
index f27137d..9e20f64 100644
--- a/PokemonGo.RocketBot.Window/Forms/SettingForm.cs
+++ b/PokemonGo.RocketBot.Window/Forms/SettingForm.cs
@@ -269,7 +269,7 @@ namespace PokemonGo.RocketBot.Window.Forms

             tbDelayBetweenPlayerActions.Text = _setting.DelayBetweenPlayerActions.ToString();
             tbDelayBetweenPokemonCatch.Text = _setting.DelayBetweenPokemonCatch.ToString();
-            cbDelayBetweenRecycleActions.Checked = _setting.DelayBetweenRecycleActions;
+            tbDelayBetweenRecycle.Text = _setting.DelayBetweenRecycle.ToString();

             cbRandomizeRecycle.Checked = _setting.RandomizeRecycle;
             tbRandomRecycleValue.Text = _setting.RandomRecycleValue.ToString();
@@ -291,14 +291,14 @@ namespace PokemonGo.RocketBot.Window.Forms

         protected override void OnLoad(EventArgs e)
         {
-            var btn = new Button {Size = new Size(25, GoogleApiBox.ClientSize.Height + 2)};
+            var btn = new Button { Size = new Size(25, GoogleApiBox.ClientSize.Height + 2) };
             btn.Location = new Point(GoogleApiBox.ClientSize.Width - btn.Width, -1);
             btn.Cursor = Cursors.Default;
             btn.Image = ResourceHelper.GetImage("question");
             btn.Click += googleapihep_click;
             GoogleApiBox.Controls.Add(btn);
             // Send EM_SETMARGINS to prevent text from disappearing underneath the button
-            SendMessage(GoogleApiBox.Handle, 0xd3, (IntPtr) 2, (IntPtr) (btn.Width << 16));
+            SendMessage(GoogleApiBox.Handle, 0xd3, (IntPtr)2, (IntPtr)(btn.Width << 16));
             base.OnLoad(e);
         }

@@ -345,7 +345,7 @@ namespace PokemonGo.RocketBot.Window.Forms
         /// </summary>
         private void GetLanguageList()
         {
-            var languages = new List<string> {"en"};
+            var languages = new List<string> { "en" };
             var langFiles = Directory.GetFiles(LanguagePath, "*.json", SearchOption.TopDirectoryOnly);
             languages.AddRange(langFiles.Select(
                 langFileName => Path.GetFileNameWithoutExtension(langFileName)?.Replace("translation.", ""))
@@ -362,7 +362,7 @@ namespace PokemonGo.RocketBot.Window.Forms
             tbLatitude.Text = gMapCtrl.Position.Lat.ToString(CultureInfo.InvariantCulture);
             tbLongitude.Text = gMapCtrl.Position.Lng.ToString(CultureInfo.InvariantCulture);
             //update trackbar
-            trackBar.Value = (int) Math.Round(gMapCtrl.Zoom);
+            trackBar.Value = (int)Math.Round(gMapCtrl.Zoom);
         }

         /// <summary>
@@ -619,7 +619,7 @@ namespace PokemonGo.RocketBot.Window.Forms

                 _setting.DelayBetweenPlayerActions = ConvertStringToInt(tbDelayBetweenPlayerActions.Text);
                 _setting.DelayBetweenPokemonCatch = ConvertStringToInt(tbDelayBetweenPokemonCatch.Text);
-                _setting.DelayBetweenRecycleActions = cbDelayBetweenRecycleActions.Checked;
+                _setting.DelayBetweenRecycle = ConvertStringToInt(tbDelayBetweenRecycle.Text);

                 _setting.RandomizeRecycle = cbRandomizeRecycle.Checked;
                 _setting.RandomRecycleValue = ConvertStringToInt(tbRandomRecycleValue.Text);
@@ -707,7 +707,7 @@ namespace PokemonGo.RocketBot.Window.Forms

         private void AdressBox_KeyPress(object sender, KeyPressEventArgs e)
         {
-            if (e.KeyChar != (char) Keys.Enter)
+            if (e.KeyChar != (char)Keys.Enter)
             {
                 return;
             }
You may download the files in Public Git.