Skip to content

Commit

Permalink
Merge pull request #4714 from mjmadsen/mjmadsen-patch-2
Browse files Browse the repository at this point in the history
Add random delay for animation if new to dex
  • Loading branch information
solderzzc authored Aug 25, 2016
2 parents 54f78b8 + dad1e26 commit e2e13cf
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 34 deletions.
4 changes: 3 additions & 1 deletion configs/config.json.cluster.example
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@
"berry_wait_min": 3,
"berry_wait_max": 5,
"changeball_wait_min": 3,
"changeball_wait_max": 5
"changeball_wait_max": 5,
"newtodex_wait_min": 20,
"newtodex_wait_max": 30
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion configs/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@
"berry_wait_min": 3,
"berry_wait_max": 5,
"changeball_wait_min": 3,
"changeball_wait_max": 5
"changeball_wait_max": 5,
"newtodex_wait_min": 20,
"newtodex_wait_max": 30
}
}
},
Expand Down
4 changes: 3 additions & 1 deletion configs/config.json.map.example
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@
"berry_wait_min": 2,
"berry_wait_max": 3,
"changeball_wait_min": 2,
"changeball_wait_max": 3
"changeball_wait_max": 3,
"newtodex_wait_min": 20,
"newtodex_wait_max": 30
}
}
},
Expand Down
22 changes: 12 additions & 10 deletions configs/config.json.optimizer.example
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,18 @@
"normal_rate": 0.1,
"spin_success_rate" : 0.6
},
"catch_simulation": {
"flee_count": 3,
"flee_duration": 2,
"catch_wait_min": 3,
"catch_wait_max": 6,
"berry_wait_min": 3,
"berry_wait_max": 5,
"changeball_wait_min": 3,
"changeball_wait_max": 5
}
"catch_simulation": {
"flee_count": 3,
"flee_duration": 2,
"catch_wait_min": 3,
"catch_wait_max": 6,
"berry_wait_min": 3,
"berry_wait_max": 5,
"changeball_wait_min": 3,
"changeball_wait_max": 5,
"newtodex_wait_min": 20,
"newtodex_wait_max": 30
}
}
},
{
Expand Down
4 changes: 3 additions & 1 deletion configs/config.json.path.example
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@
"berry_wait_min": 3,
"berry_wait_max": 5,
"changeball_wait_min": 3,
"changeball_wait_max": 5
"changeball_wait_max": 5,
"newtodex_wait_min": 20,
"newtodex_wait_max": 30
}
}
},
Expand Down
40 changes: 21 additions & 19 deletions configs/config.json.pokemon.example
Original file line number Diff line number Diff line change
Expand Up @@ -122,33 +122,35 @@
"recycle_force_max": "00:01:00"
}
},
{
"type": "CatchPokemon",
"config": {
"enabled": true,
{
"type": "CatchPokemon",
"config": {
"enabled": true,
"catch_visible_pokemon": true,
"catch_lured_pokemon": true,
"min_ultraball_to_keep": 5,
"berry_threshold": 0.35,
"vip_berry_threshold": 0.9,
"treat_unseen_as_vip": true,
"catch_throw_parameters": {
"excellent_rate": 0.1,
"great_rate": 0.5,
"nice_rate": 0.3,
"normal_rate": 0.1,
"spin_success_rate" : 0.6
"excellent_rate": 0.1,
"great_rate": 0.5,
"nice_rate": 0.3,
"normal_rate": 0.1,
"spin_success_rate" : 0.6
},
"catch_simulation": {
"flee_count": 3,
"flee_duration": 2,
"catch_wait_min": 3,
"catch_wait_max": 6,
"berry_wait_min": 3,
"berry_wait_max": 5,
"changeball_wait_min": 3,
"changeball_wait_max": 5
}
"catch_simulation": {
"flee_count": 3,
"flee_duration": 2,
"catch_wait_min": 3,
"catch_wait_max": 6,
"berry_wait_min": 3,
"berry_wait_max": 5,
"changeball_wait_min": 3,
"changeball_wait_max": 5,
"newtodex_wait_min": 20,
"newtodex_wait_max": 30
}
}
},
{
Expand Down
10 changes: 9 additions & 1 deletion pokemongo_bot/cell_workers/pokemon_catch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


############################################################################
Expand Down Expand Up @@ -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]',
Expand All @@ -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'],
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit e2e13cf

Please sign in to comment.