From d11a63d36fbed4d66d40e92d92915e4ab7302ac2 Mon Sep 17 00:00:00 2001 From: Sebastian Kupfer Date: Sat, 23 Jul 2016 00:27:59 +0200 Subject: [PATCH] Add KeepMinDuplicatePokemon to UserSettings and Inventory Logic --- PokemonGo.RocketAPI.Console/App.config | 3 +++ PokemonGo.RocketAPI.Console/Settings.cs | 1 + PokemonGo.RocketAPI.Console/UserSettings.Designer.cs | 12 ++++++++++++ PokemonGo.RocketAPI.Console/UserSettings.settings | 3 +++ PokemonGo.RocketAPI.Logic/Inventory.cs | 9 ++++++++- PokemonGo.RocketAPI/ISettings.cs | 1 + 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/PokemonGo.RocketAPI.Console/App.config b/PokemonGo.RocketAPI.Console/App.config index 6a8b3a5e2..bcec8df5d 100644 --- a/PokemonGo.RocketAPI.Console/App.config +++ b/PokemonGo.RocketAPI.Console/App.config @@ -61,6 +61,9 @@ False + + 1 + diff --git a/PokemonGo.RocketAPI.Console/Settings.cs b/PokemonGo.RocketAPI.Console/Settings.cs index 0eacc072a..4256a2b9f 100644 --- a/PokemonGo.RocketAPI.Console/Settings.cs +++ b/PokemonGo.RocketAPI.Console/Settings.cs @@ -25,6 +25,7 @@ public class Settings : ISettings public bool TransferDuplicatePokemon => UserSettings.Default.TransferDuplicatePokemon; public int DelayBetweenMove => UserSettings.Default.DelayBetweenMove; public bool UsePokemonToNotCatchFilter => UserSettings.Default.UsePokemonToNotCatchFilter; + public int KeepMinDuplicatePokemon => UserSettings.Default.KeepMinDuplicatePokemon; private ICollection _pokemonsToEvolve; private ICollection _pokemonsNotToTransfer; diff --git a/PokemonGo.RocketAPI.Console/UserSettings.Designer.cs b/PokemonGo.RocketAPI.Console/UserSettings.Designer.cs index 0fdef110f..968f51d04 100644 --- a/PokemonGo.RocketAPI.Console/UserSettings.Designer.cs +++ b/PokemonGo.RocketAPI.Console/UserSettings.Designer.cs @@ -190,5 +190,17 @@ public bool UsePokemonToNotCatchFilter { this["UsePokemonToNotCatchFilter"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("1")] + public int KeepMinDuplicatePokemon { + get { + return ((int)(this["KeepMinDuplicatePokemon"])); + } + set { + this["KeepMinDuplicatePokemon"] = value; + } + } } } diff --git a/PokemonGo.RocketAPI.Console/UserSettings.settings b/PokemonGo.RocketAPI.Console/UserSettings.settings index fb277538f..a9d9e983a 100644 --- a/PokemonGo.RocketAPI.Console/UserSettings.settings +++ b/PokemonGo.RocketAPI.Console/UserSettings.settings @@ -44,5 +44,8 @@ False + + 1 + \ No newline at end of file diff --git a/PokemonGo.RocketAPI.Logic/Inventory.cs b/PokemonGo.RocketAPI.Logic/Inventory.cs index ca93860b5..d0bbff000 100644 --- a/PokemonGo.RocketAPI.Logic/Inventory.cs +++ b/PokemonGo.RocketAPI.Logic/Inventory.cs @@ -14,6 +14,13 @@ public class Inventory { private readonly Client _client; + private readonly ISettings _clientSettings; + + public Inventory(ISettings clientSettings) + { + _clientSettings = clientSettings; + } + public Inventory(Client client) { _client = client; @@ -68,7 +75,7 @@ public async Task> GetDuplicatePokemonToTransfer( p.Where(x => x.Favorite == 0) .OrderByDescending(x => x.Cp) .ThenBy(n => n.StaminaMax) - .Skip(1) + .Skip(_clientSettings.KeepMinDuplicatePokemon) .ToList()); } diff --git a/PokemonGo.RocketAPI/ISettings.cs b/PokemonGo.RocketAPI/ISettings.cs index 11cf1fbcb..a6873b799 100644 --- a/PokemonGo.RocketAPI/ISettings.cs +++ b/PokemonGo.RocketAPI/ISettings.cs @@ -24,6 +24,7 @@ public interface ISettings bool TransferDuplicatePokemon { get; } int DelayBetweenMove { get; } bool UsePokemonToNotCatchFilter { get; } + int KeepMinDuplicatePokemon { get; } ICollection> ItemRecycleFilter { get; } ICollection PokemonsToEvolve { get; }