From 391b00f3c8a18f3eee3fcc4c4272ed64efc16161 Mon Sep 17 00:00:00 2001 From: Streppel Date: Tue, 2 Aug 2016 07:56:53 +0200 Subject: [PATCH] issue #1966 --- PoGo.NecroBot.Logic/Settings.cs | 21 +++++++++++++++++-- .../Tasks/EvolvePokemonTask.cs | 4 ++-- PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs | 4 ++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/PoGo.NecroBot.Logic/Settings.cs b/PoGo.NecroBot.Logic/Settings.cs index f6460b9d8..a80e2b423 100644 --- a/PoGo.NecroBot.Logic/Settings.cs +++ b/PoGo.NecroBot.Logic/Settings.cs @@ -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; @@ -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)] @@ -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; } + /// + /// Method for issue #1966 + /// + 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 diff --git a/PoGo.NecroBot.Logic/Tasks/EvolvePokemonTask.cs b/PoGo.NecroBot.Logic/Tasks/EvolvePokemonTask.cs index 39cb21ec7..09900a30f 100644 --- a/PoGo.NecroBot.Logic/Tasks/EvolvePokemonTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/EvolvePokemonTask.cs @@ -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))); @@ -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; diff --git a/PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs b/PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs index 5e9b55cc2..f4f0c9713 100644 --- a/PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs @@ -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) @@ -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;