From 18fd2afb5de9efc11209c6a1a9e471f27b6b8956 Mon Sep 17 00:00:00 2001 From: Ingwar Wirjawan Date: Thu, 18 Aug 2016 01:20:12 +0800 Subject: [PATCH 1/2] stop catching pokemon if we do not have pokeballs --- pokemongo_bot/cell_workers/catch_pokemon.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pokemongo_bot/cell_workers/catch_pokemon.py b/pokemongo_bot/cell_workers/catch_pokemon.py index b0500f6d1a..5ccd5d0005 100644 --- a/pokemongo_bot/cell_workers/catch_pokemon.py +++ b/pokemongo_bot/cell_workers/catch_pokemon.py @@ -2,6 +2,11 @@ from pokemongo_bot.base_task import BaseTask from pokemongo_bot.worker_result import WorkerResult from pokemongo_bot.cell_workers import CatchVisiblePokemon, CatchLuredPokemon +from pokemongo_bot import inventory + +ITEM_POKEBALL = 1 +ITEM_GREATBALL = 2 +ITEM_ULTRABALL = 3 class CatchPokemon(BaseTask): @@ -15,6 +20,12 @@ def initialize(self): self.catch_workers.append(CatchLuredPokemon(self.bot, self.config)) def work(self): + + if sum([inventory.items().get(ball_id).count for ball_id in + [ITEM_POKEBALL, ITEM_GREATBALL, ITEM_ULTRABALL]]) <= 0: + self.emit_event('no_pokeballs', formatted='No usable pokeballs found!') + return WorkerResult.ERROR + for cw in self.catch_workers: if cw.work() == WorkerResult.RUNNING: return WorkerResult.RUNNING From 4ca0b0967c73992d52f21223b8c7794f6a965d86 Mon Sep 17 00:00:00 2001 From: rawgni Date: Thu, 18 Aug 2016 02:29:46 +0700 Subject: [PATCH 2/2] uses global constant --- pokemongo_bot/cell_workers/catch_pokemon.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pokemongo_bot/cell_workers/catch_pokemon.py b/pokemongo_bot/cell_workers/catch_pokemon.py index 5ccd5d0005..81c35c8a04 100644 --- a/pokemongo_bot/cell_workers/catch_pokemon.py +++ b/pokemongo_bot/cell_workers/catch_pokemon.py @@ -2,12 +2,9 @@ from pokemongo_bot.base_task import BaseTask from pokemongo_bot.worker_result import WorkerResult from pokemongo_bot.cell_workers import CatchVisiblePokemon, CatchLuredPokemon +from pokemongo_bot.item_list import Item from pokemongo_bot import inventory -ITEM_POKEBALL = 1 -ITEM_GREATBALL = 2 -ITEM_ULTRABALL = 3 - class CatchPokemon(BaseTask): SUPPORTED_TASK_API_VERSION = 1 @@ -21,9 +18,8 @@ def initialize(self): def work(self): - if sum([inventory.items().get(ball_id).count for ball_id in - [ITEM_POKEBALL, ITEM_GREATBALL, ITEM_ULTRABALL]]) <= 0: - self.emit_event('no_pokeballs', formatted='No usable pokeballs found!') + if sum([inventory.items().get(ball.value).count for ball in + [Item.ITEM_POKE_BALL, Item.ITEM_GREAT_BALL, Item.ITEM_ULTRA_BALL]]) <= 0: return WorkerResult.ERROR for cw in self.catch_workers: