diff --git a/PoGo.NecroBot.Logic/ILogicSettings.cs b/PoGo.NecroBot.Logic/ILogicSettings.cs index 84b5d1fd9..c659cea24 100644 --- a/PoGo.NecroBot.Logic/ILogicSettings.cs +++ b/PoGo.NecroBot.Logic/ILogicSettings.cs @@ -69,6 +69,7 @@ public interface ILogicSettings bool TransferConfigAndAuthOnUpdate { get; } float KeepMinIvPercentage { get; } int KeepMinCp { get; } + string KeepMinOperator { get; } double WalkingSpeedInKilometerPerHour { get; } bool EvolveAllPokemonWithEnoughCandy { get; } bool KeepPokemonsThatCanEvolve { get; } diff --git a/PoGo.NecroBot.Logic/Inventory.cs b/PoGo.NecroBot.Logic/Inventory.cs index 4435cf26d..e13d082c4 100644 --- a/PoGo.NecroBot.Logic/Inventory.cs +++ b/PoGo.NecroBot.Logic/Inventory.cs @@ -80,13 +80,16 @@ public async Task> GetDuplicatePokemonToTransfer( { var myPokemon = await GetPokemons(); - var pokemonList = + var pokemonList = (_logicSettings.KeepMinOperator.ToLower().Equals("and")) ? myPokemon.Where( - p => p.DeployedFortId == string.Empty && - p.Favorite == 0 && (p.Cp < GetPokemonTransferFilter(p.PokemonId).KeepMinCp || - PokemonInfo.CalculatePokemonPerfection(p) < - GetPokemonTransferFilter(p.PokemonId).KeepMinIvPercentage)) - .ToList(); + p => p.DeployedFortId == string.Empty && + p.Favorite == 0 && (p.Cp < GetPokemonTransferFilter(p.PokemonId).KeepMinCp || + PokemonInfo.CalculatePokemonPerfection(p) < GetPokemonTransferFilter(p.PokemonId).KeepMinIvPercentage)).ToList() : + myPokemon.Where( + p => p.DeployedFortId == string.Empty && + p.Favorite == 0 && (p.Cp < GetPokemonTransferFilter(p.PokemonId).KeepMinCp && + PokemonInfo.CalculatePokemonPerfection(p) < GetPokemonTransferFilter(p.PokemonId).KeepMinIvPercentage)).ToList(); + if (filter != null) { pokemonList = pokemonList.Where(p => !filter.Contains(p.PokemonId)).ToList(); @@ -138,6 +141,7 @@ public async Task> GetDuplicatePokemonToTransfer( } if (prioritizeIVoverCp) { + var skipnum = GetPokemonTransferFilter(PokemonId.Arbok).KeepMinDuplicatePokemon; return pokemonList .GroupBy(p => p.PokemonId) .Where(x => x.Any()) @@ -416,7 +420,11 @@ public async Task> GetPokemonToUpgrade() myPokemon.Where( p => (p.Cp >= _logicSettings.UpgradePokemonCpMinimum || PokemonInfo.CalculatePokemonPerfection(p) >= _logicSettings.UpgradePokemonIvMinimum)).OrderByDescending(p => p.Cp).ToList(); - + /** + * @todo make sure theres enough candy (see line 109) + * @todo make sure max cp hasnt been reached + * @todo remove _logicSettings.AmountOfTimesToUpgradeLoop and use it as a count limitation in levelup loop for successes instead + * */ return upgradePokemon = (_logicSettings.LevelUpByCPorIv.ToLower().Equals("iv")) ? highestPokemonForUpgrade.OrderByDescending(PokemonInfo.CalculatePokemonPerfection).Take(_logicSettings.AmountOfTimesToUpgradeLoop).ToList() : highestPokemonForUpgrade.Take(_logicSettings.AmountOfTimesToUpgradeLoop).ToList(); diff --git a/PoGo.NecroBot.Logic/Settings.cs b/PoGo.NecroBot.Logic/Settings.cs index 8441d87c2..f6460b9d8 100644 --- a/PoGo.NecroBot.Logic/Settings.cs +++ b/PoGo.NecroBot.Logic/Settings.cs @@ -163,10 +163,21 @@ public class GlobalSettings public bool EvolveAllPokemonAboveIv; [DefaultValue(true)] public bool EvolveAllPokemonWithEnoughCandy; - [DefaultValue(false)] - public bool KeepPokemonsThatCanEvolve; [DefaultValue(0.90)] public double EvolveKeptPokemonsAtStorageUsagePercentage; + [DefaultValue(false)] + public bool KeepPokemonsThatCanEvolve; + //keeping + [DefaultValue(1250)] + public int KeepMinCp; + [DefaultValue(90)] + public float KeepMinIvPercentage; + [DefaultValue("and")] + public string KeepMinOperator; + [DefaultValue(false)] + public bool PrioritizeIvOverCp; + [DefaultValue(1)] + public int KeepMinDuplicatePokemon; //gpx [DefaultValue(false)] public bool UseGpxPathing; @@ -177,15 +188,6 @@ public class GlobalSettings public bool VerboseRecycling; [DefaultValue(0.90)] public double RecycleInventoryAtUsagePercentage; - //keeping - [DefaultValue(1250)] - public int KeepMinCp; - [DefaultValue(1)] - public int KeepMinDuplicatePokemon; - [DefaultValue(90)] - public float KeepMinIvPercentage; - [DefaultValue(false)] - public bool PrioritizeIvOverCp; //lucky, incense and berries [DefaultValue(true)] public bool UseEggIncubators; @@ -692,7 +694,8 @@ public LogicSettings(GlobalSettings settings) public bool AutoUpdate => _settings.AutoUpdate; public bool TransferConfigAndAuthOnUpdate => _settings.TransferConfigAndAuthOnUpdate; public bool DisableHumanWalking => _settings.DisableHumanWalking; - public float KeepMinIvPercentage => _settings.KeepMinIvPercentage; + public float KeepMinIvPercentage => _settings.KeepMinIvPercentage; + public string KeepMinOperator => _settings.KeepMinOperator; public int KeepMinCp => _settings.KeepMinCp; public bool AutomaticallyLevelUpPokemon => _settings.AutomaticallyLevelUpPokemon; public int AmountOfTimesToUpgradeLoop => _settings.AmountOfTimesToUpgradeLoop; diff --git a/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs b/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs index 48110910d..7581c5d95 100644 --- a/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs @@ -26,8 +26,7 @@ public static async Task Execute(ISession session) var highestsPokemonCp = await session.Inventory.GetHighestsCp(session.LogicSettings.AmountOfPokemonToDisplayOnStart); - var highestsPokemonCpForUpgrade = await session.Inventory.GetHighestsCp(50); - var highestsPokemonIvForUpgrade = await session.Inventory.GetHighestsPerfect(50); + var pokemonPairedWithStatsCp = highestsPokemonCp.Select( pokemon => @@ -35,12 +34,7 @@ public static async Task Execute(ISession session) PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon), PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings))).ToList(); - var pokemonPairedWithStatsCpForUpgrade = - highestsPokemonCpForUpgrade.Select( - pokemon => - Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), - PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), - PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon))).ToList(); + var highestsPokemonPerfect = await session.Inventory.GetHighestsPerfect(session.LogicSettings.AmountOfPokemonToDisplayOnStart); @@ -51,12 +45,6 @@ public static async Task Execute(ISession session) PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon), PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings))).ToList(); - var pokemonPairedWithStatsIvForUpgrade = - highestsPokemonIvForUpgrade.Select( - pokemon => - Tuple.Create(pokemon, PokemonInfo.CalculateMaxCp(pokemon), - PokemonInfo.CalculatePokemonPerfection(pokemon), PokemonInfo.GetLevel(pokemon), - PokemonInfo.GetPokemonMove1(pokemon), PokemonInfo.GetPokemonMove2(pokemon))).ToList(); session.EventDispatcher.Send( new DisplayHighestsPokemonEvent @@ -74,31 +62,6 @@ public static async Task Execute(ISession session) PokemonList = pokemonPairedWithStatsIv }); - foreach (var pokemon in pokemonPairedWithStatsIvForUpgrade) - { - var dgdfs = pokemon.ToString(); - - var tokens = dgdfs.Split(new[] {"id"}, StringSplitOptions.None); - var splitone = tokens[1].Split('"'); - var iv = session.Inventory.GetPerfect(pokemon.Item1); - if (iv >= session.LogicSettings.UpgradePokemonIvMinimum) - { - PokemonId.Add(ulong.Parse(splitone[2])); - } - } - foreach (var t in pokemonPairedWithStatsCpForUpgrade) - { - var dgdfs = t.ToString(); - var tokens = dgdfs.Split(new[] {"id"}, StringSplitOptions.None); - var splitone = tokens[1].Split('"'); - var tokensSplit = tokens[1].Split(new[] {"cp"}, StringSplitOptions.None); - var tokenSplitAgain = tokensSplit[1].Split(' '); - var tokenSplitAgain2 = tokenSplitAgain[1].Split(','); - if (float.Parse(tokenSplitAgain2[0]) >= session.LogicSettings.UpgradePokemonCpMinimum) - { - PokemonIdcp.Add(ulong.Parse(splitone[2])); - } - } var allPokemonInBag = session.LogicSettings.PrioritizeIvOverCp ? await session.Inventory.GetHighestsPerfect(1000) : await session.Inventory.GetHighestsCp(1000); diff --git a/PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs b/PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs index 52ff3c3a3..2578804ba 100644 --- a/PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/TransferDuplicatePokemonTask.cs @@ -32,18 +32,31 @@ 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 >= - pokemonTransferFilter.KeepMinCp || - PokemonInfo.CalculatePokemonPerfection(duplicatePokemon) > - pokemonTransferFilter.KeepMinIvPercentage || - pokemonTransferFilter.Moves.Contains(duplicatePokemon.Move1) || - pokemonTransferFilter.Moves.Contains(duplicatePokemon.Move2)) + if (pokemonTransferFilter != null && session.LogicSettings.KeepMinOperator.ToLower().Equals("and")) { - continue; + if ((duplicatePokemon.Cp >= pokemonTransferFilter.KeepMinCp && + PokemonInfo.CalculatePokemonPerfection(duplicatePokemon) >= pokemonTransferFilter.KeepMinIvPercentage) || + pokemonTransferFilter.Moves.Contains(duplicatePokemon.Move1) || + pokemonTransferFilter.Moves.Contains(duplicatePokemon.Move2)) + { + continue; + } } - + else if(pokemonTransferFilter != null) + { + if (duplicatePokemon.Cp >= pokemonTransferFilter.KeepMinCp || + PokemonInfo.CalculatePokemonPerfection(duplicatePokemon) > + pokemonTransferFilter.KeepMinIvPercentage || + pokemonTransferFilter.Moves.Contains(duplicatePokemon.Move1) || + pokemonTransferFilter.Moves.Contains(duplicatePokemon.Move2)) + { + continue; + } + } + await session.Client.Inventory.TransferPokemon(duplicatePokemon.Id); await session.Inventory.DeletePokemonFromInvById(duplicatePokemon.Id);