Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up PokeDex to print out correct findings. #1646

Merged
merged 2 commits into from
Aug 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions PoGo.NecroBot.Logic/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,11 @@ public async Task<UseIncenseResponse> UseIncenseConstantly()
public async Task<List<InventoryItem>> GetPokeDexItems()
{
List<InventoryItem> PokeDex = new List<InventoryItem>();
var hfgds = await _client.Inventory.GetInventory();
for (int i = 0; i < hfgds.InventoryDelta.InventoryItems.Count; i++)
{
if (hfgds.InventoryDelta.InventoryItems[i].ToString().ToLower().Contains("pokedex") && hfgds.InventoryDelta.InventoryItems[i].ToString().ToLower().Contains("timesencountered"))
{
PokeDex.Add(hfgds.InventoryDelta.InventoryItems[i]);
}
}
return PokeDex;
var inventory = await _client.Inventory.GetInventory();

return (from items in inventory.InventoryDelta.InventoryItems
where items.InventoryItemData?.PokedexEntry != null
select items).ToList();
}

public async Task<List<Candy>> GetPokemonFamilies()
Expand Down
15 changes: 5 additions & 10 deletions PoGo.NecroBot.Logic/Tasks/GetPokeDexCount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ class GetPokeDexCount
{
public static async Task Execute(ISession session, CancellationToken cancellationToken)
{
int timesCaptured = 0;
var PokeDex = await session.Inventory.GetPokeDexItems();
for (int i = 0; i < PokeDex.Count; i++)
{
var CaughtPokemon = PokeDex[i].ToString().Split(new[] { "timesCaptured" }, StringSplitOptions.None);
var split = CaughtPokemon[1].Split(' ');
int Times = int.Parse(split[1]);
if (Times > 0)
timesCaptured++;
}
Logger.Write(session.Translation.GetTranslation(TranslationString.AmountPkmSeenCaught, PokeDex.Count, timesCaptured));
var _totalUniqueEncounters = PokeDex.Select(i => new { Pokemon = i.InventoryItemData.PokedexEntry.PokemonId, Captures = i.InventoryItemData.PokedexEntry.TimesCaptured });
var _totalCaptures = _totalUniqueEncounters.Count(i => i.Captures > 0);
var _totalData = PokeDex.Count();

Logger.Write(session.Translation.GetTranslation(TranslationString.AmountPkmSeenCaught, _totalData, _totalCaptures));
}
}
}