Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable minimum number of evolvable pokemon for lucky egg usage #791

Merged
merged 2 commits into from
Jul 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions PoGo.NecroBot.CLI/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ public void Save(string fullPath)
public bool UseEggIncubators = true;
public bool UseGpxPathing = false;
public bool UseLuckyEggsWhileEvolving = false;
public int UseLuckyEggsMinPokemonAmount = 30;
public bool UsePokemonToNotCatchFilter = false;
public double WalkingSpeedInKilometerPerHour = 50;
public int AmountOfPokemonToDisplayOnStart = 10;
Expand Down Expand Up @@ -299,6 +300,7 @@ public LogicSettings(GlobalSettings settings)
public string GpxFile => _settings.GpxFile;
public bool UseGpxPathing => _settings.UseGpxPathing;
public bool UseLuckyEggsWhileEvolving => _settings.UseLuckyEggsWhileEvolving;
public int UseLuckyEggsMinPokemonAmount => _settings.UseLuckyEggsMinPokemonAmount;
public bool EvolveAllPokemonAboveIv => _settings.EvolveAllPokemonAboveIv;
public float EvolveAboveIvValue => _settings.EvolveAboveIvValue;
public bool RenameAboveIv => _settings.RenameAboveIv;
Expand Down
1 change: 1 addition & 0 deletions PoGo.NecroBot.Logic/ILogicSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public interface ILogicSettings
bool UseGpxPathing { get; }
string GpxFile { get; }
bool UseLuckyEggsWhileEvolving { get; }
int UseLuckyEggsMinPokemonAmount { get; }
bool EvolveAllPokemonAboveIv { get; }
float EvolveAboveIvValue { get; }
bool RenameAboveIv { get; }
Expand Down
15 changes: 11 additions & 4 deletions PoGo.NecroBot.Logic/Tasks/EvolvePokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@ public class EvolvePokemonTask
private static DateTime _lastLuckyEggTime;
public static async Task Execute(Context ctx, StateMachine machine)
{
var pokemonToEvolveTask = await ctx.Inventory.GetPokemonToEvolve(ctx.LogicSettings.PokemonsToEvolve);
var pokemonToEvolve = pokemonToEvolveTask;
if (ctx.LogicSettings.UseLuckyEggsWhileEvolving)
{
await UseLuckyEgg(ctx.Client, ctx.Inventory, machine);
if (pokemonToEvolve.Count() >= ctx.LogicSettings.UseLuckyEggsMinPokemonAmount)
{
await UseLuckyEgg(ctx.Client, ctx.Inventory, machine);
}
else
{
// Wait until we have enough pokemon
return;
}
}

var pokemonToEvolveTask = await ctx.Inventory.GetPokemonToEvolve(ctx.LogicSettings.PokemonsToEvolve);

var pokemonToEvolve = pokemonToEvolveTask;
foreach (var pokemon in pokemonToEvolve)
{
var evolveResponse = await ctx.Client.Inventory.EvolvePokemon(pokemon.Id);
Expand Down