Skip to content

Commit c2e3b84

Browse files
author
Marcel Hofer
committed
make use of self.visited_forts non-experimental
1 parent 9488e18 commit c2e3b84

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

pgoapi/location.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,23 @@ def distance_in_meters(p1, p2):
8181
return vincenty(p1, p2).meters
8282

8383

84-
def filtered_forts(starting_location, origin, forts, proximity, visited_forts={}, experimental=False, reverse=False):
85-
forts = filter(lambda f: is_active_pokestop(f[0], experimental=experimental,
86-
visited_forts=visited_forts, starting_location=starting_location,
84+
def filtered_forts(starting_location, origin, forts, proximity, visited_forts={}, reverse=False):
85+
forts = filter(lambda f: is_active_pokestop(f[0], visited_forts=visited_forts, starting_location=starting_location,
8786
proximity=proximity),
8887
map(lambda x: (x, distance_in_meters(origin, (x['latitude'], x['longitude']))), forts))
8988

9089
sorted_forts = sorted(forts, key=lambda x: x[1], reverse=reverse)
9190
return sorted_forts
9291

9392

94-
def is_active_pokestop(fort, experimental, visited_forts, starting_location, proximity):
93+
def is_active_pokestop(fort, visited_forts, starting_location, proximity):
9594
is_active_fort = fort.get('type', None) == 1 and ("enabled" in fort or 'lure_info' in fort) and fort.get(
9695
'cooldown_complete_timestamp_ms', -1) < time() * 1000
97-
if experimental and visited_forts:
98-
if proximity and proximity > 0:
99-
return is_active_fort and fort['id'] not in visited_forts and distance_in_meters(starting_location, (
100-
fort['latitude'], fort['longitude'])) < proximity
101-
else:
102-
return is_active_fort and fort['id'] not in visited_forts
10396
if proximity and proximity > 0:
104-
return is_active_fort and distance_in_meters(starting_location,
105-
(fort['latitude'], fort['longitude'])) < proximity
97+
return is_active_fort and fort['id'] not in visited_forts and distance_in_meters(starting_location, (
98+
fort['latitude'], fort['longitude'])) < proximity
10699
else:
107-
return is_active_fort
100+
return is_active_fort and fort['id'] not in visited_forts
108101

109102

110103
# from pokemongodev slack @erhan

pgoapi/pgoapi.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,7 @@ def walk_back_to_origin(self):
528528
def spin_nearest_fort(self):
529529
map_cells = self.nearby_map_objects()['responses'].get('GET_MAP_OBJECTS', {}).get('map_cells', [])
530530
forts = PGoApi.flatmap(lambda c: c.get('forts', []), map_cells)
531-
destinations = filtered_forts(self._origPosF, self._posf, forts, self.STAY_WITHIN_PROXIMITY, self.visited_forts,
532-
self.experimental)
531+
destinations = filtered_forts(self._origPosF, self._posf, forts, self.STAY_WITHIN_PROXIMITY, self.visited_forts)
533532
if destinations:
534533
nearest_fort = destinations[0][0]
535534
nearest_fort_dis = destinations[0][1]
@@ -590,8 +589,7 @@ def spin_all_forts_visible(self):
590589
res = self.nearby_map_objects()
591590
map_cells = res['responses'].get('GET_MAP_OBJECTS', {}).get('map_cells', [])
592591
forts = PGoApi.flatmap(lambda c: c.get('forts', []), map_cells)
593-
destinations = filtered_forts(self._origPosF, self._posf, forts, self.STAY_WITHIN_PROXIMITY, self.visited_forts,
594-
self.experimental)
592+
destinations = filtered_forts(self._origPosF, self._posf, forts, self.STAY_WITHIN_PROXIMITY, self.visited_forts)
595593
if not destinations:
596594
self.log.debug("No fort to walk to! %s", res)
597595
self.log.info('No more spinnable forts within proximity. Or server error')
@@ -623,8 +621,7 @@ def spin_near_fort(self):
623621
res = self.nearby_map_objects()
624622
map_cells = res['responses'].get('GET_MAP_OBJECTS', {}).get('map_cells', [])
625623
forts = PGoApi.flatmap(lambda c: c.get('forts', []), map_cells)
626-
destinations = filtered_forts(self._origPosF, self._posf, forts, self.STAY_WITHIN_PROXIMITY, self.visited_forts,
627-
self.experimental)
624+
destinations = filtered_forts(self._origPosF, self._posf, forts, self.STAY_WITHIN_PROXIMITY, self.visited_forts)
628625
if not destinations:
629626
self.log.debug("No fort to walk to! %s", res)
630627
self.log.info('No more spinnable forts within proximity. Returning back to origin')

0 commit comments

Comments
 (0)