Skip to content

Commit

Permalink
adding random delay between pokemon capture & transfer. #774 (#1225)
Browse files Browse the repository at this point in the history
* adding random delay between pokemon capture & transfer. #774

* improved fix for #774 by adding click_action_delay function

* wait time minimum & maximum are passed in from the config now

* updated readme & contributors files

* updated how action wait times are loaded from config

* optimize docker usage (#1257)

* update Dockerfile; install missed python-protobuf package; add CMD as a way of defining default arguments for the ENTRYPOINT

* remove CMD command, default config parameter is also set in pokecli.py

* Removed erroneous line in human_behavior and corrected bad merge resolution

* updated configs & changed function name to action_delay
  • Loading branch information
johnsosoka authored and eggins committed Jul 28, 2016
1 parent 6022dfb commit 5c3b108
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@
* fierysolid
* surfaace
* surceis
* SpaceWhale
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ We use [Slack](https://slack.com) as a web chat. [Click here to join the chat!](
- [x] Limit the step to farm specific area for pokestops
- [x] Rudimentary IV Functionality filter
- [x] Ignore certain pokemon filter
- [x] Adjust delay between Pokemon capture & Transfer as per configuration
- [ ] Standalone Desktop Application
- [ ] Hatch eggs
- [ ] Incubate eggs
Expand Down Expand Up @@ -59,4 +60,4 @@ Bitcoin Address: 1PJMCx9NNQRasQYaa4MMff9yyNFffhHgLu

<p align="center">
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WQUXDC54W6EVY"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif"></a>
</p>
</p>
2 changes: 2 additions & 0 deletions configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"max_steps": 5,
"mode": "all",
"walk": 4.16,
"action_wait_min": 1,
"action_wait_max": 4,

This comment has been minimized.

Copy link
@k4n30

k4n30 Jul 28, 2016

Contributor

need to add these 2 lines to config.json.pokemons.example

"debug": false,
"test": false,
"initial_transfer": false,
Expand Down
2 changes: 1 addition & 1 deletion configs/config.json.pokemons.example
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,4 @@
"Raichu": { "release_below_cp": 708, "release_below_iv": 0.8, "logic": "and" },
"Cloyster": { "release_below_cp": 717, "release_below_iv": 0.8, "logic": "and"}
}
}
}
2 changes: 2 additions & 0 deletions pokecli.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ def init_config():
config.catch = load.get('catch', {})
config.release = load.get('release', {})
config.item_filter = load.get('item_filter', {})
config.action_wait_max = load.get('action_wait_max', 4)
config.action_wait_min = load.get('action_wait_min', 1)

if config.auth_service not in ['ptc', 'google']:
logging.error("Invalid Auth service specified! ('ptc' or 'google')")
Expand Down
5 changes: 4 additions & 1 deletion pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sets import Set

from pokemongo_bot import logger
from pokemongo_bot.human_behaviour import sleep
from pokemongo_bot.human_behaviour import sleep, action_delay


class PokemonCatchWorker(object):
Expand Down Expand Up @@ -221,6 +221,9 @@ def work(self):
if len(pokemon_to_transfer) == 0:
raise RuntimeError(
'Trying to transfer 0 pokemons!')
# Add slight delay between capture & candy transfer #774
logger.log("Waiting briefly before transferring pokemon")
action_delay(self.config.action_wait_min, self.config.action_wait_max)
self.transfer_pokemon(pokemon_to_transfer[0])
self.bot.metrics.released_pokemon()
logger.log(
Expand Down
5 changes: 5 additions & 0 deletions pokemongo_bot/human_behaviour.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ def jitter(value, delta=0.3):
jitter = delta * value
return uniform(value-jitter, value+jitter)

def action_delay(low, high):
# Waits for random number of seconds between low & high numbers
longNum = uniform(low, high)
shortNum = float("{0:.2f}".format(longNum))
time.sleep(shortNum)

def random_lat_long_delta():
# Return random value from [-.000025, .000025]. Since 364,000 feet is equivalent to one degree of latitude, this
Expand Down

0 comments on commit 5c3b108

Please sign in to comment.