Skip to content

Commit

Permalink
Merge pull request #1514 from bornsupercharged/master
Browse files Browse the repository at this point in the history
Fixed frequent recycling to be inventory based
  • Loading branch information
NecronomiconCoding authored Jul 31, 2016
2 parents 6712ce3 + 8120826 commit 4d69da1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
14 changes: 13 additions & 1 deletion PoGo.NecroBot.CLI/WebSocketInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
{


}
}

Expand Down
1 change: 1 addition & 0 deletions PoGo.NecroBot.Logic/ILogicSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public interface ILogicSettings
int TotalAmountOfPotionsToKeep { get; }
int TotalAmountOfRevivesToKeep { get; }

double RecycleInventoryAtUsagePercentage { get; }
ICollection<KeyValuePair<ItemId, int>> ItemRecycleFilter { get; }

ICollection<PokemonId> PokemonsToEvolve { get; }
Expand Down
3 changes: 2 additions & 1 deletion PoGo.NecroBot.Logic/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public class GlobalSettings

public string GpxFile = "GPXPath.GPX";


public double RecycleInventoryAtUsagePercentage = 0.90;
public List<KeyValuePair<ItemId, int>> ItemRecycleFilter = new List<KeyValuePair<ItemId, int>>
{
new KeyValuePair<ItemId, int>(ItemId.ItemUnknown, 0),
Expand Down Expand Up @@ -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<KeyValuePair<ItemId, int>> ItemRecycleFilter => _settings.ItemRecycleFilter;
public ICollection<PokemonId> PokemonsToEvolve => _settings.PokemonsToEvolve;
public ICollection<PokemonId> PokemonsNotToTransfer => _settings.PokemonsNotToTransfer;
Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/Tasks/RecycleItemsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4d69da1

Please sign in to comment.