Skip to content

Commit

Permalink
Upgrade Pokemon Classed as faveriot
Browse files Browse the repository at this point in the history
  • Loading branch information
cawk committed Aug 9, 2016
1 parent 97062a7 commit 5e115e8
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions PoGo.NecroBot.Logic/ILogicSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public interface ILogicSettings

int DelayBetweenPokemonCatch { get; }
bool AutomaticallyLevelUpPokemon { get; }
bool OnlyUpgradeFaveriots { get; }
bool UseLevelUpList { get; }
string LevelUpByCPorIv { get; }
float UpgradePokemonCpMinimum { get; }
Expand Down
7 changes: 7 additions & 0 deletions PoGo.NecroBot.Logic/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,13 @@ public async Task<IEnumerable<PokemonData>> GetPokemons()
inventory.InventoryDelta.InventoryItems.Select(i => i.InventoryItemData?.PokemonData)
.Where(p => p != null && p.PokemonId > 0);
}
public async Task<IEnumerable<PokemonData>> GetFaveriotPokemon()
{
var inventory = await GetPokemons();
return
inventory.Where(i => i.Favorite == 1);

}

public async Task<IEnumerable<PokemonSettings>> GetPokemonSettings()
{
Expand Down
3 changes: 3 additions & 0 deletions PoGo.NecroBot.Logic/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ public class GlobalSettings
//powerup
[DefaultValue(false)]
public bool AutomaticallyLevelUpPokemon;
[DefaultValue(true)]
public bool OnlyUpgradeFaveriots;

[DefaultValue((true))]
public bool UseLevelUpList;
Expand Down Expand Up @@ -1233,6 +1235,7 @@ public LogicSettings(GlobalSettings settings)
public int KeepMinLvl => _settings.KeepMinLvl;
public bool UseKeepMinLvl => _settings.UseKeepMinLvl;
public bool AutomaticallyLevelUpPokemon => _settings.AutomaticallyLevelUpPokemon;
public bool OnlyUpgradeFaveriots => _settings.OnlyUpgradeFaveriots;
public bool UseLevelUpList => _settings.UseLevelUpList;
public int AmountOfTimesToUpgradeLoop => _settings.AmountOfTimesToUpgradeLoop;
public string LevelUpByCPorIv => _settings.LevelUpByCPorIv;
Expand Down
21 changes: 16 additions & 5 deletions PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,24 @@ namespace PoGo.NecroBot.Logic.Tasks
internal class LevelUpPokemonTask
{
public static List<PokemonData> Upgrade = new List<PokemonData>();
private static IEnumerable<PokemonData> upgradablePokemon;

public static async Task Execute(ISession session, CancellationToken cancellationToken)
{
if (session.Inventory.GetStarDust() <= session.LogicSettings.GetMinStarDustForLevelUp)
return;

var upgradablePokemon = await session.Inventory.GetPokemonToUpgrade();
if (upgradablePokemon.Count == 0)


// if (session.Inventory.GetStarDust() <= session.LogicSettings.GetMinStarDustForLevelUp)
// return;
if (session.LogicSettings.OnlyUpgradeFaveriots)
{
upgradablePokemon = await session.Inventory.GetFaveriotPokemon();
}
else
{
upgradablePokemon = await session.Inventory.GetPokemonToUpgrade();
}

if (upgradablePokemon.Count() == 0)
return;

var myPokemonSettings = await session.Inventory.GetPokemonSettings();
Expand Down

1 comment on commit 5e115e8

@rahulrverma
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Favorite spelling is not correct

Please sign in to comment.