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

Add option to separate usage of incubator unbreakable from breakable (2) #4564

Merged
merged 14 commits into from
Aug 22, 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
4 changes: 3 additions & 1 deletion configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
},
{
Expand Down
24 changes: 24 additions & 0 deletions docs/configuration_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]
}
}
```


20 changes: 18 additions & 2 deletions pokemongo_bot/cell_workers/incubate_eggs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)
Expand Down