From 1dbf83ef243026db48cd2c81d33dcb4f9f753a04 Mon Sep 17 00:00:00 2001 From: 5andr0 Date: Thu, 28 Jul 2016 21:00:48 +0200 Subject: [PATCH] Improved bottleneck when run out of pokeballs Due to the sleep in here this function can delay the walk to a pokestop up to (pokemons around you) * 3 sec. Not sure if it's worth to implement the calls. A check for EventNoPokeballs after the EncounterPokemon with a loop break might be better even though it's after the sleep. --- PoGo.NecroBot.Logic/Tasks/CatchNearbyPokemonsTask.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/PoGo.NecroBot.Logic/Tasks/CatchNearbyPokemonsTask.cs b/PoGo.NecroBot.Logic/Tasks/CatchNearbyPokemonsTask.cs index d06bb9fb4..a4ded13cd 100644 --- a/PoGo.NecroBot.Logic/Tasks/CatchNearbyPokemonsTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/CatchNearbyPokemonsTask.cs @@ -22,6 +22,14 @@ public static async Task Execute(ISession session) var pokemons = await GetNearbyPokemons(session); foreach (var pokemon in pokemons) { + var pokeBallsCount = await session.Inventory.GetItemAmountByType(POGOProtos.Inventory.Item.ItemId.ItemPokeBall); + var greatBallsCount = await session.Inventory.GetItemAmountByType(POGOProtos.Inventory.Item.ItemId.ItemGreatBall); + var ultraBallsCount = await session.Inventory.GetItemAmountByType(POGOProtos.Inventory.Item.ItemId.ItemUltraBall); + var masterBallsCount = await session.Inventory.GetItemAmountByType(POGOProtos.Inventory.Item.ItemId.ItemMasterBall); + + if (pokeBallsCount + greatBallsCount + ultraBallsCount + masterBallsCount == 0) + return; + if (session.LogicSettings.UsePokemonToNotCatchFilter && session.LogicSettings.PokemonsNotToCatch.Contains(pokemon.PokemonId)) { @@ -78,4 +86,4 @@ private static async Task> GetNearbyPokemons(ISes return pokemons; } } -} \ No newline at end of file +}