Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter out disabled or closed forts #6056

Merged
merged 1 commit into from
Jun 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(self, db, config):
self.catch_disabled = False

self.capture_locked = False # lock catching while moving to VIP pokemon

# Inform bot if there's a response
self.empty_response = False

Expand Down Expand Up @@ -963,9 +963,9 @@ def check_session(self, position):

def login(self):
status = {}
retry = 0
retry = 0
quit_login = False

self.event_manager.emit(
'login_started',
sender=self,
Expand All @@ -974,7 +974,7 @@ def login(self):
)
lat, lng = self.position[0:2]
self.api.set_position(lat, lng, self.alt) # or should the alt kept to zero?

while not quit_login:
try:
self.api.login(
Expand Down Expand Up @@ -1555,7 +1555,7 @@ def heartbeat(self):
except:
self.logger.warning('Error occured in heatbeat, retying')
self.empty_response = True

if not self.empty_response:
if responses['responses']['GET_PLAYER']['success'] == True:
# we get the player_data anyway, might as well store it
Expand Down Expand Up @@ -1622,6 +1622,19 @@ def get_forts(self, order_by_distance=False):
forts = [fort
for fort in self.cell['forts']
if 'latitude' in fort and 'type' in fort]
# Need to filter out disabled forts!
forts = filter(lambda x: x["enabled"] is True, forts)
forts = filter(lambda x: 'closed' not in fort, forts)

if order_by_distance:
forts.sort(key=lambda x: distance(
self.position[0],
self.position[1],
x['latitude'],
x['longitude']
))

return forts

if order_by_distance:
forts.sort(key=lambda x: distance(
Expand Down