Skip to content

Commit

Permalink
Merge branch 'tstumm-dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Stumm committed Jul 26, 2016
2 parents 4555466 + ff50e37 commit 27fa1d5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
22 changes: 14 additions & 8 deletions pokemongo_bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand All @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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()


Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pokemongo_bot/spiral_navigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -94,4 +94,4 @@ def take_step(self):
self.cnt = 0

sleep(1)
return [point['lat'], point['lng'], 0]
return [point['lat'], point['lng']]

0 comments on commit 27fa1d5

Please sign in to comment.