Skip to content

Commit

Permalink
Deprecate action_wait_min/max in favour of task specific options (#4048)
Browse files Browse the repository at this point in the history
* RecycleItems uses it's own recycle_wait_min/max instead of action_wait_min/max

* TransferPokemon uses it's own transfer_wait_min/max instead of action_wait_min/max

* PokemonOptimizer uses it's own transfer_wait_min/max instead of action_wait_min/max

* Deprecated action_wait_min and action_wait_max

* fixed mistake
  • Loading branch information
Quantra authored and solderzzc committed Aug 17, 2016
1 parent 8e40230 commit 7136348
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
8 changes: 6 additions & 2 deletions configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
},
{
"type": "TransferPokemon"
"config": {
"transfer_wait_min": 1,
"transfer_wait_max": 4
}
},
{
"type": "NicknamePokemon",
Expand Down Expand Up @@ -78,6 +82,8 @@
"Revive": { "keep" : 30 },
"Razz Berry": { "keep" : 100 }
}
"recycle_wait_min": 1,
"recycle_wait_max": 4
}
},
{
Expand Down Expand Up @@ -135,8 +141,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 @@ -465,8 +465,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', [])

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 @@ -36,6 +36,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)
self.max_pokemon_storage = self.bot.player_data["max_pokemon_storage"]
Expand Down Expand Up @@ -284,7 +287,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

2 comments on commit 7136348

@belinux
Copy link

@belinux belinux commented on 7136348 Aug 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.json.example line 44 needs a "," at the end of the line :D

@maxprzemo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a random min-max or just between these values?

Please sign in to comment.