Skip to content

Commit

Permalink
issue #1966
Browse files Browse the repository at this point in the history
  • Loading branch information
Streppel committed Aug 2, 2016
1 parent fc90a96 commit 391b00f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
21 changes: 19 additions & 2 deletions PoGo.NecroBot.Logic/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public class GlobalSettings
public bool EvolveAllPokemonAboveIv;
[DefaultValue(true)]
public bool EvolveAllPokemonWithEnoughCandy;
[DefaultValue(0.90)]
[DefaultValue(90.0)]
public double EvolveKeptPokemonsAtStorageUsagePercentage;
[DefaultValue(false)]
public bool KeepPokemonsThatCanEvolve;
Expand All @@ -186,7 +186,7 @@ public class GlobalSettings
//recycle
[DefaultValue(true)]
public bool VerboseRecycling;
[DefaultValue(0.90)]
[DefaultValue(90.0)]
public double RecycleInventoryAtUsagePercentage;
//lucky, incense and berries
[DefaultValue(true)]
Expand Down Expand Up @@ -567,12 +567,29 @@ public static GlobalSettings Load(string path)

var firstRun = !File.Exists(configFile);

settings.migratePercentages();

settings.Save(configFile);
settings.Auth.Load(Path.Combine(profileConfigPath, "auth.json"));

return firstRun ? null : settings;
}

/// <summary>
/// Method for issue #1966
/// </summary>
private void migratePercentages()
{
if (EvolveKeptPokemonsAtStorageUsagePercentage <= 1.0)
{
EvolveKeptPokemonsAtStorageUsagePercentage *= 100.0f;
}
if (RecycleInventoryAtUsagePercentage <= 1.0)
{
RecycleInventoryAtUsagePercentage *= 100.0f;
}
}

public void Save(string fullPath)
{
var jsonSerializeSettings = new JsonSerializerSettings
Expand Down
4 changes: 2 additions & 2 deletions PoGo.NecroBot.Logic/Tasks/EvolvePokemonTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
{
var totalPokemon = await session.Inventory.GetPokemons();

var pokemonNeededInInventory = session.Profile.PlayerData.MaxPokemonStorage * session.LogicSettings.EvolveKeptPokemonsAtStorageUsagePercentage;
var pokemonNeededInInventory = session.Profile.PlayerData.MaxPokemonStorage * session.LogicSettings.EvolveKeptPokemonsAtStorageUsagePercentage/100.0f;
var needPokemonToStartEvolve = Math.Round(
Math.Max(0,
Math.Min(pokemonNeededInInventory, session.Profile.PlayerData.MaxPokemonStorage)));
Expand All @@ -48,7 +48,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
session.EventDispatcher.Send(new NoticeEvent()
{
Message = session.Translation.GetTranslation(TranslationString.WaitingForMorePokemonToEvolve,
pokemonToEvolve.Count, deltaCount, totalPokemon.Count(), needPokemonToStartEvolve, session.LogicSettings.EvolveKeptPokemonsAtStorageUsagePercentage)
pokemonToEvolve.Count, deltaCount, totalPokemon.Count(), needPokemonToStartEvolve, session.LogicSettings.EvolveKeptPokemonsAtStorageUsagePercentage/100.0f)
});

return;
Expand Down
4 changes: 2 additions & 2 deletions PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
cancellationToken.ThrowIfCancellationRequested();

var currentTotalItems = await session.Inventory.GetTotalItemCount();
if ((session.Profile.PlayerData.MaxItemStorage * session.LogicSettings.RecycleInventoryAtUsagePercentage) > currentTotalItems)
if ((session.Profile.PlayerData.MaxItemStorage * session.LogicSettings.RecycleInventoryAtUsagePercentage/100.0f) > currentTotalItems)
return;

if (!session.LogicSettings.VerboseRecycling)
Expand Down Expand Up @@ -52,7 +52,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio
}

currentTotalItems = await session.Inventory.GetTotalItemCount();
if ((session.Profile.PlayerData.MaxItemStorage * session.LogicSettings.RecycleInventoryAtUsagePercentage) > currentTotalItems)
if ((session.Profile.PlayerData.MaxItemStorage * session.LogicSettings.RecycleInventoryAtUsagePercentage/100.0f) > currentTotalItems)
{
await session.Inventory.RefreshCachedInventory();
return;
Expand Down

0 comments on commit 391b00f

Please sign in to comment.