Skip to content

Commit

Permalink
Merge pull request #1522 from cawk/master
Browse files Browse the repository at this point in the history
Add minimum stardust for levelup
  • Loading branch information
NecronomiconCoding authored Jul 31, 2016
2 parents 04a52bf + e840dbc commit 3f9b1fb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions PoGo.NecroBot.Logic/ILogicSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,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 @@ -101,6 +101,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 @@ -589,6 +590,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

0 comments on commit 3f9b1fb

Please sign in to comment.