Skip to content

Commit 4283fa8

Browse files
author
Marcel
authored
Merge pull request jekirl#344 from destiny117/fix-api-limit
Make use of self.visited_forts non-experimental
2 parents fa30f04 + c2e3b84 commit 4283fa8

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
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: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,7 @@ def spin_all_forts_visible(self):
590590
res = self.nearby_map_objects()
591591
map_cells = res['responses'].get('GET_MAP_OBJECTS', {}).get('map_cells', [])
592592
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)
593+
destinations = filtered_forts(self._origPosF, self._posf, forts, self.STAY_WITHIN_PROXIMITY, self.visited_forts)
595594
if not destinations:
596595
self.log.debug("No fort to walk to! %s", res)
597596
self.log.info('No more spinnable forts within proximity. Or server error')
@@ -623,8 +622,7 @@ def spin_near_fort(self):
623622
res = self.nearby_map_objects()
624623
map_cells = res['responses'].get('GET_MAP_OBJECTS', {}).get('map_cells', [])
625624
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)
625+
destinations = filtered_forts(self._origPosF, self._posf, forts, self.STAY_WITHIN_PROXIMITY, self.visited_forts)
628626
if not destinations:
629627
self.log.debug("No fort to walk to! %s", res)
630628
self.log.info('No more spinnable forts within proximity. Returning back to origin')

0 commit comments

Comments
 (0)