Skip to content

Commit

Permalink
fix followCluster & MoveToMapPokemon (#4115)
Browse files Browse the repository at this point in the history
* * fixed followCluster not following lured clusters because of outdated pokestop data structure
* fixed very annoying followCluster wording (OCD senses were tickling)
* fixed #4022

* no message

* string formatting

* correcting message to display lured only when walking to lured cluster

* message formatting

* forgot to add regester event variable
  • Loading branch information
mvrska authored and solderzzc committed Aug 17, 2016
1 parent 8a7580e commit ad91ac7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def _register_events(self):
self.event_manager.register_event(
'arrived_at_cluster',
parameters=(
'forts', 'radius'
'num_points', 'forts', 'radius'
)
)

Expand Down
15 changes: 8 additions & 7 deletions pokemongo_bot/cell_workers/follow_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def work(self):
log_lure_avail_str = ''
log_lured_str = ''
if self.lured:
log_lured_str = 'lured '
lured_forts = [x for x in forts if 'lure_info' in x]
lured_forts = [x for x in forts if 'active_fort_modifier' in x]
if len(lured_forts) > 0:
self.dest = find_biggest_cluster(self.radius, lured_forts, 'lure_info')
log_lured_str = 'lured '
self.dest = find_biggest_cluster(self.radius, lured_forts, '9QM=')
else:
log_lure_avail_str = 'No lured pokestops in vicinity. Search for normal ones instead. '
self.dest = find_biggest_cluster(self.radius, forts)
Expand All @@ -39,7 +39,7 @@ def work(self):

if not self.is_at_destination:
msg = log_lure_avail_str + (
"Move to destiny {num_points}. {forts} "
"Move to cluster: {num_points} {forts} "
"pokestops will be in range of {radius}. Walking {distance}m."
)
self.emit_event(
Expand All @@ -49,7 +49,7 @@ def work(self):
'num_points': cnt,
'forts': log_lured_str,
'radius': str(self.radius),
'distance': str(distance(self.bot.position[0], self.bot.position[1], lat, lng))
'distance': str(round(distance(self.bot.position[0], self.bot.position[1], lat, lng), 2))
}
)

Expand All @@ -71,9 +71,10 @@ def work(self):
elif not self.announced:
self.emit_event(
'arrived_at_cluster',
formatted="Arrived at cluster. {forts} are in a range of {radius}m radius.",
formatted="Arrived at cluster. {num_points} {forts} pokestops are in a range of {radius}m radius.",
data={
'forts': str(cnt),
'num_points': cnt,
'forts': log_lured_str,
'radius': self.radius
}
)
Expand Down
2 changes: 1 addition & 1 deletion pokemongo_bot/cell_workers/move_to_map_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def get_pokemon_from_map(self):

# pokemon not reachable with mean walking speed (by config)
mean_walk_speed = (self.bot.config.walk_max + self.bot.config.walk_min) / 2
if pokemon['dist'] > ((pokemon['expire'] - now) * mean_walk_speed) and not self.config['snipe']:
if pokemon['dist'] > ((pokemon['disappear_time'] - now) * mean_walk_speed) and not self.config['snipe']:
continue

pokemon_list.append(pokemon)
Expand Down
7 changes: 5 additions & 2 deletions pokemongo_bot/cell_workers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,11 @@ def rad2deg(rad):
def find_biggest_cluster(radius, points, order=None):
graph = nx.Graph()
for point in points:
if order is 'lure_info':
f = point['latitude'], point['longitude'], point['lure_info']['lure_expires_timestamp_ms']
if order is '9QM=':
#is a lure module - 9QM=
now = int(time.time())
remaining = now - point['last_modified_timestamp_ms']
f = point['latitude'], point['longitude'], remaining
else:
f = point['latitude'], point['longitude'], 0
graph.add_node(f)
Expand Down

0 comments on commit ad91ac7

Please sign in to comment.