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 minimum stardust for levelup #1522

Merged
merged 2 commits into from Jul 31, 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.Logic/ILogicSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public interface ILogicSettings
int KeepMinDuplicatePokemon { get; }
bool PrioritizeIvOverCp { get; }
int AmountOfTimesToUpgradeLoop { get; }

int GetMinStarDustForLevelUp { get; }
int MaxTravelDistanceInMeters { get; }
bool UseGpxPathing { get; }
string GpxFile { get; }
Expand Down
10 changes: 9 additions & 1 deletion PoGo.NecroBot.Logic/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@ public async Task<PokemonData> GetHighestPokemonOfTypeByCp(PokemonData pokemon)
.OrderByDescending(x => x.Cp)
.FirstOrDefault();
}
public async Task<int> GetStarDust()
{
var StarDust =await _client.Player.GetPlayer();
var gdrfds = StarDust.PlayerData.Currencies;
var SplitStar = gdrfds[1].Amount;
return SplitStar;

}

public async Task<PokemonData> GetHighestPokemonOfTypeByIv(PokemonData pokemon)
{
Expand All @@ -201,7 +209,7 @@ public async Task<IEnumerable<PokemonData>> GetHighestsCp(int limit)
var pokemons = myPokemon.ToList();
return pokemons.OrderByDescending(x => x.Cp).ThenBy(n => n.StaminaMax).Take(limit);
}

public async Task<IEnumerable<PokemonData>> GetHighestsPerfect(int limit)
{
var myPokemon = await GetPokemons();
Expand Down
2 changes: 2 additions & 0 deletions PoGo.NecroBot.Logic/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public class GlobalSettings

public bool AutomaticallyLevelUpPokemon = false;
public int AmountOfTimesToUpgradeLoop = 5;
public int GetMinStarDustForLevelUp = 5000;

public bool AutoUpdate = true;
public double DefaultAltitude = 10;
Expand Down Expand Up @@ -584,6 +585,7 @@ public LogicSettings(GlobalSettings settings)
public bool AutomaticallyLevelUpPokemon => _settings.AutomaticallyLevelUpPokemon;
public int AmountOfTimesToUpgradeLoop => _settings.AmountOfTimesToUpgradeLoop;
public string LevelUpByCPorIv => _settings.LevelUpByCPorIv;
public int GetMinStarDustForLevelUp => _settings.GetMinStarDustForLevelUp;
public float UpgradePokemonIvMinimum => _settings.UpgradePokemonIvMinimum;
public float UpgradePokemonCpMinimum => _settings.UpgradePokemonCpMinimum;
public double WalkingSpeedInKilometerPerHour => _settings.WalkingSpeedInKilometerPerHour;
Expand Down
9 changes: 7 additions & 2 deletions PoGo.NecroBot.Logic/Tasks/LevelUpPokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
{
return;
}
if (await session.Inventory.GetStarDust() <= session.LogicSettings.GetMinStarDustForLevelUp)
{
return;
}
if (session.LogicSettings.LevelUpByCPorIv.ToLower().Contains("iv"))
{
for (int i = 0; i < session.LogicSettings.AmountOfTimesToUpgradeLoop; i++)
Expand All @@ -39,7 +43,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
}
else if (upgradeResult.Result.ToString().Contains("ErrorUpgradeNotAvailable"))
{
Logging.Logger.Write("Pokemon Is At Max Level For Your Level");
Logger.Write("Pokemon Is At Max Level For Your Level");
break;
}
else
Expand All @@ -53,6 +57,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
}
else if (session.LogicSettings.LevelUpByCPorIv.ToLower().Contains("cp"))
{

for (int i = 0; i < session.LogicSettings.AmountOfTimesToUpgradeLoop; i++)
{
var rand = new Random();
Expand All @@ -71,7 +76,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
}
else if (upgradeResult.Result.ToString().Contains("ErrorUpgradeNotAvailable"))
{
Logging.Logger.Write("Pokemon Is At Max Level For Your Level");
Logger.Write("Pokemon Is At Max Level For Your Level");
break;
}
else
Expand Down