diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index e5e82f4f13..d830b7891a 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -14,13 +14,18 @@ import logger from cell_workers import PokemonCatchWorker, SeenFortWorker, MoveToFortWorker, InitialTransferWorker, EvolveAllWorker -from cell_workers.utils import distance, get_cellid, encode +from cell_workers.utils import distance, get_cellid, encode, i2f from human_behaviour import sleep from item_list import Item from spiral_navigator import SpiralNavigator class PokemonGoBot(object): + + @property + def position(self): + return (self.api._position_lat, self.api._position_lng) + def __init__(self, config): self.config = config self.pokemon_list = json.load(open('data/pokemon.json')) @@ -42,11 +47,11 @@ def take_step(self): 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 and map_cells if lat == None: - lat = self.position[0] + lat = i2f(self.api._position_lat) if lng == None: - lng = self.position[1] + lng = i2f(self.api._position_lng) if alt == None: - alt = self.position[2] + alt = 0 if cells == []: cellid = get_cellid(lat, lng) @@ -116,7 +121,7 @@ def find_close_cells(self, lat, lng): x['forts'][0]['latitude'], x['forts'][0]['longitude']) if x.get('forts', []) else 1e6 ) - self.update_web_location(map_cells,lat,lng) + self.update_web_location(map_cells) return map_cells def work_on_cell(self, cell, position): @@ -239,7 +244,7 @@ def check_session(self, position): if remaining_time < 60: logger.log("Session stale, re-logging in", 'yellow') - self.position = position + self.position = [i2f(self.api._position_lat), i2f(self.api._position_lng), 0] self.login() @@ -281,7 +286,7 @@ def _setup_api(self): logger.log('') self.update_inventory() # send empty map_cells and then our position - self.update_web_location([],*self.position) + self.update_web_location() def _print_character_info(self): # get player profile call @@ -435,7 +440,8 @@ def _set_starting_position(self): self.position = location self.api.set_position(*self.position) logger.log('') - logger.log(u'Location Found: {}'.format(location_str)) + logger.log(u'Location Found: {}'.format(self.config.location.decode( + 'utf-8'))) logger.log('GeoPosition: {}'.format(self.position)) logger.log('') has_position = True diff --git a/pokemongo_bot/spiral_navigator.py b/pokemongo_bot/spiral_navigator.py index 0ceb9a28f5..51647c9590 100644 --- a/pokemongo_bot/spiral_navigator.py +++ b/pokemongo_bot/spiral_navigator.py @@ -15,7 +15,7 @@ def __init__(self, bot): self.origin_lat = self.bot.position[0] self.origin_lon = self.bot.position[1] - self.points = self._generate_spiral(self.origin_lat, self.origin_lon, 0.0025, self.steplimit) + self.points = self._generate_spiral(self.origin_lat, self.origin_lon, 0.0018, self.steplimit) self.ptr = 0 self.direction = 1 self.cnt = 0 @@ -94,4 +94,4 @@ def take_step(self): self.cnt = 0 sleep(1) - return [point['lat'], point['lng'], 0] + return [point['lat'], point['lng']]