Closed Paramon closed 8 years ago
If I understand correctly, we need sortCloseFort function like this:
def sortCloseFort(session, type = 1):
logging.info("Sorting Nearest Forts:")
cells = session.getMapObjects()
latitude, longitude, _ = session.getCoordinates()
forts = [fort for cell in cells.map_cells for fort in cell.forts if fort.type == type]
return sorted(forts, key=lambda f: Location.getDistance(latitude, longitude, f.latitude, f.longitude))
And from findClosestGym call with type for Gym. If it's so I will do it. ;-)
Yes. As a Pokemon select.
I suggest create something like "cell worker" class. Who extract all data from cells.
And move all logic of finding, filtering and sorting (rarity of Pokemons, Forts type, etc...) cell data in it.
I believe there is no 'type' given in a Gym 'fort' I would remove the attribute in sortCloseForts
And do the loop and type check in
findClosestPokestop()
forts = sortCloseForts
for fort in forts:
if fort.type and fort.type == 1:
return fort
findClosestGym()
forts = sortCloseForts
for fort in forts:
#just to be sure, if there is type (not 100% sure about it atm)
if not fort.type or fort.type != 1:
return fort
Something like that :)
You can even set globals, pokestops {} gyms {} pokemons {}
and just return first occurance on them.
Shouldn't you leave it out the way, and use only 1 function to retrieve forts. As a Pokestop is a Fort, and a Gym as well.
Just make the difference in findClosestPokestop, findClosestGym or just... findClosestFort if it doesnt matter where you go, and how extended the bot is ;-)