From e4c54dc593b7202ac95ebd70cfc672e88eb878ee Mon Sep 17 00:00:00 2001
From: pmquan <pmquan@gmail.com>
Date: Tue, 9 Aug 2016 00:25:42 -0700
Subject: [PATCH] MoveToMap: Add minimum balls to run (#3166)

---
 configs/config.json.map.example                   | 1 +
 pokemongo_bot/cell_workers/move_to_map_pokemon.py | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/configs/config.json.map.example b/configs/config.json.map.example
index 1079c999f9..43196196f5 100644
--- a/configs/config.json.map.example
+++ b/configs/config.json.map.example
@@ -58,6 +58,7 @@
           "address": "http://localhost:5000",
           "max_distance": 500,
           "min_time": 60,
+          "min_ball": 50,
           "prioritize_vips": true,
           "snipe": false,
           "update_map": true,
diff --git a/pokemongo_bot/cell_workers/move_to_map_pokemon.py b/pokemongo_bot/cell_workers/move_to_map_pokemon.py
index 9ab6bbb7a2..c97b240196 100644
--- a/pokemongo_bot/cell_workers/move_to_map_pokemon.py
+++ b/pokemongo_bot/cell_workers/move_to_map_pokemon.py
@@ -82,6 +82,7 @@ def initialize(self):
         self.pokemon_data = self.bot.pokemon_list
         self.unit = self.bot.config.distance_unit
         self.caught = []
+        self.min_ball = self.config.get('min_ball', 1)
 
         data_file = 'data/map-caught-{}.json'.format(self.bot.config.username)
         if os.path.isfile(data_file):
@@ -250,7 +251,7 @@ def work(self):
         pokemon = pokemon_list[0]
 
         # if we only have ultraballs and the target is not a vip don't snipe/walk
-        if (pokeballs + superballs) < 1 and not pokemon['is_vip']:
+        if (pokeballs + superballs) < self.min_ball and not pokemon['is_vip']:
             return WorkerResult.SUCCESS
 
         if self.config['snipe']: