diff --git a/configs/config.json.example b/configs/config.json.example index 7c694cd56d..a536410b64 100644 --- a/configs/config.json.example +++ b/configs/config.json.example @@ -47,7 +47,9 @@ "type": "IncubateEggs", "config": { "longer_eggs_first": true, - "min_interval": 120 + "min_interval": 120, + "infinite": [2,5,10], + "breakable": [2,5,10] } }, { diff --git a/docs/configuration_files.md b/docs/configuration_files.md index d01a50bb12..9755c9a303 100644 --- a/docs/configuration_files.md +++ b/docs/configuration_files.md @@ -44,6 +44,7 @@ - [Example console output](#example-console-output) - [Sleep Schedule Task](#sleep-schedule-task) - [Random Pause](#random-pause) +- [Egg Incubator](#egg-incubator) #Configuration files @@ -755,3 +756,26 @@ Simulates the random pause of the day (speaking to someone, getting into a store } } ``` + +##Egg Incubator +[[back to top](#table-of-contents)] + +Configure how the bot should use the incubators. + +- `longer_eggs_first`: (True | False ) should the bot start by the longer eggs first. If set to true, the bot first use the 10km eggs, then the 5km eggs, then the 2km eggs. +- `infinite`: ([2], [2,5], [2,5,10], []) the type of egg the infinite (ie. unbreakable) incubator(s) can incubate. If set to [2,5], the incubator(s) can only incubate the 2km and 5km eggs. If set to [], the incubator(s) can incubate any type of egg. +- `breakable`: ([2], [2,5], [2,5,10], []) the type of egg the breakable incubator(s) can incubate. If set to [2,5], the incubator(s) can only incubate the 2km and 5km eggs. If set to [], the incubator(s) can incubate any type of egg. + +###Example Config +``` +{ + "type": "IncubateEggs", + "config": { + "longer_eggs_first": true, + "infinite": [2,5], + "breakable": [10] + } +} +``` + + diff --git a/pokemongo_bot/cell_workers/incubate_eggs.py b/pokemongo_bot/cell_workers/incubate_eggs.py index 86a7de657b..668a641c61 100644 --- a/pokemongo_bot/cell_workers/incubate_eggs.py +++ b/pokemongo_bot/cell_workers/incubate_eggs.py @@ -23,7 +23,10 @@ def initialize(self): def _process_config(self): self.longer_eggs_first = self.config.get("longer_eggs_first", True) self.min_interval = self.config.get('min_interval', 120) - + + self.breakable_incubator = self.config.get("breakable", []) + self.infinite_incubator = self.config.get("infinite", []) + def work(self): try: self._check_inventory() @@ -57,6 +60,19 @@ def _apply_incubators(self): for egg in self.eggs: if egg["used"] or egg["km"] == -1: continue + + if self.breakable_incubator: + # test if the incubator is of type breakable + if incubator.get('uses_remaining') is not None: + if egg["km"] not in self.breakable_incubator: + continue + + if self.infinite_incubator: + # test if the incubator is of type infinite + if incubator.get('uses_remaining') is None: + if egg["km"] not in self.infinite_incubator: + continue + self.emit_event( 'incubate_try', level='debug', @@ -119,7 +135,7 @@ def _check_inventory(self, lookup_ids=[]): incubators = inv_data.get("egg_incubators", {}).get("egg_incubator",[]) if isinstance(incubators, basestring): # checking for old response incubators = [incubators] - for incubator in incubators: + for incubator in incubators: if 'pokemon_id' in incubator: start_km = incubator.get('start_km_walked', 9001) km_walked = incubator.get('target_km_walked', 9001)