Skip to content

Commit

Permalink
Fixed 2nd Conflict. New to this.. bear with me.
Browse files Browse the repository at this point in the history
  • Loading branch information
RedViper9 committed Aug 18, 2016
2 parents 1287161 + 8eba07a commit 90f137f
Show file tree
Hide file tree
Showing 20 changed files with 350 additions and 60 deletions.
1 change: 1 addition & 0 deletions configs/config.json.cluster.example
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
"distance_unit": "km",
"reconnecting_timeout": 15,
"logging_color": true,
"daily_catch_limit": 800,
"catch": {
"any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"},
"// Example of always catching Rattata:": {},
Expand Down
17 changes: 15 additions & 2 deletions configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
"duration_random_offset": "00:43"
}
},
{
"type": "RandomPause",
"config": {
"enabled": false,
"min_duration": "00:00:10",
"max_duration": "00:10:00",
"min_interval": "00:10:00",
"max_interval": "02:00:00"
}
},
{
"type": "CompleteTutorial",
"config": {
Expand Down Expand Up @@ -156,6 +166,7 @@
"distance_unit": "km",
"reconnecting_timeout": 15,
"logging_color": true,
"daily_catch_limit": 800,
"catch": {
"any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"},
"// Example of always catching Rattata:": {},
Expand All @@ -167,12 +178,14 @@
"// Rattata": {"always_release": true},
"// Example of keeping 3 stronger (based on CP) Pidgey:": {},
"// Pidgey": {"keep_best_cp": 3},
"// Example of keeping 2 stronger (based on IV) Zubat:": {},
"// Example of keeping 2 best (based on IV) Zubat:": {},
"// Zubat": {"keep_best_iv": 2},
"// Also, it is working with any": {},
"// any": {"keep_best_iv": 3},
"// Example of keeping the 2 strongest (based on CP) and 3 best (based on IV) Zubat:": {},
"// Zubat": {"keep_best_cp": 2, "keep_best_iv": 3}
"// Zubat": {"keep_best_cp": 2, "keep_best_iv": 3},
"// Example of custom order of static criterion": {},
"// Zubat": {"keep_best_custom": "moveset.defense_perfection, hp_max", "amount":2}
},
"vips" : {
"Any pokemon put here directly force to use Berry & Best Ball to capture, to secure the capture rate!": {},
Expand Down
1 change: 1 addition & 0 deletions configs/config.json.map.example
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@
"distance_unit": "km",
"reconnecting_timeout": 15,
"logging_color": true,
"daily_catch_limit": 800,
"catch": {
"any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"},
"// Example of always catching Rattata:": {},
Expand Down
1 change: 1 addition & 0 deletions configs/config.json.optimizer.example
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
"distance_unit": "km",
"reconnecting_timeout": 15,
"logging_color": true,
"daily_catch_limit": 800,
"catch": {
"any": {
"always_catch": true
Expand Down
1 change: 1 addition & 0 deletions configs/config.json.path.example
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
"distance_unit": "km",
"reconnecting_timeout": 15,
"logging_color": true,
"daily_catch_limit": 800,
"catch": {
"any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"},
"// Example of always catching Rattata:": {},
Expand Down
1 change: 1 addition & 0 deletions configs/config.json.pokemon.example
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
"distance_unit": "km",
"reconnecting_timeout": 15,
"logging_color": true,
"daily_catch_limit": 800,
"catch": {
"any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or" },

Expand Down
16 changes: 16 additions & 0 deletions docs/configuration_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
| `location_cache` | true | Bot will start at last known location if you do not have location set in the config |
| `distance_unit` | km | Set the unit to display distance in (km for kilometers, mi for miles, ft for feet) |
| `evolve_cp_min` | 300 | Min. CP for evolve_all function
|`daily_catch_llimit` | 800 | Limit the amount of pokemon caught in a 24 hour period.

## Configuring Tasks
The behaviors of the bot are configured via the `tasks` key in the `config.json`. This enables you to list what you want the bot to do and change the priority of those tasks by reordering them in the list. This list of tasks is run repeatedly and in order. For more information on why we are moving config to this format, check out the [original proposal](https://github.com/PokemonGoF/PokemonGo-Bot/issues/142).
Expand Down Expand Up @@ -162,6 +163,21 @@ If you already have it, it will keep a stronger version and will transfer the a

```"release": {"any": {"keep_best_cp": 2}}```, ```"release": {"any": {"keep_best_cp": 10}}``` - can be any number.

### Keep the best custom pokemon configuration (dev branch)

Define a list of criteria to keep the best Pokemons according to those criteria.

The list of criteria is the following:```'cp','iv', 'iv_attack', 'iv_defense', 'iv_stamina', 'moveset.attack_perfection', 'moveset.defense_perfection', 'hp', 'hp_max'```

####Examples:

- Keep the top 25 Zubat with the best hp_max:

```"release": {"Zubat": {"keep_best_custom": "hp_max", "amount":25}}```
- Keep the top 10 Zubat with the best hp_max and, if there are Zubat with the same hp_max, to keep the one with the highest hp:

```"release": {"Zubat": {"keep_best_custom": "hp_max,hp", "amount":10}}````

## Evolve All Configuration

By setting the `evolve_all` attribute in config.json, you can instruct the bot to automatically
Expand Down
2 changes: 1 addition & 1 deletion pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def _json_loader(filename):
config.release = load.get('release', {})
config.plugins = load.get('plugins', [])
config.raw_tasks = load.get('tasks', [])

config.daily_catch_limit = load.get('daily_catch_limit', 800)
config.vips = load.get('vips', {})

if config.map_object_cache_time < 0.0:
Expand Down
36 changes: 30 additions & 6 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,22 @@ def _register_events(self):
'wake'
)
)

# random pause
self.event_manager.register_event(
'next_random_pause',
parameters=(
'time',
'duration'
)
)
self.event_manager.register_event(
'bot_random_pause',
parameters=(
'time_hms',
'resume'
)
)

# fort stuff
self.event_manager.register_event(
Expand Down Expand Up @@ -284,6 +300,7 @@ def _register_events(self):
self.event_manager.register_event(
'threw_pokeball',
parameters=(
'throw_type',
'ball_name',
'success_percentage',
'count_left'
Expand Down Expand Up @@ -324,6 +341,7 @@ def _register_events(self):
self.event_manager.register_event('threw_berry_failed', parameters=('status_code',))
self.event_manager.register_event('vip_pokemon')
self.event_manager.register_event('gained_candy', parameters=('quantity', 'type'))
self.event_manager.register_event('catch_limit')

# level up stuff
self.event_manager.register_event(
Expand Down Expand Up @@ -555,8 +573,11 @@ def update_web_location(self, cells=[], lat=None, lng=None, alt=None):
cells = self.find_close_cells(*location)

user_data_cells = os.path.join(_base_dir, 'data', 'cells-%s.json' % self.config.username)
with open(user_data_cells, 'w') as outfile:
json.dump(cells, outfile)
try:
with open(user_data_cells, 'w') as outfile:
json.dump(cells, outfile)
except IOError as e:
self.logger.info('[x] Error while opening location file: %s' % e)

user_web_location = os.path.join(
_base_dir, 'web', 'location-%s.json' % self.config.username
Expand Down Expand Up @@ -715,10 +736,10 @@ def get_encryption_lib(self):
full_path = path + '/'+ file_name
if not os.path.isfile(full_path):
self.logger.error(file_name + ' is not found! Please place it in the bots root directory or set encrypt_location in config.')
self.logger.info('Platform: '+ _platform + ' Encrypt.so directory: '+ path)
self.logger.info('Platform: '+ _platform + ' ' + file_name + ' directory: '+ path)
sys.exit(1)
else:
self.logger.info('Found '+ file_name +'! Platform: ' + _platform + ' Encrypt.so directory: ' + path)
self.logger.info('Found '+ file_name +'! Platform: ' + _platform + ' ' + file_name + ' directory: ' + path)

return full_path

Expand Down Expand Up @@ -852,8 +873,11 @@ def current_inventory(self):

user_web_inventory = os.path.join(_base_dir, 'web', 'inventory-%s.json' % self.config.username)

with open(user_web_inventory, 'w') as outfile:
json.dump(inventory_dict, outfile)
try:
with open(user_web_inventory, 'w') as outfile:
json.dump(inventory_dict, outfile)
except IOError as e:
self.logger.info('[x] Error while opening location file: %s' % e)

# get player items stock
# ----------------------
Expand Down
2 changes: 1 addition & 1 deletion pokemongo_bot/api_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
NoPlayerPositionSetException, EmptySubrequestChainException,
UnexpectedResponseException)
from pgoapi.pgoapi import PGoApi, PGoApiRequest, RpcApi
from pgoapi.protos.POGOProtos.Networking.Requests_pb2 import RequestType
from pgoapi.protos.POGOProtos.Networking.Requests.RequestType_pb2 import RequestType

from human_behaviour import sleep

Expand Down
1 change: 1 addition & 0 deletions pokemongo_bot/cell_workers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
from update_live_stats import UpdateLiveStats
from catch_pokemon import CatchPokemon
from complete_tutorial import CompleteTutorial
from random_pause import RandomPause
7 changes: 7 additions & 0 deletions pokemongo_bot/cell_workers/catch_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from pokemongo_bot.base_task import BaseTask
from pokemongo_bot.worker_result import WorkerResult
from pokemongo_bot.cell_workers import CatchVisiblePokemon, CatchLuredPokemon
from pokemongo_bot.item_list import Item
from pokemongo_bot import inventory


class CatchPokemon(BaseTask):
Expand All @@ -15,6 +17,11 @@ def initialize(self):
self.catch_workers.append(CatchLuredPokemon(self.bot, self.config))

def work(self):

if sum([inventory.items().get(ball.value).count for ball in
[Item.ITEM_POKE_BALL, Item.ITEM_GREAT_BALL, Item.ITEM_ULTRA_BALL]]) <= 0:
return WorkerResult.ERROR

for cw in self.catch_workers:
if cw.work() == WorkerResult.RUNNING:
return WorkerResult.RUNNING
Expand Down
5 changes: 5 additions & 0 deletions pokemongo_bot/cell_workers/migrations/catch_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from yoyo import step

step(
"CREATE TABLE catch_log (pokemon text, cp real, iv real, encounter_id text, pokemon_id real, dated datetime DEFAULT CURRENT_TIMESTAMP)"
)
Loading

0 comments on commit 90f137f

Please sign in to comment.