Skip to content

Commit

Permalink
Merge pull request NecronomiconCoding#1646 from dddbliss/feature/pokedex
Browse files Browse the repository at this point in the history
Clean up PokeDex to print out correct findings.
  • Loading branch information
NecronomiconCoding authored Aug 1, 2016
2 parents 4490eb9 + 1029f2a commit 68c5f5a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
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));
}
}
}

0 comments on commit 68c5f5a

Please sign in to comment.