diff --git a/PoGo.NecroBot.Logic/ILogicSettings.cs b/PoGo.NecroBot.Logic/ILogicSettings.cs index c9bb82738..fae2a1e86 100644 --- a/PoGo.NecroBot.Logic/ILogicSettings.cs +++ b/PoGo.NecroBot.Logic/ILogicSettings.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using POGOProtos.Enums; using POGOProtos.Inventory.Item; +using POGOProtos.Settings.Master.Item; #endregion @@ -46,16 +47,19 @@ public TransferFilter() { } - public TransferFilter(int keepMinCp, float keepMinIvPercentage, int keepMinDuplicatePokemon) + public TransferFilter(int keepMinCp, float keepMinIvPercentage, int keepMinDuplicatePokemon, + List moves = null) { KeepMinCp = keepMinCp; KeepMinIvPercentage = keepMinIvPercentage; KeepMinDuplicatePokemon = keepMinDuplicatePokemon; + Moves = moves ?? new List(); } public int KeepMinCp { get; set; } public float KeepMinIvPercentage { get; set; } public int KeepMinDuplicatePokemon { get; set; } + public List Moves { get; set; } } public interface ILogicSettings diff --git a/PoGo.NecroBot.Logic/Settings.cs b/PoGo.NecroBot.Logic/Settings.cs index fe4b6d21f..a655b828b 100644 --- a/PoGo.NecroBot.Logic/Settings.cs +++ b/PoGo.NecroBot.Logic/Settings.cs @@ -13,6 +13,7 @@ using System.ComponentModel; using System.Reflection; using System.Collections; +using System.Linq; #endregion @@ -445,6 +446,12 @@ public static GlobalSettings Load(string path) jsonSettings.DefaultValueHandling = DefaultValueHandling.Populate; settings = JsonConvert.DeserializeObject(input, jsonSettings); + + //This makes sure that existing config files dont get null values which lead to an exception + foreach (var filter in settings.PokemonsTransferFilter.Where(x => x.Value.Moves == null)) + { + filter.Value.Moves = new List(); + } // One day we might be able to better do this so its automatic /* diff --git a/PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs b/PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs index c8b66aff9..52ff3c3a3 100644 --- a/PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs @@ -32,11 +32,14 @@ public static async Task Execute(ISession session, CancellationToken cancellatio foreach (var duplicatePokemon in duplicatePokemons) { cancellationToken.ThrowIfCancellationRequested(); + var pokemonTransferFilter = session.Inventory.GetPokemonTransferFilter(duplicatePokemon.PokemonId); if (duplicatePokemon.Cp >= - session.Inventory.GetPokemonTransferFilter(duplicatePokemon.PokemonId).KeepMinCp || + pokemonTransferFilter.KeepMinCp || PokemonInfo.CalculatePokemonPerfection(duplicatePokemon) > - session.Inventory.GetPokemonTransferFilter(duplicatePokemon.PokemonId).KeepMinIvPercentage) + pokemonTransferFilter.KeepMinIvPercentage || + pokemonTransferFilter.Moves.Contains(duplicatePokemon.Move1) || + pokemonTransferFilter.Moves.Contains(duplicatePokemon.Move2)) { continue; }