Repository: PokemonGoF/PokemonGo-Bot

Issue:
implement application like delays to account of animation screens
### Short Description

logs for the game are being joined up into one place, anything that does not look normal from a device in timings is being flagged 
from my normal play through once a pokemon shows up nearby, it takes at least 2-3 seconds before you can throw a pokeball (animation of pokemon appearing) , then it takes at least 3-20 seconds (20ish if its a new pokedex pokemon) to allow you to transfer cancel out of the capture and allow you select another pokemon to capture. 

I don't know where the asset downloads would be occuring, e.g. when you have a new pokemon nearby or when you select it to capture.
### Possible solution

implement default timings for items such as selecting/throwing pokeball after they appear. waiting the min time after a capture for the success screen and maybe the new pokedex entry. if a badge is awarded, wait the min time for the badge to display before selecting/throwing a pokeball etc.
### How it would help others

With more realistic application timings we should be able to stand out as much as the other users of the api.



Discussion:
This is already accomplished with @Quantra's catch_simulation, except the part on new pokedex entry.

```
          "catch_simulation": {
            "flee_count": 3,
            "flee_duration": 3,
            "catch_wait_min": 3,
            "catch_wait_max": 6,
            "berry_wait_min": 3,
            "berry_wait_max": 5,
            "changeball_wait_min": 3,
            "changeball_wait_max": 5
          }
```

Shouldn't be too hard to add a min/max wait time if we catch a new pokemon. I'll look when I get home, less someone else merges before then. 

Cant radt the code, when bot is in 20sec pause, gps data are sent or are also in pause ?

@MZorzy TBH we probably shouldn't use a flat sleep anywhere. Ideally our responses to the server were decoupled from our tasks. But that's a pretty large change.

In the mean time, I'd say a standard sleep is fine (no API updates). 

maybe go for a random sleep between min time and a max so that its not as
easy to tell due to exact timings. i've noticed that the tutorial/avatar
setup has exact sleeps which if enough bots user it will show up as humans
never wait exactly 10 seconds before actioning things ;)

On 25 August 2016 at 15:57, Matt J Madsen notifications@github.com wrote:

> @MZorzy https://github.com/MZorzy TBH we probably shouldn't use a flat
> sleep anywhere. Ideally our responses to the server were decoupled from our
> tasks. But that's a pretty large change.
> 
> In the mean time, I'd say a standard sleep is fine (no API updates).
> 
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> https://github.com/PokemonGoF/PokemonGo-Bot/issues/4700#issuecomment-242288176,
> or mute the thread
> https://github.com/notifications/unsubscribe-auth/AB7XcBpRVuPaZoJWoTnTLYMKepOWanmaks5qjS7kgaJpZM4JshLV
> .

As I thought about it, our API should be the thing that determines when our calls are made. If it's a request/response sent every X seconds, it should be doing the handling of that. Not quite in the scope of our project.

I'll take a gander at the pokemon_catch_worker and try to get in a PR for the never seen before capture delays. 


Resolving patch:
diff --git a/pokemongo_bot/cell_workers/pokemon_catch_worker.py b/pokemongo_bot/cell_workers/pokemon_catch_worker.py
--- a/pokemongo_bot/cell_workers/pokemon_catch_worker.py
+++ b/pokemongo_bot/cell_workers/pokemon_catch_worker.py
@@ -78,6 +78,8 @@ def initialize(self):
         self.catchsim_berry_wait_max = self.catchsim_config.get('berry_wait_max', 3)
         self.catchsim_changeball_wait_min = self.catchsim_config.get('changeball_wait_min', 2)
         self.catchsim_changeball_wait_max = self.catchsim_config.get('changeball_wait_max', 3)
+        self.catchsim_newtodex_wait_min = self.catchsim_config.get('newtodex_wait_min', 20)
+        self.catchsim_newtodex_wait_max = self.catchsim_config.get('newtodex_wait_max', 30)
 
 
     ############################################################################
@@ -499,6 +501,8 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False):
 
                 try:
                     inventory.pokemons().add(pokemon)
+                    exp_gain = sum(response_dict['responses']['CATCH_POKEMON']['capture_award']['xp'])
+                    
                     self.emit_event(
                         'pokemon_caught',
                         formatted='Captured {pokemon}! [CP {cp}] [NCP {ncp}] [Potential {iv}] [{iv_display}] [+{exp} exp]',
@@ -508,7 +512,7 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False):
                             'cp': pokemon.cp,
                             'iv': pokemon.iv,
                             'iv_display': pokemon.iv_display,
-                            'exp': sum(response_dict['responses']['CATCH_POKEMON']['capture_award']['xp']),
+                            'exp': exp_gain,
                             'encounter_id': self.pokemon['encounter_id'],
                             'latitude': self.pokemon['latitude'],
                             'longitude': self.pokemon['longitude'],
@@ -545,6 +549,10 @@ def _do_catch(self, pokemon, encounter_id, catch_rate_by_ball, is_vip=False):
                         }, outfile)
                         outfile.write('\n')
 
+                    # if it is a new pokemon to our dex, simulate app animation delay
+                    if exp_gain >= 500:
+                        sleep (randrange(catchsim_newtodex_wait_min, catchsim_newtodex_wait_max))
+
                 except IOError as e:
                     self.logger.info('[x] Error while opening location file: %s' % e)
 


Test patch: