Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…o dev
  • Loading branch information
solderzzc committed Aug 26, 2016
2 parents 4ad7011 + ba424f9 commit 4916879
Show file tree
Hide file tree
Showing 17 changed files with 412 additions and 32 deletions.
14 changes: 14 additions & 0 deletions configs/config.json.cluster.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": true,
"live_config_update": {
"enabled": false,
"tasks_only": false
},
"tasks": [
{
"//NOTE: This task MUST be placed on the top of task list": {},
Expand Down Expand Up @@ -68,6 +72,16 @@
"items": ["pokemon_bag", "space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
}
},
{
"type": "ShowBestPokemon",
"config": {
"enabled": true,
"min_interval": 60,
"amount": 5,
"order_by": "cp",
"info_to_show": ["cp", "ivcp", "dps", "hp"]
}
},
{
"type": "TransferPokemon",
"config": {
Expand Down
16 changes: 15 additions & 1 deletion configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": true,
"live_config_update": {
"enabled": false,
"tasks_only": false
},
"tasks": [
{
"//NOTE: This task MUST be placed on the top of task list": {},
Expand Down Expand Up @@ -80,6 +84,16 @@
"items": ["pokemon_bag", "space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
}
},
{
"type": "ShowBestPokemon",
"config": {
"enabled": true,
"min_interval": 60,
"amount": 5,
"order_by": "cp",
"info_to_show": ["cp", "ivcp", "dps", "hp"]
}
},
{
"type": "TransferPokemon",
"config": {
Expand Down Expand Up @@ -250,7 +264,7 @@
"logging_color": true,
"daily_catch_limit": 800,
"catch": {
"any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"},
"any": {"candy_threshold" : 400 ,"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"},
"// Example of always catching Rattata:": {},
"// Rattata": { "always_catch" : true }
},
Expand Down
14 changes: 14 additions & 0 deletions configs/config.json.map.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": true,
"live_config_update": {
"enabled": false,
"tasks_only": false
},
"tasks": [
{
"//NOTE: This task MUST be placed on the top of task list": {},
Expand Down Expand Up @@ -68,6 +72,16 @@
"items": ["pokemon_bag", "space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
}
},
{
"type": "ShowBestPokemon",
"config": {
"enabled": true,
"min_interval": 60,
"amount": 5,
"order_by": "cp",
"info_to_show": ["cp", "ivcp", "dps", "hp"]
}
},
{
"type": "TransferPokemon",
"config": {
Expand Down
14 changes: 14 additions & 0 deletions configs/config.json.optimizer.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": true,
"live_config_update": {
"enabled": false,
"tasks_only": false
},
"tasks": [
{
"//NOTE: This task MUST be placed on the top of task list": {},
Expand Down Expand Up @@ -68,6 +72,16 @@
"items": ["pokemon_bag", "space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
}
},
{
"type": "ShowBestPokemon",
"config": {
"enabled": true,
"min_interval": 60,
"amount": 5,
"order_by": "cp",
"info_to_show": ["cp", "ivcp", "dps", "hp"]
}
},
{
"type": "PokemonOptimizer",
"config": {
Expand Down
14 changes: 14 additions & 0 deletions configs/config.json.path.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": true,
"live_config_update": {
"enabled": false,
"tasks_only": false
},
"tasks": [
{
"//NOTE: This task MUST be placed on the top of task list": {},
Expand Down Expand Up @@ -68,6 +72,16 @@
"items": ["pokemon_bag", "space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
}
},
{
"type": "ShowBestPokemon",
"config": {
"enabled": true,
"min_interval": 60,
"amount": 5,
"order_by": "cp",
"info_to_show": ["cp", "ivcp", "dps", "hp"]
}
},
{
"type": "TransferPokemon",
"config": {
Expand Down
14 changes: 14 additions & 0 deletions configs/config.json.pokemon.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"websocket_server": false,
"heartbeat_threshold": 10,
"enable_social": true,
"live_config_update": {
"enabled": false,
"tasks_only": false
},
"tasks": [
{
"//NOTE: This task MUST be placed on the top of task list": {},
Expand Down Expand Up @@ -68,6 +72,16 @@
"items": ["pokemon_bag", "space_info", "pokeballs", "greatballs", "ultraballs", "razzberries", "luckyegg"]
}
},
{
"type": "ShowBestPokemon",
"config": {
"enabled": true,
"min_interval": 60,
"amount": 5,
"order_by": "cp",
"info_to_show": ["cp", "ivcp", "dps", "hp"]
}
},
{
"type": "TransferPokemon",
"config": {
Expand Down
53 changes: 53 additions & 0 deletions docs/configuration_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- [Sleep Schedule Task](#sleep-schedule-task)
- [Random Pause](#random-pause)
- [Egg Incubator](#egg-incubator)
- [ShowBestPokemon](#showbestpokemon)

#Configuration files

Expand Down Expand Up @@ -81,6 +82,8 @@ Document the configuration options of PokemonGo-Bot.
|`pokemon_bag.show_count` | false | Show amount of each pokemon.
|`pokemon_bag.pokemon_info` | [] | Check any config example file to see available settings.
|`favorite_locations` | [] | Allows you to define a collection of locations and coordinates, allowing rapid switch using a "label" on your location config
| `live_config_update.enabled` | false | Enable live config update
| `live_config_update.tasks_only` | false | True: quick update for Tasks only (without re-login). False: slower update for entire config file.


## Configuring Tasks
Expand Down Expand Up @@ -704,6 +707,7 @@ Periodically displays the user inventory in the terminal.

### Options
[[back to top](#table-of-contents)]

* `min_interval` : The minimum interval at which the stats are displayed, in seconds (defaults to 120 seconds). The update interval cannot be accurate as workers run synchronously.
* `show_all_multiple_lines` : Logs all items on inventory using multiple lines. Ignores configuration of 'items'
* `items` : An array of items to display and their display order (implicitly), see available items below (defaults to []).
Expand Down Expand Up @@ -824,4 +828,53 @@ Configure how the bot should use the incubators.
}
```

## ShowBestPokemon
[[back to top](#table-of-contents)]

### Description
[[back to top](#table-of-contents)]

Periodically displays the user best pokemon in the terminal.

### Options
[[back to top](#table-of-contents)]

* `min_interval` : The minimum interval at which the pokemon are displayed, in seconds (defaults to 120 seconds). The update interval cannot be accurate as workers run synchronously.
* `amount` : Amount of pokemon to show.
* `order_by` : Stat that will be used to get best pokemons.
Available Stats: 'cp', 'iv', 'ivcp', 'ncp', 'dps', 'hp', 'level'
* `info_to_show` : Info to show for each pokemon

Available `info_to_show` :
```
'cp',
'iv_ads',
'iv_pct',
'ivcp',
'ncp',
'level',
'hp',
'moveset',
'dps'
```

### Sample configuration
[[back to top](#table-of-contents)]
```json
{
"type": "ShowBestPokemon",
"config": {
"enabled": true,
"min_interval": 60,
"amount": 5,
"order_by": "cp",
"info_to_show": ["cp", "ivcp", "dps"]
}
}
```

### Example console output
[[back to top](#table-of-contents)]
```
2016-08-25 21:20:59,642 [ShowBestPokemon] [INFO] [show_best_pokemon] [Tauros, CP 575, IVCP 0.95, DPS 12.04] | [Grimer, CP 613, IVCP 0.93, DPS 13.93] | [Tangela, CP 736, IVCP 0.93, DPS 14.5] | [Staryu, CP 316, IVCP 0.92, DPS 10.75] | [Gastly, CP 224, IVCP 0.9, DPS 11.7]
```
6 changes: 2 additions & 4 deletions docs/manual_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ source bin/activate

##### Requirements

- [Python 2.7.x](http://docs.python-guide.org/en/latest/starting/installation/)
- [Python 2.7.x](http://docs.python-guide.org/en/latest/starting/installation/) *Be sure to tick "Add python.exe to Path" during install*
- [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [Microsoft Visual C++ Compiler for Python 2.7](http://www.microsoft.com/en-us/download/details.aspx?id=44266)

Expand All @@ -107,8 +107,6 @@ pip2 install --upgrade pip
pip2 install --upgrade virtualenv
pip2 install --upgrade protobuf==3.0.0b4
git clone --recursive -b dev https://github.com/PokemonGoF/PokemonGo-Bot
pip2 install --upgrade "C:\Python27\PokemonGo-Bot\windows_bat\PyYAML-3.11-cp27-cp27m-win32.whl"
pip2 install --upgrade "C:\Python27\PokemonGo-Bot\windows_bat\PyYAML-3.11-cp27-cp27m-win_amd64.whl"
pip2 install --upgrade -r C:/Python27/PokemonGo-Bot/requirements.txt
cd C:/Python27/PokemonGo-Bot/
virtualenv .
Expand All @@ -118,7 +116,7 @@ pip2 install --upgrade -r C:/Python27/PokemonGo-Bot/requirements.txt

##### Get encrypt.so and encrypt.dll or encrypt_64.dll
Due to copywrite on the encrypt.so, encrypt.dll and encrypt_64.dll we are not directly hosting it. Please find a copy elsewhere on the internet and compile it yourself. We accept no responsibility should you encounter any problems with files you download elsewhere.
Try asking around our Slack chat!
Try asking around our Slack chat **(Just say the word "encrypt" and Slackbot will give you info)**!

Download it to the `C:/Python27/PokemonGo-Bot/` folder

Expand Down
50 changes: 41 additions & 9 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ def handle_sigint(*args):
raise SIGINTRecieved
signal.signal(signal.SIGINT, handle_sigint)

def initialize_task(bot, config):
tree = TreeConfigBuilder(bot, config.raw_tasks).build()
bot.workers = tree

def initialize(config):
bot = PokemonGoBot(config)
bot.start()
initialize_task(bot,config)
bot.metrics.capture_stats()
bot.health_record = BotEvent(config)
return bot

def get_commit_hash():
try:
hash = subprocess.check_output(['git', 'rev-parse', 'HEAD'], stderr=subprocess.STDOUT)[:-1]
Expand All @@ -88,7 +100,7 @@ def get_commit_hash():
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
sys.stderr = codecs.getwriter('utf8')(sys.stderr)

config = init_config()
config, config_file = init_config()
if not config:
return

Expand All @@ -100,12 +112,8 @@ def get_commit_hash():

while not finished:
try:
bot = PokemonGoBot(config)
bot.start()
tree = TreeConfigBuilder(bot, config.raw_tasks).build()
bot.workers = tree
bot.metrics.capture_stats()
bot.health_record = health_record
bot = initialize(config)
config_changed = check_mod(config_file)

bot.event_manager.emit(
'bot_start',
Expand All @@ -116,6 +124,12 @@ def get_commit_hash():

while True:
bot.tick()
if config.live_config_update_enabled and config_changed():
logger.info('Config changed! Applying new config.')
config, _ = init_config()

if config.live_config_update_tasks_only: initialize_task(bot, config)
else: bot = initialize(config)

except KeyboardInterrupt:
bot.event_manager.emit(
Expand Down Expand Up @@ -212,6 +226,18 @@ def get_commit_hash():
data={'path': cached_forts_path}
)

def check_mod(config_file):
check_mod.mtime = os.path.getmtime(config_file)

def compare_mtime():
mdate = os.path.getmtime(config_file)
if check_mod.mtime == mdate: # mtime didnt change
return False
else:
check_mod.mtime = mdate
return True

return compare_mtime

def report_summary(bot):
if bot.metrics.start_time is None:
Expand Down Expand Up @@ -265,6 +291,7 @@ def _json_loader(filename):

if config_arg and os.path.isfile(config_arg):
_json_loader(config_arg)
config_file = config_arg
elif os.path.isfile(config_file):
logger.info('No config argument specified, checking for /configs/config.json')
_json_loader(config_file)
Expand Down Expand Up @@ -593,9 +620,11 @@ 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', {})
config.sleep_schedule = load.get('sleep_schedule', [])
config.live_config_update = load.get('live_config_update', {})
config.live_config_update_enabled = config.live_config_update.get('enabled', False)
config.live_config_update_tasks_only = config.live_config_update.get('tasks_only', False)

if config.map_object_cache_time < 0.0:
parser.error("--map_object_cache_time is out of range! (should be >= 0.0)")
Expand Down Expand Up @@ -638,6 +667,9 @@ def task_configuration_error(flag_name):
if "walk" in load:
logger.warning('The walk argument is no longer supported. Please use the walk_max and walk_min variables instead')

if "daily_catch_limit" in load:
logger.warning('The daily_catch_limit argument has been moved into the CatchPokemon Task')

if config.walk_min < 1:
parser.error("--walk_min is out of range! (should be >= 1.0)")
return None
Expand All @@ -662,7 +694,7 @@ def task_configuration_error(flag_name):
raise

fix_nested_config(config)
return config
return config, config_file

def add_config(parser, json_config, short_flag=None, long_flag=None, **kwargs):
if not long_flag:
Expand Down
Loading

0 comments on commit 4916879

Please sign in to comment.