Skip to content

Commit

Permalink
merge and refactor config files (#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffanLong authored and eggins committed Jul 25, 2016
1 parent 236fdc0 commit 33a0ad6
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 311 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
* budi-khoirudin
* riberod07
* th3w4y
* Leaklessgfy
* Leaklessgfy
* steffwiz
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,26 @@ To update your project do: `git pull` in the project folder
- `item_filter` :
- `evolve_all` : Set to true to evolve pokemons if possible

## Catch Configuration
Default configuration will capture all Pokemon.
```"any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}```
You can override the global configuration with Pokemon-specific options, such as:
```"Pidgey": {"catch_above_cp": 0, "catch_above_iv": 0.8", "logic": "and"}```
to only capture Pidgey with a good roll.
Additionally, you can specify always_capture and never_capture flags. For example:
```"Pidgey": {"never_capture": true}```
will stop catching Pidgey entirely.

## Release Configuration
Default configuration will not release any Pokemon.
```"any": {"release_under_cp": 0, "release_under_iv": 0, "logic": "or"}```
You can override the global configuration with Pokemon-specific options, such as:
```"Pidgey": {"release_below_cp": 0, "release_below_iv": 0.8", "logic": "or"}```
to only release Pidgey with bad rolls.
Additionally, you can specify always_release and never_release flags. For example:
```"Pidgey": {"always_release": true}```
will release all Pidgey caught.

### Evolve All Configuration
By setting the `evolve_all` attribute in config.json, you can instruct the bot to automatically
evolve specified pokemons on startup. This is especially useful for batch-evolving after popping up
Expand Down Expand Up @@ -232,7 +252,7 @@ sudo apt-get install nginx

#### 2. Check the webserver
Check if the webserver is running by using your browser and entering the IP address of your local machine/server.
On a local machine this would be http://127.0.0.1. On AWS this is your public DNS if you havent configured an elastic IP.
On a local machine this would be http://127.0.0.1. On AWS this is your public DNS if you haven't configured an elastic IP.

#### 3. Change Base Directory of the Webserver
```
Expand All @@ -248,7 +268,7 @@ Comment out following line: ```root /var/www/html;``` and change it to the web f
### What's IV ?
Here's the [introduction](http://bulbapedia.bulbagarden.net/wiki/Individual_values)

### Does it run automatally?
### Does it run automatically?
Not yet, still need a trainer to train the script param. But we are very close to.
### Set GEO Location
It works, use -l "xx.yyyy,zz.ttttt" to set lat long for location. -- diordache
Expand Down
18 changes: 12 additions & 6 deletions configs/config.json.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"auth_service": "google",
"username": "YOURACCOUNT@gmail.com",
"password": "YOURPASSWORD",
"location": "SOME LOCATION",
"gmapkey": "AGMAPAPIKEY",
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"location": "SOME_LOCATION",
"gmapkey": "GOOGLE_MAPS_API_KEY",
"max_steps": 5,
"mode": "all",
"walk": 4.16,
Expand All @@ -12,7 +12,13 @@
"initial_transfer": 0,
"location_cache": true,
"distance_unit": "km",
"item_filter": "101,102,103,104",
"item_filter": "",
"evolve_all": "NONE",
"use_lucky_egg": false
"use_lucky_egg": false,
"catch": {
"any": {"catch_above_cp": 0, "catch_above_iv": 0, "logic": "or"}
},
"release": {
"any": {"release_under_cp": 0, "release_under_iv": 0, "logic": "or"}
}
}
174 changes: 0 additions & 174 deletions configs/release_config.json.example

This file was deleted.

11 changes: 3 additions & 8 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@
if sys.version_info >= (2, 7, 9):
ssl._create_default_https_context = ssl._create_unverified_context


def init_config():
parser = argparse.ArgumentParser()
config_file = "configs/config.json"
release_config_json = "configs/release_config.json"
web_dir = "web"

# If config file exists, load variables from json
Expand Down Expand Up @@ -165,6 +163,8 @@ def init_config():
for key in config.__dict__:
if key in load:
config.__dict__[key] = load[key]
config.catch = load['catch']
config.release = load['release']

if config.auth_service not in ['ptc', 'google']:
logging.error("Invalid Auth service specified! ('ptc' or 'google')")
Expand All @@ -174,14 +174,9 @@ def init_config():
parser.error("Needs either --use-location-cache or --location.")
return None

config.release_config = {}
if os.path.isfile(release_config_json):
with open(release_config_json) as data:
config.release_config.update(json.load(data))
# When config.item_filter looks like "101,102,103" needs to be converted to ["101","102","103"]
if isinstance(config.item_filter, basestring):
#When config.item_filter looks like "101,102,103" needs to be converted to ["101","102","103"]
config.item_filter= config.item_filter.split(",")


# create web dir if not exists
try:
Expand Down
Loading

0 comments on commit 33a0ad6

Please sign in to comment.