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

Add PokeDex #1528

Merged
merged 1 commit into from Jul 31, 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: 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");
}
}
}