Skip to content

Commit

Permalink
Dev - Fixed the loss of fort data (updated) (PokemonGoF#2269)
Browse files Browse the repository at this point in the history
* Keep fort data even if the server returns no fort data. Also replaced redundant code.

* Making sure we only save fort data if the server returned multiple forts.
  • Loading branch information
Abraxas000 authored and Zhou committed Aug 2, 2016
1 parent 7df44e9 commit 3ec36ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@
* NamPNQ
* z4ppy.bbc
* matheussampaio
* Abraxas000
31 changes: 17 additions & 14 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,21 @@ def get_meta_cell(self):
wild_pokemons += cell["wild_pokemons"]
if "catchable_pokemons" in cell and len(cell["catchable_pokemons"]):
catchable_pokemons += cell["catchable_pokemons"]

return {
"forts": forts,
"wild_pokemons": wild_pokemons,
"catchable_pokemons": catchable_pokemons
}

# If there are forts present in the cells sent from the server or we don't yet have any cell data, return all data retrieved
if len(forts) > 1 or not self.cell:
return {
"forts": forts,
"wild_pokemons": wild_pokemons,
"catchable_pokemons": catchable_pokemons
}
# If there are no forts present in the data from the server, keep our existing fort data and only update the pokemon cells.
else:
return {
"forts": self.cell["forts"],
"wild_pokemons": wild_pokemons,
"catchable_pokemons": catchable_pokemons
}

def update_web_location(self, cells=[], lat=None, lng=None, alt=None):
# we can call the function with no arguments and still get the position
Expand All @@ -121,14 +130,8 @@ def update_web_location(self, cells=[], lat=None, lng=None, alt=None):
alt = 0

if cells == []:
cellid = get_cell_ids(lat, lng)
timestamp = [0, ] * len(cellid)
response_dict = self.get_map_objects(lat, lng, timestamp, cellid)
map_objects = response_dict.get(
'responses', {}
).get('GET_MAP_OBJECTS', {})
status = map_objects.get('status', None)
cells = map_objects['map_cells']
location = self.position[0:2]
cells = self.find_close_cells(*location)

# insert detail info about gym to fort
for cell in cells:
Expand Down

0 comments on commit 3ec36ca

Please sign in to comment.