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

Deprecate action_wait_min/max in favour of task specific options #4048

Merged
merged 5 commits into from
Aug 17, 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
8 changes: 6 additions & 2 deletions configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
},
{
"type": "TransferPokemon"
"config": {
"transfer_wait_min": 1,
"transfer_wait_max": 4
}
},
{
"type": "NicknamePokemon",
Expand Down Expand Up @@ -77,6 +81,8 @@
"Revive": { "keep" : 30 },
"Razz Berry": { "keep" : 100 }
}
"recycle_wait_min": 1,
"recycle_wait_max": 4
}
},
{
Expand Down Expand Up @@ -111,8 +117,6 @@
},
"walk_max": 4.16,
"walk_min": 2.16,
"action_wait_min": 1,
"action_wait_max": 4,
"debug": false,
"test": false,
"health_record": true,
Expand Down
4 changes: 4 additions & 0 deletions configs/config.json.optimizer.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
"// at false, you will still get the log information of what the optimizer": {},
"// would have transfered if the parameter was true": {},
"transfer": true,
"// 'transfer_wait_min' and 'transfer_wait_max' are the minimum and maximum": {},
"// "time to wait when transferring a pokemon": {},
"transfer_wait_min": 1,
"transfer_wait_max": 4,
"// the 'evolve' parameter activate or deactivate the evolution of pokemons": {},
"// at false, no pokemon is going to be evolved, ever": {},
"// at false, you will still get the log information of what the": {},
Expand Down
2 changes: 0 additions & 2 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,6 @@ def _json_loader(filename):
config.encrypt_location = load.get('encrypt_location','')
config.catch = load.get('catch', {})
config.release = load.get('release', {})
config.action_wait_max = load.get('action_wait_max', 4)
config.action_wait_min = load.get('action_wait_min', 1)
config.plugins = load.get('plugins', [])
config.raw_tasks = load.get('tasks', [])
config.min_ultraball_to_keep = load.get('min_ultraball_to_keep', None)
Expand Down
5 changes: 4 additions & 1 deletion pokemongo_bot/cell_workers/pokemon_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def initialize(self):
{"top": 1, "evolve": True, "sort": ["ncp"]},
{"top": 1, "evolve": False, "sort": ["cp"]}])

self.transfer_wait_min = self.config.get('transfer_wait_min', 1)
self.transfer_wait_max = self.config.get('transfer_wait_max', 4)

def get_pokemon_slot_left(self):
pokemon_count = len(inventory.pokemons()._data)

Expand Down Expand Up @@ -256,7 +259,7 @@ def transfer_pokemon(self, pokemon):
inventory.candies().get(pokemon.pokemon_id).add(candy)
inventory.pokemons().remove(pokemon.id)

action_delay(self.bot.config.action_wait_min, self.bot.config.action_wait_max)
action_delay(self.transfer_wait_min, self.transfer_wait_max)

return True

Expand Down
6 changes: 4 additions & 2 deletions pokemongo_bot/cell_workers/recycle_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def initialize(self):
self.max_potions_keep = self.config.get('max_potions_keep', None)
self.max_berries_keep = self.config.get('max_berries_keep', None)
self.max_revives_keep = self.config.get('max_revives_keep', None)
self.recycle_wait_min = self.config.get('recycle_wait_min', 1)
self.recycle_wait_max = self.config.get('recycle_wait_max', 4)
self._validate_item_filter()

def _validate_item_filter(self):
Expand Down Expand Up @@ -107,7 +109,7 @@ def work(self):

if self.item_should_be_recycled(item_in_inventory):
# Make the bot appears more human
action_delay(self.bot.config.action_wait_min, self.bot.config.action_wait_max)
action_delay(self.recycle_wait_min, self.recycle_wait_max)
# If at any recycling process call we got an error, we consider that the result of this task is error too.
if ItemRecycler(self.bot, item_in_inventory, self.get_amount_to_recycle(item_in_inventory)).work() == WorkerResult.ERROR:
worker_result = WorkerResult.ERROR
Expand All @@ -129,7 +131,7 @@ def recycle_excess_category_max(self, category_max, category_items_list):
category_count = category_count + i[1]
items_to_recycle = self.get_category_items_to_recycle(category_inventory, category_count, category_max)
for item in items_to_recycle:
action_delay(self.bot.config.action_wait_min, self.bot.config.action_wait_max)
action_delay(self.recycle_wait_min, self.recycle_wait_max)
if ItemRecycler(self.bot, inventory.items().get(item[0]), item[1]).work() == WorkerResult.ERROR:
worker_result = WorkerResult.ERROR
return worker_result
Expand Down
6 changes: 5 additions & 1 deletion pokemongo_bot/cell_workers/transfer_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
class TransferPokemon(BaseTask):
SUPPORTED_TASK_API_VERSION = 1

def initialize(self):
self.transfer_wait_min = self.config.get('transfer_wait_min', 1)
self.transfer_wait_max = self.config.get('transfer_wait_max', 4)

def work(self):
pokemon_groups = self._release_pokemon_get_groups()
for pokemon_id, group in pokemon_groups.iteritems():
Expand Down Expand Up @@ -164,7 +168,7 @@ def release_pokemon(self, pokemon):
'dps': pokemon.moveset.dps
}
)
action_delay(self.bot.config.action_wait_min, self.bot.config.action_wait_max)
action_delay(self.transfer_wait_min, self.transfer_wait_max)

def _get_release_config_for(self, pokemon):
release_config = self.bot.config.release.get(pokemon)
Expand Down