diff --git a/PoGo.PokeMobBot.Logic/ILogicSettings.cs b/PoGo.PokeMobBot.Logic/ILogicSettings.cs index 7ee8e4d..e06b38c 100644 --- a/PoGo.PokeMobBot.Logic/ILogicSettings.cs +++ b/PoGo.PokeMobBot.Logic/ILogicSettings.cs @@ -103,7 +103,9 @@ public interface ILogicSettings //transfer bool TransferDuplicatePokemon { get; } + bool TransferLowStatPokemon { get; } bool PrioritizeIvOverCp { get; } + bool PrioritizeIvAndCp { get; } int KeepMinCp { get; } float KeepMinIvPercentage { get; } int KeepMinDuplicatePokemon { get; } diff --git a/PoGo.PokeMobBot.Logic/PoGo.PokeMobBot.Logic.csproj b/PoGo.PokeMobBot.Logic/PoGo.PokeMobBot.Logic.csproj index 5efa695..bb1cfe3 100644 --- a/PoGo.PokeMobBot.Logic/PoGo.PokeMobBot.Logic.csproj +++ b/PoGo.PokeMobBot.Logic/PoGo.PokeMobBot.Logic.csproj @@ -132,6 +132,7 @@ + diff --git a/PoGo.PokeMobBot.Logic/Settings.cs b/PoGo.PokeMobBot.Logic/Settings.cs index 1a930a5..03d7b5d 100644 --- a/PoGo.PokeMobBot.Logic/Settings.cs +++ b/PoGo.PokeMobBot.Logic/Settings.cs @@ -151,7 +151,9 @@ public class GlobalSettings //transfer public bool TransferDuplicatePokemon = true; + public bool TransferLowStatPokemon = false; public bool PrioritizeIvOverCp = true; + public bool PrioritizeIvAndCp = false; public int KeepMinCp = 1250; public float KeepMinIvPercentage = 95; public int KeepMinDuplicatePokemon = 1; @@ -646,6 +648,7 @@ public LogicSettings(GlobalSettings settings) public bool EvolveAllPokemonWithEnoughCandy => _settings.EvolveAllPokemonWithEnoughCandy; public bool KeepPokemonsThatCanEvolve => _settings.KeepPokemonsThatCanEvolve; public bool TransferDuplicatePokemon => _settings.TransferDuplicatePokemon; + public bool TransferLowStatPokemon => _settings.TransferLowStatPokemon; public bool UseEggIncubators => _settings.UseEggIncubators; public int UseGreatBallAboveIv => _settings.UseGreatBallAboveIv; public int UseUltraBallAboveIv => _settings.UseUltraBallAboveIv; @@ -657,6 +660,7 @@ public LogicSettings(GlobalSettings settings) public bool UsePokemonToNotCatchFilter => _settings.UsePokemonToNotCatchFilter; public int KeepMinDuplicatePokemon => _settings.KeepMinDuplicatePokemon; public bool PrioritizeIvOverCp => _settings.PrioritizeIvOverCp; + public bool PrioritizeIvAndCp => _settings.PrioritizeIvAndCp; public int MaxTravelDistanceInMeters => _settings.MaxTravelDistanceInMeters; public string GpxFile => _settings.GpxFile; public bool UseGpxPathing => _settings.UseGpxPathing; diff --git a/PoGo.PokeMobBot.Logic/State/FarmState.cs b/PoGo.PokeMobBot.Logic/State/FarmState.cs index 2cefe4d..8f4c02b 100644 --- a/PoGo.PokeMobBot.Logic/State/FarmState.cs +++ b/PoGo.PokeMobBot.Logic/State/FarmState.cs @@ -28,6 +28,10 @@ public async Task Execute(ISession session, CancellationToken cancellati { await TransferDuplicatePokemonTask.Execute(session, cancellationToken); } + if (session.LogicSettings.TransferLowStatPokemon) + { + await TransferLowStatPokemonTask.Execute(session, cancellationToken); + } if (session.LogicSettings.AutomaticallyLevelUpPokemon) { await LevelUpPokemonTask.Execute(session, cancellationToken); diff --git a/PoGo.PokeMobBot.Logic/Tasks/CatchIncensePokemonsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/CatchIncensePokemonsTask.cs index 9f892f2..667e185 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/CatchIncensePokemonsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/CatchIncensePokemonsTask.cs @@ -77,6 +77,14 @@ public static async Task Execute(ISession session, CancellationToken cancellatio }); await TransferDuplicatePokemonTask.Execute(session, cancellationToken); } + if (session.LogicSettings.TransferLowStatPokemon) + { + session.EventDispatcher.Send(new WarnEvent + { + Message = session.Translation.GetTranslation(TranslationString.InvFullTransferring) + }); + await TransferLowStatPokemonTask.Execute(session, cancellationToken); + } else session.EventDispatcher.Send(new WarnEvent { diff --git a/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs index 40ab8b1..3b2b668 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/CatchLurePokemonsTask.cs @@ -58,6 +58,14 @@ public static async Task Execute(ISession session, FortData currentFortData, Can }); await TransferDuplicatePokemonTask.Execute(session, cancellationToken); } + if (session.LogicSettings.TransferLowStatPokemon) + { + session.EventDispatcher.Send(new WarnEvent + { + Message = session.Translation.GetTranslation(TranslationString.InvFullTransferring) + }); + await TransferLowStatPokemonTask.Execute(session, cancellationToken); + } else session.EventDispatcher.Send(new WarnEvent { diff --git a/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs index b57064a..dbb3782 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/CatchNearbyPokemonsTask.cs @@ -80,6 +80,14 @@ public static async Task Execute(ISession session, CancellationToken cancellatio }); await TransferDuplicatePokemonTask.Execute(session, cancellationToken); } + if (session.LogicSettings.TransferLowStatPokemon) + { + session.EventDispatcher.Send(new WarnEvent + { + Message = session.Translation.GetTranslation(TranslationString.InvFullTransferring) + }); + await TransferLowStatPokemonTask.Execute(session, cancellationToken); + } else session.EventDispatcher.Send(new WarnEvent { diff --git a/PoGo.PokeMobBot.Logic/Tasks/Farm.cs b/PoGo.PokeMobBot.Logic/Tasks/Farm.cs index 7c1f41a..eff90c0 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/Farm.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/Farm.cs @@ -35,6 +35,10 @@ public void Run(CancellationToken cancellationToken) { TransferDuplicatePokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken); } + if (_session.LogicSettings.TransferLowStatPokemon) + { + TransferLowStatPokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken); + } if (_session.LogicSettings.RenamePokemon) { diff --git a/PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsGPXTask.cs b/PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsGPXTask.cs index 651a2e1..436c0b0 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsGPXTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsGPXTask.cs @@ -129,6 +129,10 @@ public static async Task Execute(ISession session, CancellationToken cancellatio { await TransferDuplicatePokemonTask.Execute(session, cancellationToken); } + if (session.LogicSettings.TransferLowStatPokemon) + { + await TransferLowStatPokemonTask.Execute(session, cancellationToken); + } if (session.LogicSettings.RenamePokemon) { diff --git a/PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsTask.cs index 86860ae..3d5c6ed 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/FarmPokestopsTask.cs @@ -412,6 +412,10 @@ await session.Navigation.HumanLikeWalking(new GeoCoordinate(pokeStop.Latitude, p { await TransferDuplicatePokemonTask.Execute(session, cancellationToken); } + if (session.LogicSettings.TransferLowStatPokemon) + { + await TransferLowStatPokemonTask.Execute(session, cancellationToken); + } if (session.LogicSettings.RenamePokemon) { await RenamePokemonTask.Execute(session, cancellationToken); diff --git a/PoGo.PokeMobBot.Logic/Tasks/TransferLowStatPokemon.cs b/PoGo.PokeMobBot.Logic/Tasks/TransferLowStatPokemon.cs new file mode 100644 index 0000000..636d790 --- /dev/null +++ b/PoGo.PokeMobBot.Logic/Tasks/TransferLowStatPokemon.cs @@ -0,0 +1,93 @@ +#region using directives + +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using PoGo.PokeMobBot.Logic.Event; +using PoGo.PokeMobBot.Logic.PoGoUtils; +using PoGo.PokeMobBot.Logic.State; +using PoGo.PokeMobBot.Logic.Utils; + +#endregion + +namespace PoGo.PokeMobBot.Logic.Tasks +{ + public class TransferLowStatPokemonTask + { + public static async Task Execute(ISession session, CancellationToken cancellationToken) + { + cancellationToken.ThrowIfCancellationRequested(); + + // Refresh inventory so that the player stats are fresh + await session.Inventory.RefreshCachedInventory(); + + var pokemons = await session.Inventory.GetPokemons(); + + var pokemonList = pokemons.Where(p => !session.LogicSettings.PokemonsNotToTransfer.Contains(p.PokemonId)).ToList(); //filter out the do not transfers + + if (session.LogicSettings.KeepPokemonsThatCanEvolve) + { + pokemonList = pokemonList.Where(p => !session.LogicSettings.PokemonsToEvolve.Contains(p.PokemonId)).ToList(); //filter out the evolve list if evolve is true + } + + var pokemonSettings = await session.Inventory.GetPokemonSettings(); + var pokemonFamilies = await session.Inventory.GetPokemonFamilies(); + + foreach (var pokemon in pokemonList) + { + cancellationToken.ThrowIfCancellationRequested(); + + if (pokemon.Favorite == 1) + continue; + + if (session.LogicSettings.PrioritizeIvAndCp) //combined mode - pokemon has to match minimum CP and IV requirements to be kept + { + if (pokemon.Cp >= session.LogicSettings.KeepMinCp && (PokemonInfo.CalculatePokemonPerfection(pokemon) >= session.LogicSettings.KeepMinIvPercentage)) + { + continue; + } + } + else //normal filtering + { + if (pokemon.Cp >= session.LogicSettings.KeepMinCp) //dont toss if above minimum CP + { + continue; + } + if (session.LogicSettings.PrioritizeIvOverCp) + { + if (PokemonInfo.CalculatePokemonPerfection(pokemon) >= session.LogicSettings.KeepMinIvPercentage) //dont toss if its over min IV + { + continue; + } + } + } + + await session.Client.Inventory.TransferPokemon(pokemon.Id); + await session.Inventory.DeletePokemonFromInvById(pokemon.Id); + + var bestPokemonOfType = (session.LogicSettings.PrioritizeIvOverCp + ? await session.Inventory.GetHighestPokemonOfTypeByIv(pokemon) + : await session.Inventory.GetHighestPokemonOfTypeByCp(pokemon)) ?? pokemon; + + var setting = pokemonSettings.Single(q => q.PokemonId == pokemon.PokemonId); + var family = pokemonFamilies.First(q => q.FamilyId == setting.FamilyId); + + family.Candy_++; + + session.EventDispatcher.Send(new TransferPokemonEvent + { + Id = pokemon.PokemonId, + Perfection = PokemonInfo.CalculatePokemonPerfection(pokemon), + Cp = pokemon.Cp, + BestCp = bestPokemonOfType.Cp, + BestPerfection = PokemonInfo.CalculatePokemonPerfection(bestPokemonOfType), + FamilyCandies = family.Candy_ + }); + if (session.LogicSettings.Teleport) + await Task.Delay(session.LogicSettings.DelayTransferPokemon); + else + await DelayingUtils.Delay(session.LogicSettings.DelayBetweenPlayerActions, 0); + } + } + } +} \ No newline at end of file diff --git a/PoGo.PokeMobBot.Logic/Tasks/UseNearbyPokestopsTask.cs b/PoGo.PokeMobBot.Logic/Tasks/UseNearbyPokestopsTask.cs index 256764e..67b6627 100644 --- a/PoGo.PokeMobBot.Logic/Tasks/UseNearbyPokestopsTask.cs +++ b/PoGo.PokeMobBot.Logic/Tasks/UseNearbyPokestopsTask.cs @@ -64,6 +64,10 @@ public static async Task Execute(ISession session, CancellationToken cancellatio { await TransferDuplicatePokemonTask.Execute(session, cancellationToken); } + if (session.LogicSettings.TransferLowStatPokemon) + { + await TransferLowStatPokemonTask.Execute(session, cancellationToken); + } } }