diff --git a/PoGo.NecroBot.CLI/WebSocketInterface.cs b/PoGo.NecroBot.CLI/WebSocketInterface.cs index fecfd1e6c..095943881 100644 --- a/PoGo.NecroBot.CLI/WebSocketInterface.cs +++ b/PoGo.NecroBot.CLI/WebSocketInterface.cs @@ -83,7 +83,7 @@ private void HandleEvent(ProfileEvent evt) private async void HandleMessage(WebSocketSession session, string message) { - switch (message) + switch(message) { case "PokemonList": await PokemonListTask.Execute(_session); @@ -106,6 +106,18 @@ private async void HandleMessage(WebSocketSession session, string message) { + } + + // Setup to only send data back to the session that requested it. + try + { + dynamic decodedMessage = JObject.Parse(message); + await _websocketHandler?.Handle(_session, session, decodedMessage); + } + catch (JsonException ex) + { + + } } diff --git a/PoGo.NecroBot.Logic/ILogicSettings.cs b/PoGo.NecroBot.Logic/ILogicSettings.cs index 8c7f69e83..b40b05d08 100644 --- a/PoGo.NecroBot.Logic/ILogicSettings.cs +++ b/PoGo.NecroBot.Logic/ILogicSettings.cs @@ -120,6 +120,7 @@ public interface ILogicSettings int TotalAmountOfPotionsToKeep { get; } int TotalAmountOfRevivesToKeep { get; } + double RecycleInventoryAtUsagePercentage { get; } ICollection> ItemRecycleFilter { get; } ICollection PokemonsToEvolve { get; } diff --git a/PoGo.NecroBot.Logic/Settings.cs b/PoGo.NecroBot.Logic/Settings.cs index 86f8c8356..4773f4e2b 100644 --- a/PoGo.NecroBot.Logic/Settings.cs +++ b/PoGo.NecroBot.Logic/Settings.cs @@ -117,7 +117,7 @@ public class GlobalSettings public string GpxFile = "GPXPath.GPX"; - + public double RecycleInventoryAtUsagePercentage = 0.90; public List> ItemRecycleFilter = new List> { new KeyValuePair(ItemId.ItemUnknown, 0), @@ -620,6 +620,7 @@ public LogicSettings(GlobalSettings settings) public int AmountOfPokemonToDisplayOnStart => _settings.AmountOfPokemonToDisplayOnStart; public bool DumpPokemonStats => _settings.DumpPokemonStats; public string TranslationLanguageCode => _settings.TranslationLanguageCode; + public double RecycleInventoryAtUsagePercentage => _settings.RecycleInventoryAtUsagePercentage; public ICollection> ItemRecycleFilter => _settings.ItemRecycleFilter; public ICollection PokemonsToEvolve => _settings.PokemonsToEvolve; public ICollection PokemonsNotToTransfer => _settings.PokemonsNotToTransfer; diff --git a/PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs b/PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs index 09948aada..e7115aa96 100644 --- a/PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs @@ -18,7 +18,7 @@ public static async Task Execute(ISession session, CancellationToken cancellatio cancellationToken.ThrowIfCancellationRequested(); var currentTotalItems = await session.Inventory.GetTotalItemCount(); - if ((session.Profile.PlayerData.MaxItemStorage*.95) > currentTotalItems) + if ((session.Profile.PlayerData.MaxItemStorage * session.LogicSettings.RecycleInventoryAtUsagePercentage) > currentTotalItems) return; var items = await session.Inventory.GetItemsToRecycle(session);