diff --git a/.gitignore b/.gitignore index a65c0694af..003dde0c6a 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,12 @@ var/ *.manifest *.spec +# Eclipse Users +.project +.pydevproject +.settings/ + + # Installer logs pip-log.txt pip-delete-this-directory.txt @@ -90,15 +96,17 @@ ENV/ # Personal load details config.json -location.json src/ info.json inventory.json pokedex.json web/catchable.json -data/catch-ignore.yml web/catchable-*.json web/location-*.json +web/location.json +web/userdata.js +data/last-location*.json +data/catch-ignore.yml # ignore Pycharm config .idea diff --git a/README.md b/README.md index 91d42d55c5..6bcd2159fc 100644 --- a/README.md +++ b/README.md @@ -138,13 +138,13 @@ This project uses Google Maps. There's one map coupled with the project, but as -u USERNAME, --username USERNAME Username -p PASSWORD, --password PASSWORD Password -l LOCATION, --location LOCATION Location (Address or 'xx.yyyy,zz.ttttt') - -lc, --use-location-cache Bot will start at last known location + -lc, --location_cache Bot will start at last known location -c CP, --cp Set the CP to transfer or lower (eg. 100 will transfer CP0-99) -m MODE, --mode MODE Set farming Mode for the bot ('all', 'poke', 'farm') -w SPEED, --walk SPEED Walk instead of teleport with given speed (meters per second max 4.16 because of walking end on 15km/h) - --distance_unit UNIT Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet) - --initial-transfer Start the bot with a pokemon clean up, keeping only the higher CP of each pokemon. It respects -c as upper limit to release. - --maxsteps MAX_STEP Set the steps around your initial location (DEFAULT 5 mean 25 cells around your location) + -du, --distance_unit UNIT Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet) + -it, --initial_transfer Start the bot with a pokemon clean up, keeping only the higher CP of each pokemon. It respects -c as upper limit to release. + -ms, --max_steps MAX_STEP Set the steps around your initial location (DEFAULT 5 mean 25 cells around your location) -iv IV, --pokemon_potential Set the ratio for the IV values to transfer (eg. 0.8 will transfer a pokemon with IV 0.5) -d, --debug Debug Mode -t, --test Only parse the specified location @@ -260,6 +260,7 @@ To install the pgoapi use `pip install -e git://github.com/tejado/pgoapi.git#egg * luizperes * brantje * VirtualSatai + * dmateusp ## Credits [tejado](https://github.com/tejado) many thanks for the API diff --git a/config.json.example b/config.json.example index d9ec77e6da..66aed50122 100644 --- a/config.json.example +++ b/config.json.example @@ -1,14 +1,17 @@ { "auth_service": "google", - "username": "example@gmail.com", - "password": "password11!!", - "location": "New York", + "username": "YOURACCOUNT@gmail.com", + "password": "YOURPASSWORD", + "location": "SOME LOCATION", "cp": 100, - "gmapkey": "CHANGME", - "maxsteps": 100, + "gmapkey": "AGMAPAPIKEY", + "max_steps": 50, "mode": "all", "walk": 4.16, - "debug": true, - "test": false + "debug": false, + "test": false, + "initial_transfer": false, + "pokemon_potential": 0.70, + "location_cache": true, + "distance_unit": "km" } - diff --git a/pokecli.py b/pokecli.py index dde4aa4ced..f5bbde9bf5 100755 --- a/pokecli.py +++ b/pokecli.py @@ -60,20 +60,18 @@ def init_config(): parser.add_argument("-u", "--username", help="Username") parser.add_argument("-p", "--password", help="Password") parser.add_argument("-l", "--location", help="Location") - parser.add_argument("-lc", "--use-location-cache", help="Bot will start at last known location", action='store_true', default=False, dest='location_cache') + parser.add_argument("-lc", "--location_cache", help="Bot will start at last known location", type=bool, default=False) parser.add_argument("-m", "--mode", help="Farming Mode", type=str, default="all") parser.add_argument("-w", "--walk", help="Walk instead of teleport with given speed (meters per second, e.g. 2.5)", type=float, default=2.5) parser.add_argument("-c", "--cp",help="Set CP less than to transfer(DEFAULT 100)",type=int,default=100) parser.add_argument("-iv", "--pokemon_potential",help="Set IV ratio less than to transfer(DEFAULT 0.80)",type=float,default=0.80) - parser.add_argument("-k", "--gmapkey",help="Set Google Maps API KEY",type=str,default=None) - parser.add_argument("--maxsteps",help="Set the steps around your initial location(DEFAULT 5 mean 25 cells around your location)",type=int,default=5) - parser.add_argument("--initial-transfer", help="Transfer all pokemon with same ID on bot start, except pokemon with highest CP. It works with -c", action='store_true', dest='initial_transfer') - parser.add_argument("-d", "--debug", help="Debug Mode", action='store_true') - parser.add_argument("-t", "--test", help="Only parse the specified location", action='store_true') - parser.add_argument("--distance_unit", help="Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet)", type=str, default="m") - parser.set_defaults(DEBUG=False, TEST=False) + parser.add_argument("-k", "--gmapkey",help="Set Google Maps API KEY",type=str, default=None) + parser.add_argument("-ms","--max_steps",help="Set the steps around your initial location(DEFAULT 5 mean 25 cells around your location)",type=int,default=50) + parser.add_argument("-it", "--initial_transfer", help="Transfer all pokemon with same ID on bot start, except pokemon with highest CP. It works with -c", type=bool, default=False) + parser.add_argument("-d", "--debug", help="Debug Mode", type=bool, default=False) + parser.add_argument("-t", "--test", help="Only parse the specified location", type=bool, default=False) + parser.add_argument("-du","--distance_unit", help="Set the unit to display distance in (e.g, km for kilometers, mi for miles, ft for feet)", type=str, default="km") config = parser.parse_args() - if not config.username and not 'username' in load: config.username = raw_input("Username: ") if not config.password and not 'password' in load: @@ -91,7 +89,7 @@ def init_config(): if not config.location and not config.location_cache in load: logging.error("Needs either --use-location-cache or --location.") return None - + print(config) return config def main(): diff --git a/pokemongo_bot/__init__.py b/pokemongo_bot/__init__.py index 390380ecb1..47fcf345e3 100644 --- a/pokemongo_bot/__init__.py +++ b/pokemongo_bot/__init__.py @@ -282,7 +282,7 @@ def _set_starting_position(self): try: # # save location flag used to pull the last known location from the location.json - with open('location.json') as f: + with open('data/last-location-%s.json' % (self.config.username)) as f: location_json = json.load(f) self.position = (location_json['lat'], location_json['lng'], 0.0) @@ -310,7 +310,7 @@ def _set_starting_position(self): def _get_pos_by_name(self, location_name): geolocator = GoogleV3(api_key=self.config.gmapkey) - loc = geolocator.geocode(location_name) + loc = geolocator.geocode(location_name, timeout=10) #self.log.info('Your given location: %s', loc.address.encode('utf-8')) #self.log.info('lat/long/alt: %s %s %s', loc.latitude, loc.longitude, loc.altitude) diff --git a/pokemongo_bot/stepper.py b/pokemongo_bot/stepper.py index 5863dabb47..57f3031dfe 100644 --- a/pokemongo_bot/stepper.py +++ b/pokemongo_bot/stepper.py @@ -26,7 +26,7 @@ def __init__(self, bot): self.y = 0 self.dx = 0 self.dy = -1 - self.steplimit=self.config.maxsteps + self.steplimit=self.config.max_steps self.steplimit2 = self.steplimit**2 self.origin_lat = self.bot.position[0] self.origin_lon = self.bot.position[1] @@ -92,6 +92,9 @@ def _work_at_position(self, lat, lng, alt, pokemon_only=False): if 'map_cells' in response_dict['responses']['GET_MAP_OBJECTS']: with open('web/location-%s.json' % (self.config.username), 'w') as outfile: json.dump({'lat': lat, 'lng': lng,'cells':response_dict['responses']['GET_MAP_OBJECTS']['map_cells']}, outfile) + with open('data/last-location-%s.json' % (self.config.username), 'w') as outfile: + outfile.truncate() + json.dump({'lat': lat, 'lng' : lng},outfile) if response_dict and 'responses' in response_dict: if 'GET_MAP_OBJECTS' in response_dict['responses']: if 'status' in response_dict['responses']['GET_MAP_OBJECTS']: diff --git a/web/main.js b/web/main.js index 118651c85a..cb647fe3a1 100644 --- a/web/main.js +++ b/web/main.js @@ -62,6 +62,9 @@ var trainerFunc = function(data, user_index) { /* var z = 0; for (var i = 0; i < data.cells.length; i++) { cell = data.cells[i]; + if (!cell.hasOwnProperty(forts)) { + continue; + } for (var x = 0; x < data.cells[i].forts.length; x++) { var fort = cell.forts[x]; if (!forts[fort.id]) {