Skip to content

Commit

Permalink
Merge pull request #1528 from cawk/master
Browse files Browse the repository at this point in the history
Add PokeDex
  • Loading branch information
NecronomiconCoding authored Jul 31, 2016
2 parents dd3db8c + fdd488b commit ae82a02
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 3 deletions.
14 changes: 12 additions & 2 deletions PoGo.NecroBot.Logic/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,21 @@ private List<ItemData> GetPokeballsToRecycle(ISession session, IReadOnlyList<Ite
return TakeAmountOfItems(allPokeballs, amountOfPokeballsToKeep).ToList();
}

public async Task<int> GetPokedexCount()
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("timescaptured"))
{
PokeDex.Add(hfgds.InventoryDelta.InventoryItems[i]);
}


}
return PokeDex;

return hfgds.InventoryDelta.InventoryItems.Count(t => t.ToString().ToLower().Contains("pokedex"));
}

public async Task<List<Candy>> GetPokemonFamilies()
Expand Down
1 change: 1 addition & 0 deletions PoGo.NecroBot.Logic/PoGo.NecroBot.Logic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<Compile Include="Service\BotService.cs" />
<Compile Include="Tasks\EggsListTask.cs" />
<Compile Include="Tasks\FavoritePokemonTask.cs" />
<Compile Include="Tasks\GetPokeDexCount.cs" />
<Compile Include="Tasks\InventoryListTask.cs" />
<Compile Include="Tasks\LevelUpPokemonTask.cs" />
<Compile Include="Tasks\PokemonListTask.cs" />
Expand Down
2 changes: 1 addition & 1 deletion PoGo.NecroBot.Logic/State/FarmState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task<IState> Execute(ISession session, CancellationToken cancellati
{
await LevelUpPokemonTask.Execute(session, cancellationToken);
}

await GetPokeDexCount.Execute(session, cancellationToken);
if (session.LogicSettings.RenamePokemon)
{
await RenamePokemonTask.Execute(session, cancellationToken);
Expand Down
1 change: 1 addition & 0 deletions PoGo.NecroBot.Logic/Tasks/Farm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public void Run(CancellationToken cancellationToken)
{
LevelUpPokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
}
GetPokeDexCount.Execute(_session, cancellationToken).Wait(cancellationToken);
if (_session.LogicSettings.TransferDuplicatePokemon)
{
TransferDuplicatePokemonTask.Execute(_session, cancellationToken).Wait(cancellationToken);
Expand Down
1 change: 1 addition & 0 deletions PoGo.NecroBot.Logic/Tasks/FarmPokestopsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ await session.Navigation.Move(new GeoCoordinate(pokeStop.Latitude, pokeStop.Long
{
await EvolvePokemonTask.Execute(session, cancellationToken);
}
await GetPokeDexCount.Execute(session, cancellationToken);

if (session.LogicSettings.AutomaticallyLevelUpPokemon)
{
Expand Down
38 changes: 38 additions & 0 deletions PoGo.NecroBot.Logic/Tasks/GetPokeDexCount.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using PoGo.NecroBot.Logic.State;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using PoGo.NecroBot.Logic.Logging;

namespace PoGo.NecroBot.Logic.Tasks
{
class GetPokeDexCount
{


public static async Task Execute(ISession session, CancellationToken cancellationToken)
{
int Amount = 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)
{


}
else
{
Amount++;
}
}
Logger.Write("Amount Of Pokemon Seen:" + PokeDex.Count + ":151" + ", Amount Of Pokemon Caught:" + Amount + ":151");
}
}
}

0 comments on commit ae82a02

Please sign in to comment.