Skip to content

Commit

Permalink
Merge pull request #6017 from PokemonGoF/dev
Browse files Browse the repository at this point in the history
Dev merge to master
  • Loading branch information
solderzzc authored Apr 14, 2017
2 parents 8c176c0 + b210744 commit 263da69
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ If you need any help please don't create an issue as we have a great community o
## Discord
- [Click here to join discord server](https://discord.gg/n3g5puF)

###[Bugs / Issues](https://github.com/PokemonGoF/PokemonGo-Bot/issues?q=is%3Aissue+sort%3Aupdated-desc)
### [Bugs / Issues](https://github.com/PokemonGoF/PokemonGo-Bot/issues?q=is%3Aissue+sort%3Aupdated-desc)
If you discover a bug in the bot, please [search our issue tracker](https://github.com/PokemonGoF/PokemonGo-Bot/issues?q=is%3Aissue+sort%3Aupdated-desc) first. If it hasn't been reported, please [create a new issue](https://github.com/PokemonGoF/PokemonGo-Bot/issues/new) and ensure you follow the template guide so that our team can assist you as quickly as possible.

###[Feature Requests](https://github.com/PokemonGoF/PokemonGo-Bot/labels/Feature%20Request)
### [Feature Requests](https://github.com/PokemonGoF/PokemonGo-Bot/labels/Feature%20Request)
If you have a great idea to improve the bot, please [search our feature tracker](https://github.com/PokemonGoF/PokemonGo-Bot/labels/Feature%20Request) first to ensure someone else hasn't already come up with the same great idea. If it hasn't been requested, please [create a new request](https://github.com/PokemonGoF/PokemonGo-Bot/issues/new) and ensure you follow the template guide so that it doesnt get lost with the bug reports.
While you're there vote on other feature requests to let the devs know what is most important to you.

###[Pull Requests](https://github.com/PokemonGoF/PokemonGo-Bot/pulls)
### [Pull Requests](https://github.com/PokemonGoF/PokemonGo-Bot/pulls)
If you'd like to make your own changes, make sure you follow the pull request template, and ensure your PR is made against the 'dev' branch.

If this is your first time making a PR or aren't sure of the standard practice of making a PR, here are some articles to get you started.
Expand Down
1 change: 1 addition & 0 deletions docs/configuration_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ The behaviors of the bot are configured via the `tasks` key in the `config.json`
* Catch Limiter
* `enabled`: Default false | Enable/disable the task
* `min_balls`: Default 20 | Minimum balls on hand before catch tasks enabled
* `resume_at_balls`: Default 100 | When this number of balls is reached, immediately resume catching
* `duration`: Default 15 | Length of time to disable catch tasks
* EvolvePokemon
* `enable`: Disable or enable this task.
Expand Down
2 changes: 1 addition & 1 deletion docs/google_map.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The webpage is a submodule to this repository and config related to that is in ./web folder

[OpenPoGoWeb] (https://github.com/OpenPoGo/OpenPoGoWeb) uses Google Maps. Read their [README] (https://github.com/OpenPoGo/OpenPoGoWeb/blob/master/README.md) for how to configure web frontend
[OpenPoGoWeb](https://github.com/OpenPoGo/OpenPoGoWeb) uses Google Maps. Read their [README](https://github.com/OpenPoGo/OpenPoGoWeb/blob/master/README.md) for how to configure web frontend

## How to set up a simple webserver with nginx
## SimpleHTTPServer
Expand Down
14 changes: 11 additions & 3 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ docker run --name=bot1-pokego --rm -it -v $(pwd)/configs/auth.json:/usr/src/app/
>```
docker run --name=bot1-pokego --rm -it -v $(pwd)/configs:/usr/src/app/configs -v $(pwd)/web/:/usr/src/app/web/ pokemongo-bot
```
>
Run a second container provided with the OpenPoGoBotWeb view:

Expand Down Expand Up @@ -132,11 +132,19 @@ docker run --name=bot1-pokegoweb --rm -it --volumes-from bot1-pokego -p 8000:800
docker-machine ip default
```


Then, with your containers running and your host address, you can access the web view in your browser:

`http://<your host address>:8000 (eg http://192.168.99.100:8000)`


Using proxy with docker:
- https proxy
```
docker run --name=bot1-pokego -e "https_proxy=https://PROXY_IP:PORT" --rm -it -v $(pwd)/configs:/usr/src/app/configs -v $(pwd)/web/:/usr/src/app/web/ pokemongo-bot
```
- http proxy
```
docker run --name=bot1-pokego -e "http_proxy=http://PROXY_IP:PORT" --rm -it -v $(pwd)/configs:/usr/src/app/configs -v $(pwd)/web/:/usr/src/app/web/ pokemongo-bot
```
#### Errors

- An error occurred trying to connect:
Expand Down
10 changes: 5 additions & 5 deletions docs/manual_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Consider purchase of [hashing key](http://hashing.pogodev.org) - if you want use
### Linux and Mac
Ubuntu will be used for the Linux Example

####First install required packages
#### First install required packages

#####Linux - Ubuntu
##### Linux - Ubuntu
```bash
sudo apt-get install build-essential autoconf libtool pkg-config make python2.7-dev wget git
```
#####Linux - Centos 7
##### Linux - Centos 7
```bash
sudo yum install -y epel-release
sudo yum install -y git wget python python-pip
Expand All @@ -26,11 +26,11 @@ if you are on a different Linux OS you maybe have to adapt things like:
- package manager (for example yum instead of apt-get)
- package names

#####Mac
##### Mac
```bash
brew install autoconf libtool pkg-config wget git
```
####Mac + Linux installation
#### Mac + Linux installation
make sure you installed everything above

- get pip for python2.7
Expand Down
11 changes: 9 additions & 2 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,7 @@ def login(self):
total_entry = int(len(bossland_hash_endpoint))
last_bossland_entry = bossland_hash_endpoint[total_entry-1]
bossland_lastestAPI = last_bossland_entry.split(":")[0].replace('\"','')
hashingAPI_temp = 0
self.event_manager.emit(
'security_check',
sender=self,
Expand All @@ -1036,9 +1037,15 @@ def login(self):

for version, endpoint in bossland_hash_data.items():
if endpoint == PGoAPI_hash_endpoint:
if int(version[0]) != 1 and int(version[0]) == 0:
# Version should always be in this format x.xx.x
# Check total len, if less than 4, pack a zero behind
if len(version.replace('.','')) < 4:
version = version + ".0"
hashingAPI_temp = int(version.replace('.',''))
# iOS versioning is always more than 1.19.0
if hashingAPI_temp < 1190:
PGoAPI_hash_version.append(version)
# assuming andorid versioning is always last entry
# assuming andorid versioning is always last entry
PGoAPI_hash_version.sort(reverse=True)
# covert official api version & hashing api version to numbers
officialAPI_int = int(officalAPI.replace('.',''))
Expand Down
16 changes: 13 additions & 3 deletions pokemongo_bot/cell_workers/catch_limiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def __init__(self, bot, config):
self.bot = bot
self.config = config
self.enabled = self.config.get("enabled",False)
self.min_balls = self.config.get("min_balls",20)
self.min_balls = self.config.get("min_balls", 20)
self.resume_at_balls = self.config.get("resume_at_balls", 100)
self.duration = self.config.get("duration",15)
if not hasattr(self.bot, "catch_resume_at"): self.bot.catch_resume_at = None

Expand All @@ -26,7 +27,7 @@ def work(self):

now = datetime.now()
balls_on_hand = self.get_pokeball_count()

# If resume time has passed, resume catching tasks
if self.bot.catch_disabled and now >= self.bot.catch_resume_at:
if balls_on_hand > self.min_balls:
Expand All @@ -37,6 +38,15 @@ def work(self):
)
self.bot.catch_disabled = False

# If currently not catching, but balls >= resume_at_balls
if self.bot.catch_disabled and balls_on_hand >= self.resume_at_balls:
self.emit_event(
'catch_limit_off',
formatted="Resume time hasn't passed yet, bu balls on hand ({}) exceeds threshold {}. Re-enabling catch tasks.".
format(balls_on_hand, self.resume_at_balls)
)
self.bot.catch_disabled = False

# If balls_on_hand less than threshold, pause catching tasks for duration minutes
if not self.bot.catch_disabled and balls_on_hand <= self.min_balls:
self.bot.catch_resume_at = now + timedelta(minutes = self.duration)
Expand All @@ -46,7 +56,7 @@ def work(self):
formatted="Balls on hand ({}) has reached threshold {}. Disabling catch tasks until {} or balls on hand > threshold (whichever is later).".
format(balls_on_hand, self.min_balls, self.bot.catch_resume_at.strftime("%H:%M:%S"))
)

return WorkerResult.SUCCESS

def get_pokeball_count(self):
Expand Down
19 changes: 17 additions & 2 deletions pokemongo_bot/cell_workers/pokemon_hunter.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,24 @@ def _is_vip_pokemon(self, pokemon):
def _is_needed_pokedex(self, pokemon):
candies = inventory.candies().get(pokemon["pokemon_id"]).quantity
if candies > 150:
return False
# We have enough candies, pass on hunting this Pokemon
if any(not inventory.pokedex().seen(fid) for fid in self.get_family_ids(pokemon)):
return False

# get family ids, gets ALL ids, also for previous evo!
# We could see a Ivysaur on the map, and need a Bulbasaur
# Then we have no need for a Ivysaur. If we see a Bulbasaur and need
# a Ivysaur, then we DO need this pokemon.
got_current_evo = False
ids = []
for fid in self.get_family_ids(pokemon):
if got_current_evo:
ids += [fid]
else:
if fid == pokemon["pokemon_id"]:
ids += [fid]
got_current_evo = True
# Check if we need this, or a next EVO in the Pokedex
if any(not inventory.pokedex().seen(fid) for fid in ids):
return True

def get_worth_pokemons(self, pokemons):
Expand Down
8 changes: 7 additions & 1 deletion pokemongo_bot/cell_workers/pokemon_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,9 @@ def get_evolution_plan(self, family_id, family_list, keep, try_evolve, try_upgra
upgrade_level = min(self.config_upgrade_level, inventory.player().level + 1.5, 40)

for pokemon in try_upgrade:
# self.log("Considering %s for upgrade" % pokemon.name)
if pokemon.level >= upgrade_level:
# self.log("Pokemon already at target level. %s" % pokemon.level)
continue

full_upgrade_candy_cost = 0
Expand All @@ -596,8 +598,12 @@ def get_evolution_plan(self, family_id, family_list, keep, try_evolve, try_upgra
self.ongoing_stardust_count -= full_upgrade_stardust_cost

if (candies < 0) or (self.ongoing_stardust_count < 0):
# self.log("Not enough candy: %s" % candies)
# self.log("or stardust %s" % self.ongoing_stardust_count)
# We didn' t use the stardust, so refund it...
self.ongoing_stardust_count += full_upgrade_stardust_cost
continue

# self.log("Pokemon can be upgraded!!")
upgrade.append(pokemon)

if (not self.config_evolve_for_xp) or (family_name in self.config_evolve_for_xp_blacklist):
Expand Down

0 comments on commit 263da69

Please sign in to comment.